I would like to change the song on my MediaElent from track1.mp3 to track2.mp3. And here is the code:
MyMediaElement.Stop(); Uri u = new Uri("track2.mp3", UriKind.Relative); MyMediaElement.Source=u; MyMediaElement.Play();
MediaElement changes source but does not start. What could be wrong with this code?
Try setting MyMediaElement.AutoPlay to true, as soon as the source file changes, it should play. You can also explore using the MediaElement.SetSource () method, which accepts a stream, not a uri.
. XAML, , , .MediaOpened ., Play() , . . , Play(); .
, . , : -
track2 , ?
MediaFailed, ?
TextBlock CurrentState, , CurrentState.
You install AutoPlayin false, and then in the MediaOpened handler you execute Play(). People kind of hinted at a solution here, but not very accurately. You can also handle the MediaFailed event in case the media does not open for any reason (file cannot be found, etc.).
AutoPlay
false
Play()
Source: https://habr.com/ru/post/1732453/More articles:LastActivityDate Custom Membership List - asp.netWhy does this extension method not work? - c #Learning Haskell: How to Implement My Own Version of the init Function - haskellВ Ruby, как вы можете вызывать метод с использованием аргумента по умолчанию или с указанным аргументом без повторения кода? - rubyСсылаясь на не заключительные поля окружающего класса внутри анонимного внутреннего класса в Java - javaUsing Link Passing in Objective-C - objective-cHow are self-extracting executable files made? - extractLook for an elegant skin solution appwidget - androidполучение хэш-карты в R с использованием rJava - javaParallel modification Exception thrown .next from Iterator - javaAll Articles