This is a migrated thread and some comments may be shown as answers.

How to set source in client side for radmediaplayer

1 Answer 174 Views
MediaPlayer
This is a migrated thread and some comments may be shown as answers.
Yogesh
Top achievements
Rank 1
Yogesh asked on 10 Sep 2020, 10:22 AM

Hi,

How can we set source for video in client side using radmediaplayer..I'm struggling with this problem can someone help me on this issue

Thanks,

Yogesh Kumar

1 Answer, 1 is accepted

Sort by
0
Eric R | Senior Technical Support Engineer
Telerik team
answered on 14 Sep 2020, 09:13 PM

Hi Yogesh,

At this time, there isn't a Client-Side function for setting the source property as noted in the Client-Side Programming documentation.

As a workaround, I tested the sample provided in the Client-Side API: set_source thread and it works as expected. In the sample, the source property is set using the AjaxManager OnAjaxRequest event on the server. See the following code snippet for an example. 

Markup

<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
    <script type="text/javascript">
        //Put your JavaScript code here.
        function OpenMediaModal(MediaPath) {
            var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");
            ajaxManager.ajaxRequest("ChangeMediaSource," + MediaPath);
        }
    </script>
</telerik:RadScriptBlock>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadMediaPlayer1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="RadMediaPlayer1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadMediaPlayer1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<div>
    <telerik:RadMediaPlayer ID="RadMediaPlayer1" runat="server"></telerik:RadMediaPlayer>
    <asp:Button ID="Button1" runat="server" Text="Load Video" OnClientClick="OpenMediaModal('Video/icenium.mp4'); return false;" />
</div>

Code-Behind

protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
    string[] arguments = e.Argument.Split(',');
    if (arguments[0] == "ChangeMediaSource")
    {
        RadMediaPlayer1.Source = arguments[1];
    }
}

Please give this a try and let me know if you need any additional information. Thank you for using the UI for ASP.NET AJAX forums. 

Regards,


Eric R | Senior Technical Support Engineer
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
MediaPlayer
Asked by
Yogesh
Top achievements
Rank 1
Answers by
Eric R | Senior Technical Support Engineer
Telerik team
Share this question
or