Need Help Clearing Media Sources

5 posts, 0 answers
  1. Bob
    Bob avatar
    5 posts
    Member since:
    Jul 2011

    Posted 20 Jan 2014 Link to this post

    Greetings all,

    When using the RadMediaPlayer control in my web application, I am having trouble clearing the multimedia sources that have already been loaded into the control.  The user has the option of adding a new link and corresponding description which are saved in a SQL Server table of video records.  This list is loaded into a dropdown box for selection.  When a video is chosen, I am setting the source property as follows, based on the link retrieved from the database:

    MMOMediaPlayer.Source = <link from db>

    This works fine and the video plays as expected.  However, I want to give the user the ability to clear the control of any video content and reset it to its original state when the page first loaded.  I have a button that performs this function, with server-side code as follows:

    MMOMediaPlayer.Sources.Clear()

    However, after this code executes, the most recently viewed video is still present in the viewer, and begins to play from the last position (time) within the clip.  I've also tried using MMOMediaPlayer.Sources.RemoveAt(0), but this also seems to have no effect.

    Any help would be appreciated.


  2. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 22 Jan 2014 Link to this post

    Hi Bob,

    To achieve the desired functionality you need to set the RadMediaPlayer.Source property to empty string and manually to set the toolbar scroll bar’s value to 0. For example:
    RadMediaPlayer1.Source = string.Empty;
    Page.ClientScript.RegisterStartupScript(Page.GetType(), "SetTime",
         string.Format("setTimeout(function(){{ $find('{0}').set_value(0);}}, 100)",
         RadMediaPlayer1.ClientID + "_Toolbar_ProgressRail"), true);

    Additionally I am sending you a simple example which demonstrates that. Please check it out and let me know if it helps you.

    Regards,
    Radoslav
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Bob
    Bob avatar
    5 posts
    Member since:
    Jul 2011

    Posted 22 Jan 2014 Link to this post

    That's what I needed... the problem is fixed!  Thanks for all your help.
  5. Russell
    Russell avatar
    2 posts
    Member since:
    Jun 2013

    Posted 24 Jul 2014 in reply to Radoslav Link to this post

    I tried to run your sample with RadMediaPlayer and when I tried to clear sources the program threw up an error = "Object doesn't support property or method 'SeekTo'.  I'm attaching a png file.   In addition, when I clicked on Full Screen I received an error = "Object doesn't support property or method 'EnterFullScreen'
  6. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 29 Jul 2014 Link to this post

    Hello Russell,

    To avoid the described errors you need to change the code behind as following:
    protected void Button1_Click(object sender, EventArgs e)
        {
            RadMediaPlayer1.Sources.Clear();
            RadMediaPlayer1.Source = string.Empty;
     
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "SetTime",
                string.Format("setTimeout(function(){{ $find('{0}').seekTo(0);}}, 200)",
                RadMediaPlayer1.ClientID), true);
        }

    Please give it try and let me know if it helps you.

    Regards,
    Radoslav
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017