Frage

Im trying to build Win8 metro style application. Im trying to play remote video which is on web in media element.

      MediaElement media = new MediaElement();
        Uri url = new Uri("some url on web");
        media.Source = url;
        media.Play();

The first streaming takes time. It takes time to video to start play, in this meantime application is locked. I want to do that playing ascnhronously. How can i achive this.

War es hilfreich?

Lösung

after some search, i find out that with dispatcher element, i can do my work asynchronously. Here is the sample:

await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
         {
            MediaElement media = new MediaElement();
            Uri url = new Uri("some url on web");
            media.Source = url;
            media.Play();
         }

        );

You have to mark the calling function as async in order this code block to work.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top