MediaElement can not play video from InMemoryRandomAccessStream RRS feed

  • Question

  • hi  guys,

    I have an queston. For some reasons, I need to use InMemoryRandomAccessStream to SetSource for my Media Element control . I found if I convert IRandomAccessStream (oristream)  To InMemoryRandomAccessStream (memoryStream2) , and then SetSource to Media Element (me_Video) . The Media Element control can not play the video ,  but it can  work by using  await File.OpenReadAsync() directly. Can someone help me ? Thanks!

    The following is my test code.


     var File = await Package.Current.InstalledLocation.GetFileAsync(@"Assets\VideoSample\sec10.mp4");

     var oristream = await File.OpenReadAsync(); 

     var memoryStream = new MemoryStream();

     Stream stream = oristream.AsStream();


    Byte[]  byteData= memoryStream.ToArray();

    IRandomAccessStream memoryStream2 = new InMemoryRandomAccessStream();

    DataWriter datawriter = new DataWriter(memoryStream2.GetOutputStreamAt(0));


    await datawriter.StoreAsync();

    //Media Element control: me_Video

     me_Video.SetSource(memoryStream2, "video/mp4"); //  oristream  can work fine


    Wednesday, December 25, 2013 10:58 AM


  • Hi,

    Please see MediaElement.SetSource method。the stream type should be


    Best Wishes!

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by Anne Jing Thursday, January 2, 2014 6:51 AM
    Thursday, December 26, 2013 2:27 AM