c# - Strange behavior with WPF MediaElement -
c# - Strange behavior with WPF MediaElement -
i current using mediaelement play variety of different files , seem have of working.
one thing noticed sound files (in case mp3's specifically) reject play on first attempt. can hear millisecond (very unattractive) worth of sound. more blip , nothing. subsequent effort load music works fine, odd. videos play on first attempt, , streamed media. seems apply local sound files.
the code starts both sound , video files pretty much identical.
private void lvvideos_mousedoubleclick(object sender, mousebuttoneventargs e) { var depobj = e.originalsource dependencyobject; if (depobj != null) { var parent = depobj.findvisualancestor<listviewitem>(); if (parent != null && lvvideos.selecteditem != null) { state = playstate.closed; video video = lvvideos.selecteditem video; if (video == null) return; lbltrackname.text = video.title; mediaplayer.source = null; mediaplayer.source = new uri(video.location); currentmedia = mediatype.video; state = playstate.playing; } } } private void lvmusic_mousedoubleclick(object sender, mousebuttoneventargs e) { var depobj = e.originalsource dependencyobject; if (depobj != null) { var parent = depobj.findvisualancestor<listviewitem>(); if (parent != null && lvmusic.selecteditem != null) { state = playstate.closed; music song = lvmusic.selecteditem music; if (song == null) return; lbltrackname.text = song.title; mediaplayer.source = null; mediaplayer.source = new uri(song.location); currentmedia = mediatype.music; state = playstate.playing; } } } as can see attempted null source property prior loading sound no avail. have managed come dirty hack of workaround. involved setting source file gaurenteed fail (the app's .exe) , playing app initialized. allows first music file loaded play properly.
has else come across before? , there fixes?
edit: omg sense stupid. apparently culprit mediaelement.scrubbingenabled = true; (by documentation) seemingly useful option, perhaps should enabled remote streams?
apparently culprit mediaelement.scrubbingenabled = true; (by documentation) seemingly useful option, perhaps should enabled remote streams?
c# wpf audio .net-4.0 mediaelement
Comments
Post a Comment