Windows Forms C# WMPLib Crashes while playing a mp3 file -
i'm working on simple mp3 player. i'm using wmplib playing mp3 files.
i'm displaying tracks in data grid view, double click plays selected track. program plays right song, once start scrolling or pressing buttons song stops playing.
this method i'm using playing individual tracks:
public static void playtrack(int t) { library l = new library(); wmplib.windowsmediaplayer song = new wmplib.windowsmediaplayer(); song.url = l.mylibrary[t].patch; song.controls.play(); }
i call above method when datagridview1_cellcontentdoubleclick
raised in separate class.
do guys know why happening?
do need use multi threading in order fix it?
i thought program's ui "heavy" i'm using multiple nested panels in custom controls. i'm including print screen of running application.
ok, found answer problem. needed declare library , wmplib field outside of method shown below:
static library l; static wmplib.windowsmediaplayer song; public static void playtrack(int t) { l = new library(); song = new wmplib.windowsmediaplayer(); song.url = l.mylibrary[t].patch; song.controls.play(); }
i hope helps :)
Comments
Post a Comment