简体   繁体   中英

Problem with MediaPlayerElement looping videos UWP

I am developing a wildlife related application and want to keep looping a short video of certain animals.

I am using MediaPlayerElement to play the video. With some research, I've found out that the MediaPlayerElement has a function called IsLoopingEnabled for looping media. But when I try implementing it, a sytax error is shown telling me

'MediaPlayerElement' does not contain a definition for 'IsLoopingEnabled' and no accessible method 'IsLoopingEnabled' accepting a first argument of type 'MediaPlayerElement'could be found (are you missing a using derivative or an assembly reference?)

My XAML code:

<MediaPlayerElement x:Name="mediaPlayer"
    Source="ms-appx:///Assets/video.mp4"
    Width="Auto"
    AutoPlay="True"
    Stretch="Fill"
    AreTransportControlsEnabled="False" />

In C#

mediaPlayer.IsLoopingEnabled=true;

UWP MediaPlayerElement - how to loop/repeat mp4 and official documentation show that this function exists. Am I doing something wrong?

You were almost there. MediaPlayerElement has a property called MediaPlayer which has IsLoopingEnabled . So you need to set it like below.

mediaPlayer.MediaPlayer.IsLoopingEnabled = true;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM