c# - Listen for MediaEnded event in another window -
i'm making simple c# wpf video player app.
i have 2 windows: mainwindow (parent window) contains mediaelement display video. playlistwindow (child window) window contains listbox displays .avi files in approot path.
currently, when double-click on listbox item, plays video in mainwindow. have auto-play feature next item in list automatically played when current video ends.
i playlistwindow listen mediaended event triggered mediaelement in mainwindow can perform action on listbox in playlistwindow.
how can subscribe mediaended event playlistwindow?
edit add: ended using different approach shown below. don't think best way it, works me.
public partial class mainwindow : window { playlistwindow plwindow = new playlistwindow(); public mainwindow() { initializecomponent(); } private void mainwindow_loaded(object sender, routedeventargs e) { plwindow.owner = this; plwindow.show(); } private void videowindow_ended(object sender, eventargs e) { plwindow.playnext(); } } public partial class playlistwindow : window { public void playnext() { if (playlistbox.selectedindex < playlistbox.items.count - 1) { playlistbox.selectedindex = playlistbox.selectedindex + 1; } else { playlistbox.selectedindex = 0; } (owner mainwindow).playvideo(playlistbox.selectedvalue.tostring()); } }
i'm still open learning how listen mediaended event in playlistwindow if code sample can posted.
raise custom .net event main window(this custom event raised media ended event) , subscribe in playlist window, in event handler of event return file name of next .avi file
Comments
Post a Comment