Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MediaElement web Video doesn't stop buffering

I m using MediaElement to play a web video. When I left the page I noticed in the Task Manager that my app was still using 10% of network and didn't drop till it finished downloading video.

I tried doing the following but no luck.

    //open link;
    mediaElement.Source = welcomeVideoURL;

    //when I leave the page OnNavigatedFrom()
    mediaElement.Stop();
    mediaElement.ClearValue(MediaElement.SourceProperty);
    mediaElement.Source = null;

Also tried to set the source to a dummy link but still no luck.

I thought that opening the Link as a Stream and use mediaElement.SetSource() could work but I haven't found anything on that...maybe I m not searching correct.

Thank you.

like image 379
Stamos Avatar asked Feb 08 '16 17:02

Stamos


1 Answers

Found this MediaElementWithHttpClient in some other question in a comment made by @kiewic. I can manage the stream and download process and easily dispose it.

 HttpRandomAccessStream videoStream = await HttpRandomAccessStream.CreateAsync(new Windows.Web.Http.HttpClient(), videoUrl);
 mediaElement.SetSource(videoStream, videoStream.ContentType);
like image 70
Stamos Avatar answered Nov 04 '22 10:11

Stamos