locked
MediaElement doesn't load source video every time (intermittent)

    Question

  • I use several MediaElement (AutoPlay) in a GridView as source video list (there not real-time loaded) when clicked the Binded MediaElement (used as the player) start playing but it doesn't work every time, sometimes the videos in the GridView mediaelement end up being black... But the interaction still works. I want to have all videos playing in loop (muted) at all times so it add life to the app.

    <MediaElement x:Name="VideoPlayer" Grid.Row="0" Margin="0" Stretch="UniformToFill" PosterSource="ms-appx:///Assets/Backgrounds/back-video.png" Source="{Binding ElementName=VideoList, Path=SelectedItem.Source}" AreTransportControlsEnabled="True" MediaEnded="VideoPlayer_MediaEnded">
                <MediaElement.Transitions>
                    <TransitionCollection>
                        <ContentThemeTransition HorizontalOffset="-1500" />
                    </TransitionCollection>
                </MediaElement.Transitions>            
            </MediaElement>
            <GridView x:Name="VideoList" Grid.Row="1" Padding="0" Margin="0">
                <GridView.Transitions>
                    <TransitionCollection>
                        <ContentThemeTransition VerticalOffset="2500"/>
                    </TransitionCollection>
                </GridView.Transitions>
                <MediaElement Source="ms-appx:///Assets/Video/video0.mp4" Position="00:00:05" IsLooping="True" AutoPlay="true" IsMuted="True" Margin="0" Stretch="UniformToFill" PosterSource="ms-appx:///Assets/Backgrounds/back-video.png" />
                <MediaElement Source="ms-appx:///Assets/Video/video1.mp4" IsLooping="True" AutoPlay="true" IsMuted="True" Margin="0" Stretch="UniformToFill" PosterSource="ms-appx:///Assets/Backgrounds/back-video.png" />
                <MediaElement Source="ms-appx:///Assets/Video/video2.mp4" IsLooping="True" AutoPlay="true" IsMuted="True" Margin="0" Stretch="UniformToFill" PosterSource="ms-appx:///Assets/Backgrounds/back-video.png" />
                <MediaElement Source="ms-appx:///Assets/Video/video3.mp4" IsLooping="True" AutoPlay="true" IsMuted="True" Margin="0" Stretch="UniformToFill" PosterSource="ms-appx:///Assets/Backgrounds/back-video.png" />
                <MediaElement Source="ms-appx:///Assets/Video/video4.mp4" Position="00:00:05" IsLooping="True" AutoPlay="true" IsMuted="True" Margin="0" Stretch="UniformToFill" PosterSource="ms-appx:///Assets/Backgrounds/back-video.png" />
                <MediaElement Source="ms-appx:///Assets/Video/video5.mp4" IsLooping="True" AutoPlay="true" IsMuted="True" Margin="0" Stretch="UniformToFill" PosterSource="ms-appx:///Assets/Backgrounds/back-video.png" />
            </GridView>

    Tuesday, October 07, 2014 10:44 PM

Answers

  • Hello,

    While I wasn't able to reproduce your issue exactly I was able to reproduce something that I think is very similar. I am also seeing "black video" when I have MediaElements as an ItemTemplate. I believe that this behavior is due to the fact that there are no available video resources to facilitate the current playback request. Keep in mind that the video decoding takes place in hardware. If there are not enough hardware resources to facilitate the request then the playback will fail. You might want to handle the "media failed" event in your master MediaElement to see if you get any additional detail.

    I might suggest that you handle this differently. Only start playback of the MediaElement in the ListView when the user touches and holds the item. This will act as a preview. When they tap and release the video starts playing back in the master. Limiting playback to only one or two MediaElements should resolve the hardware resource problem.

    I hope this helps,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    • Marked as answer by Jamles HezModerator Monday, October 20, 2014 2:29 AM
    • Unmarked as answer by ClementM Thursday, October 23, 2014 2:12 AM
    • Marked as answer by ClementM Thursday, October 23, 2014 2:12 AM
    Wednesday, October 08, 2014 1:02 AM
    Moderator

All replies

  • Hello,

    While I wasn't able to reproduce your issue exactly I was able to reproduce something that I think is very similar. I am also seeing "black video" when I have MediaElements as an ItemTemplate. I believe that this behavior is due to the fact that there are no available video resources to facilitate the current playback request. Keep in mind that the video decoding takes place in hardware. If there are not enough hardware resources to facilitate the request then the playback will fail. You might want to handle the "media failed" event in your master MediaElement to see if you get any additional detail.

    I might suggest that you handle this differently. Only start playback of the MediaElement in the ListView when the user touches and holds the item. This will act as a preview. When they tap and release the video starts playing back in the master. Limiting playback to only one or two MediaElements should resolve the hardware resource problem.

    I hope this helps,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    • Marked as answer by Jamles HezModerator Monday, October 20, 2014 2:29 AM
    • Unmarked as answer by ClementM Thursday, October 23, 2014 2:12 AM
    • Marked as answer by ClementM Thursday, October 23, 2014 2:12 AM
    Wednesday, October 08, 2014 1:02 AM
    Moderator
  • I'll try it... Thanks
    Wednesday, October 08, 2014 4:59 PM