Skip to content

Commit 3c72861

Browse files
github-actions[bot]KB BotP1l3T0
authored
Added new kb article mediaplayer-auto-hide-player-wehn-video-ends (#606)
* Added new kb article mediaplayer-auto-hide-player-wehn-video-ends * kb(mediaplayer): update article --------- Co-authored-by: KB Bot <[email protected]> Co-authored-by: P1l3T0 <[email protected]>
1 parent 3a70fc6 commit 3c72861

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
title: Auto Hide Video Player After Video Ends
3+
description: Learn how to automatically play a video on page load and hide the RadMediaPlayer control once the video ends in ASP.NET AJAX applications.
4+
type: how-to
5+
page_title: Auto Hide Video Player After Video Ends
6+
slug: mediaplayer-auto-hide-player-when-video-ends
7+
tags: radmediaplayer, asp.net ajax, video, autoplay, hide, client-side events
8+
res_type: kb
9+
ticketid: 1666814
10+
---
11+
12+
## Environment
13+
14+
<table>
15+
<tbody>
16+
<tr>
17+
<td>Product</td>
18+
<td>RadMediaPlayer for ASP.NET AJAX</td>
19+
</tr>
20+
<tr>
21+
<td>Version</td>
22+
<td>All</td>
23+
</tr>
24+
</tbody>
25+
</table>
26+
27+
## Description
28+
29+
I want to auto-play an MP4 video with sound on page load and make the video player disappear after the video has finished playing. The goal is to play a short welcome video by the owner that automatically hides itself upon completion.
30+
31+
This KB article also answers the following questions:
32+
33+
- How can I make RadMediaPlayer auto-play a video?
34+
- Is it possible to hide RadMediaPlayer after the video ends?
35+
- Can RadMediaPlayer start playing a video automatically and then hide itself?
36+
37+
## Solution
38+
39+
To achieve the desired behavior of auto-playing a video and hiding the [RadMediaPlayer](https://docs.telerik.com/devtools/aspnet-ajax/controls/mediaplayer/overview) after it ends, use the `OnClientEnded` [client-side event](https://docs.telerik.com/devtools/aspnet-ajax/controls/mediaplayer/client-side-programming/overview#client-side-events). In the event handler, you can set the visibility of the RadMediaPlayer to `false`.
40+
41+
Add the RadMediaPlayer control to your ASP.NET AJAX page.
42+
43+
````ASP.NET
44+
<telerik:RadMediaPlayer RenderMode="Lightweight" ID="RadMediaPlayer1" runat="server" Width="640px" Height="360px"
45+
Source="https://www.example.com/path/to/your/video.mp4" OnClientEnded="onClientEnded" />
46+
````
47+
48+
Define the `onClientEnded` JavaScript function. This function will be triggered when the video playback ends, hiding the RadMediaPlayer control.
49+
50+
````JavaScript
51+
function onClientEnded(sender, args) {
52+
sender.set_visible(false);
53+
}
54+
````
55+
56+
By following these steps, the RadMediaPlayer will automatically begin playing the video when the page loads and will hide itself after the video concludes, achieving the effect of a welcoming video that disappears post-playback.
57+
58+
## See Also
59+
60+
- [RadMediaPlayer Overview](https://docs.telerik.com/devtools/aspnet-ajax/controls/mediaplayer/overview)
61+
- [MediaPlayer Client-Side Programming](https://docs.telerik.com/devtools/aspnet-ajax/controls/mediaplayer/client-side-programming/overview)
62+
- [MediaPlayer Client-Side Events](https://docs.telerik.com/devtools/aspnet-ajax/controls/mediaplayer/client-side-programming/overview#client-side-events)

0 commit comments

Comments
 (0)