Blazored / Video

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

how do I abort a video while it is playing #28

Open rclancy opened 9 months ago

rclancy commented 9 months ago

I have a Blazor web application that passes byte arrays to BlazoredVideo but when I want to change the source, the application freezest. How can I abort the current video so I can change the source?

chrislangston commented 1 month ago

I'm not sure your specific use case, but I'll share how I'm doing this.

I have a playlist of videos that the user can see in a panel on the right side of the webpage. When a video is playing and it reached the end, it will automatically queue up the next video and begin to auto play. Or if the user clicks a new link in the playlist, I will adjust bound properties.

I adjust the correct properties bound to the BlazoredVideo component and then make the following calls: await MyBlazorVideo.ReloadControl(); await MyBlazorVideo.StartPlayback();

        <BlazoredVideo @ref="MyBlazorVideo"
                       TimeUpdateEvent="OnEvent"
                       Play="OnPlay"
                       Ended="OnEnded"
                       VideoEventOptions="options"
                       class="w-100"
                       autofocus="true"
                       controls="controls">
            <source src="@VideoSource" type="video/mp4" />
        </BlazoredVideo>
rclancy commented 1 month ago

Hi Chris, I have a list hyperlinks of video titles in a Blazor page. When I click on any one, it plays the video. This works fine if no video is playing when I select a video. If there is a video playing and select a different hyperlink, that is when the problem happens. Is that clear? The problem is how to stop or dispose of the playing video so the new selection is launched successfully. Regards, Robert

From: Chris Langston @.> Sent: Thursday, June 20, 2024 4:38 AM To: Blazored/Video @.> Cc: Robert Clancy @.>; Author @.> Subject: Re: [Blazored/Video] how do I abort a video while it is playing (Issue #28)

I'm not sure your specific use case, but I'll share how I'm doing this.

I have a playlist of videos that the user can see in a panel on the right side of the webpage. When a video is playing and it reached the end, it will automatically queue up the next video and begin to auto play. Or if the user clicks a new link in the playlist, I will adjust bound properties.

I adjust the correct properties bound to the BlazoredVideo component and then make the following calls: await MyBlazorVideo.ReloadControl(); await MyBlazorVideo.StartPlayback();

    <BlazoredVideo @ref="MyBlazorVideo"

                   TimeUpdateEvent="OnEvent"

                   Play="OnPlay"

                   Ended="OnEnded"

                   VideoEventOptions="options"

                   class="w-100"

                   autofocus="true"

                   controls="controls">

        <source ***@***.***" type="video/mp4" />

    </BlazoredVideo>

— Reply to this email directly, view it on GitHubhttps://github.com/Blazored/Video/issues/28#issuecomment-2179297516, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AACFTLK7DWIKZWJFUHWT353ZIHFXXAVCNFSM6AAAAABJSRHUR6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZZGI4TONJRGY. You are receiving this because you authored the thread.Message ID: @.**@.>>

chrislangston commented 1 month ago

Makes sense.

Do you have a repo you can share and I’ll take a look?

Get Outlook for iOShttps://aka.ms/o0ukef


From: rclancy @.> Sent: Wednesday, June 19, 2024 6:26:28 PM To: Blazored/Video @.> Cc: Chris Langston @.>; Comment @.> Subject: Re: [Blazored/Video] how do I abort a video while it is playing (Issue #28)

Hi Chris, I have a list hyperlinks of video titles in a Blazor page. When I click on any one, it plays the video. This works fine if no video is playing when I select a video. If there is a video playing and select a different hyperlink, that is when the problem happens. Is that clear? The problem is how to stop or dispose of the playing video so the new selection is launched successfully. Regards, Robert

From: Chris Langston @.> Sent: Thursday, June 20, 2024 4:38 AM To: Blazored/Video @.> Cc: Robert Clancy @.>; Author @.> Subject: Re: [Blazored/Video] how do I abort a video while it is playing (Issue #28)

I'm not sure your specific use case, but I'll share how I'm doing this.

I have a playlist of videos that the user can see in a panel on the right side of the webpage. When a video is playing and it reached the end, it will automatically queue up the next video and begin to auto play. Or if the user clicks a new link in the playlist, I will adjust bound properties.

I adjust the correct properties bound to the BlazoredVideo component and then make the following calls: await MyBlazorVideo.ReloadControl(); await MyBlazorVideo.StartPlayback();

<BlazoredVideo @ref="MyBlazorVideo"

TimeUpdateEvent="OnEvent"

Play="OnPlay"

Ended="OnEnded"

VideoEventOptions="options"

class="w-100"

autofocus="true"

controls="controls">

<source @.***" type="video/mp4" />

— Reply to this email directly, view it on GitHubhttps://github.com/Blazored/Video/issues/28#issuecomment-2179297516, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AACFTLK7DWIKZWJFUHWT353ZIHFXXAVCNFSM6AAAAABJSRHUR6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZZGI4TONJRGY. You are receiving this because you authored the thread.Message ID: @.**@.>>

— Reply to this email directly, view it on GitHubhttps://github.com/Blazored/Video/issues/28#issuecomment-2179524070, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AD3ON4IRMJBCMYRBAESMKTLZIIARJAVCNFSM6AAAAABJSRHUR6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZZGUZDIMBXGA. You are receiving this because you commented.Message ID: @.***>

rclancy commented 1 month ago

No I don't sorry. Is it not clear?

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Chris Langston @.> Sent: Thursday, June 20, 2024 10:21:25 AM To: Blazored/Video @.> Cc: Robert Clancy @.>; Author @.> Subject: Re: [Blazored/Video] how do I abort a video while it is playing (Issue #28)

Makes sense.

Do you have a repo you can share and I’ll take a look?

Get Outlook for iOShttps://aka.ms/o0ukef


From: rclancy @.> Sent: Wednesday, June 19, 2024 6:26:28 PM To: Blazored/Video @.> Cc: Chris Langston @.>; Comment @.> Subject: Re: [Blazored/Video] how do I abort a video while it is playing (Issue #28)

Hi Chris, I have a list hyperlinks of video titles in a Blazor page. When I click on any one, it plays the video. This works fine if no video is playing when I select a video. If there is a video playing and select a different hyperlink, that is when the problem happens. Is that clear? The problem is how to stop or dispose of the playing video so the new selection is launched successfully. Regards, Robert

From: Chris Langston @.> Sent: Thursday, June 20, 2024 4:38 AM To: Blazored/Video @.> Cc: Robert Clancy @.>; Author @.> Subject: Re: [Blazored/Video] how do I abort a video while it is playing (Issue #28)

I'm not sure your specific use case, but I'll share how I'm doing this.

I have a playlist of videos that the user can see in a panel on the right side of the webpage. When a video is playing and it reached the end, it will automatically queue up the next video and begin to auto play. Or if the user clicks a new link in the playlist, I will adjust bound properties.

I adjust the correct properties bound to the BlazoredVideo component and then make the following calls: await MyBlazorVideo.ReloadControl(); await MyBlazorVideo.StartPlayback();

<BlazoredVideo @ref="MyBlazorVideo"

TimeUpdateEvent="OnEvent"

Play="OnPlay"

Ended="OnEnded"

VideoEventOptions="options"

class="w-100"

autofocus="true"

controls="controls">

<source @.***" type="video/mp4" />

— Reply to this email directly, view it on GitHubhttps://github.com/Blazored/Video/issues/28#issuecomment-2179297516, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AACFTLK7DWIKZWJFUHWT353ZIHFXXAVCNFSM6AAAAABJSRHUR6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZZGI4TONJRGY. You are receiving this because you authored the thread.Message ID: @.**@.>>

— Reply to this email directly, view it on GitHubhttps://github.com/Blazored/Video/issues/28#issuecomment-2179524070, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AD3ON4IRMJBCMYRBAESMKTLZIIARJAVCNFSM6AAAAABJSRHUR6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZZGUZDIMBXGA. You are receiving this because you commented.Message ID: @.***>

— Reply to this email directly, view it on GitHubhttps://github.com/Blazored/Video/issues/28#issuecomment-2179603852, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AACFTLNKP6HFBFJ6F5665MLZIIOALAVCNFSM6AAAAABJSRHUR6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZZGYYDGOBVGI. You are receiving this because you authored the thread.Message ID: @.***>

chrislangston commented 1 month ago

Hi @rclancy ,

Take a look at the sample repo that I pushed for an example. This is just a clone of the main repo with a few changes to show the example. Note, I'm not doing anything with byte arrays, but rather just changing the value that is bound to "VideoSource"

See the file in "SharedRCL/Pages/Controls/razor". I created a sample button that when the user clicks, it will change the value for @VideoSource and then just call "video.ReloadControl()". If you want it to start playing, you can call video.StartPlayback().

https://github.com/chrislangston/Blazored.Video

rclancy commented 1 month ago

Ok, thanks

From: Chris Langston @.> Sent: Saturday, June 22, 2024 2:33 AM To: Blazored/Video @.> Cc: Robert Clancy @.>; Mention @.> Subject: Re: [Blazored/Video] how do I abort a video while it is playing (Issue #28)

Hi @rclancyhttps://github.com/rclancy ,

Take a look at the sample repo that I pushed for an example. This is just a clone of the main repo with a few changes to show the example. Note, I'm not doing anything with byte arrays, but rather just changing the value that is bound to "VideoSource"

See the file in "SharedRCL/Pages/Controls/razor". I created a sample button that when the user clicks, it will change the value for @VideoSource and then just call "video.ReloadControl()". If you want it to start playing, you can call video.StartPlayback().

https://github.com/chrislangston/Blazored.Video

— Reply to this email directly, view it on GitHubhttps://github.com/Blazored/Video/issues/28#issuecomment-2183073057, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AACFTLMMKB6NQMMXTLDL2GTZIRIULAVCNFSM6AAAAABJSRHUR6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBTGA3TGMBVG4. You are receiving this because you were mentioned.Message ID: @.**@.>>