Blazored / Video

The easiest html5 video implementation for Blazor applications
https://blazored.github.io/Video
MIT License
127 stars 28 forks source link

[Bug] How to set autoplay and loop options? Not working atm. #7

Closed progMorten closed 1 year ago

progMorten commented 3 years ago

Hi! I am working on a hobby project at the moment, trying to incorporate this video component, but Im struggling to implementing AutoPlay and Loop on load, without the controls. I am trying to implement this kind of fullscreen playing in the background with some text above, so I need the controls hidden. I have tried setting different state options in OnInitialized:

options[VideoEvents.CanPlay] = new VideoStateOptions { Autoplay = true,Loop = true }; options[VideoEvents.LoadStart] = new VideoStateOptions { Autoplay = true, Loop = true }; options[VideoEvents.Progress] = new VideoStateOptions { Autoplay = true, Loop = true };

But the video just does not start. I also tried adding different OnCanPlay, OnLoadStart and OnProgress methods with break points, but they never hit. So the video never starts.

is this anything you could help me with? Thanks for your contribution! :)

Kind regards, Morten

SQL-MisterMagoo commented 3 years ago

Hi,

You can just use the attributes for that

<BlazoredVideo @ref="video" EventFired="OnEvent"
         VideoEventOptions="options"

         autoplay="autoplay" 
         loop="loop" >

    <source src="samples/elephants.mp4" type="video/mp4" />
</BlazoredVideo>