RadMediaPlayer in a RadWindow???

9 posts, 1 answers
  1. mark
    mark avatar
    50 posts
    Member since:
    Mar 2009

    Posted 19 May 2009 Link to this post

    I have links in my Silverlight control for Media Files.  When the user clicks a link, I want that link to load into the Media Player and then play it...It kind of works, but the first file the user picks, never loads...then if I close the window, click the link again, it loads this time.  If I look at the items in the media player, the item is there, but if you click on it, it doesn't play...but again, if I close the window, and click that same link or a diiferent video link, it works the second time...Here is my sample code block....

     

    private void HyperlinkButton_Click(object sender, RoutedEventArgs e)

     

    {

     

    try

     

    {

     

    //radTabControlElementDetails.SelectedIndex = 2;

     

     

     

    RadMediaItem rmItem = new RadMediaItem();

     

     

    string fileName = ((HyperlinkButton)sender).Content.ToString();

     

    rmItem.Source=

    new Uri("http://servername/virtualwebname/media/" + fileName);

     

    _currentMediaSource = rmItem.Source.ToString();    //local variable for use later if necessary.

     

    if (fileName.ToLower().Contains("titlea"))

     

    {

    rmItem.Title =

    "TitleA";

     

    radMediaWindow.Header =

    "Title A";

     

    }

     

    if (fileName.ToLower().Contains("titleb"))

     

    {

    rmItem.Title =

    "TitleB";

     

    radMediaWindow.Header =

    "Title B";

     

    }

     

    if (fileName.ToLower().Contains("titlec"))

     

    {

    radMediaWindow.Header =

    "Title A";

     

    rmItem.Title =

    "Title A";

     

    }

     

    //-----------------------------------------------------------------------
    //Show the Window that the Media Player should live in...
    //-----------------------------------------------------------------------
    radMediaWindow.Show();

    radMediaWindow.Focus();    //try to bring the window up front...doesn't seem to work...

     

    if (radMediaPlayer.Items.Count > 0)

     

    {

            //clear out old items from the playlist...(for now, might change later)...
            radMediaPlayer.Items.Clear();

    }

    //Add the newly selected Item to the Media Player
    radMediaPlayer.Items.Add(rmItem);
    //set the currentitem...autoplay should take care of the rest...

    radMediaPlayer.CurrentItem = radMediaPlayer.Items[0]

    as RadMediaItem;

     

     

    }

     

    catch (Exception ex)

     

    {

     

    MessageBox.Show("Error: " + ex.Message);

     

     

    return;

     

    }

    }

    Thank you.

  2. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 25 May 2009 Link to this post

    Hi Mark,

    Sorry for the delayed reply, we were busy with the SP2 release which will be live soon.

    Sometimes MediaElements (the element that plays the video) behave unexpectedly when they are added/removed from the visual tree or when placed in a Popup. (For example images may not show in a Popup if they have not been preloaded before).

    It seems this may be the case with the Window in this case. To fix this, could you turn off the auto-play and invoke the play() method yourself in a dispatcher (which will give time for all objects to initialize properly).

    It will look something like:

    this.Dispatcher.BeginInvoke( () => myMediaPlayer.Play());

    Hopefully this will work for you,

    Best wishes,
    Miroslav
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft banner
  4. mark
    mark avatar
    50 posts
    Member since:
    Mar 2009

    Posted 27 May 2009 Link to this post

    I tried adding the Dispatcher code like you recommended but it didn't seem to help.  I am currently using the free downloaded code while I am waiting for our purchasing dept. is getting the controls for us.  This is just for a Prototype I am building to showoff to our Business Users...Do you think I will have these problems when I get the latest build of the code?  Should I be displaying the Media Player in a different way(Not using a Rad Window)? 

    Basically, users search for Video Elements, then we provide a Link to the Video File where it resides on a Streaming Server. 

    Also, when I DO get the video to play, I can't seem to "Scrub" the video(fast forward/rewind)...Is this a Media Player setting or maybe something wrong with the way I am streaming the file?  We are using Windows Media Streaming services.

    Thanks
  5. Answer
    Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 29 May 2009 Link to this post

    Hi Mark,

    The Trial version of the player is the same as the "Dev" version. As far as I know there have been no changes to the way MediaPlayer is initialized in the latest assemblies, so unfortunately you may see the same issue again.

    I tried to recreate your scenario (placing the MediaPlayer in a window) and it seems to work. The media item starts playing right away. Possibly there is something I am missing.
    Could you try running the attached project and replacing the media item with one of yours?
    Also, could you get the attached project not to play the item?

    Currently the MediaPlayer does not support fast forward/rewind. The next/prev buttons actually move to the next/previous chapter (if available). You can use the progress bar to navigate in the media item.

    Sincerely yours,
    Miroslav
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. mark
    mark avatar
    50 posts
    Member since:
    Mar 2009

    Posted 29 May 2009 Link to this post

    Thank you VERY much for responding.  I was able to get your project to load and work.  I looked at the dll's that you were referencing in your project and they were NEWER than the dll's I had referenced.  I changed my referenced dll's to point to yours, and my problem went away.

    Thank you very much.
  7. mark
    mark avatar
    50 posts
    Member since:
    Mar 2009

    Posted 29 May 2009 Link to this post

    I am sorry, but I remembered there was another part to this.  "Fast forward/Rewind"...I am trying to use the progress bar to move forward or backwards in the timeline, but when I try to pull it forward, it just snaps back to the place I tried to pull it from.  It doesn't rebuffer and move to the new location?

    Thanks...at least I can get the video to load now on it's initial load.  If I can get the "scrubber" working(progress bar), I think I will be good to go.

    Thanks again.
  8. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 30 May 2009 Link to this post

    Hello Mark,

    In my project I was using the latest trial DLLs, from the SP that was released a few days ago. You can download it from your client account.

    I tried seeking through the video in the example project and I did not see any problems with this. Then I remembered that the video source itself may not support seeking. To check this, you can use the following code (I modified a snippet from the project I sent you)

    private void Button_Click(object sender, RoutedEventArgs e)  
            {  
                RadMediaItem rmItem = new RadMediaItem();  
                rmItem.Source = new Uri("http://msstudios.vo.llnwd.net/o21/mix08/08_WMVs/T19.wmv");  
                radMediaPlayer.Items.Add(rmItem);  
                radMediaPlayer.CurrentItem = rmItem;  
                window.Show();  
     
                radMediaPlayer.MediaOpened += new EventHandler<Telerik.Windows.RadRoutedEventArgs>(radMediaPlayer_MediaOpened);  
            }  
     
            void radMediaPlayer_MediaOpened(object sender, Telerik.Windows.RadRoutedEventArgs e)  
            {  
                var canSeek = radMediaPlayer.MediaElement.CanSeek;  
            }  
        } 

    If the canSeek is false, it means that the stream that is loaded does not support seeking.

    Please let me know if this is the case.

    Greetings,
    Miroslav
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  9. mark
    mark avatar
    50 posts
    Member since:
    Mar 2009

    Posted 01 Jun 2009 Link to this post

    It comes back false...but when I loaded the the media file directly from the webserver instead of through the streaming media server, I was able to seek or scrub the file just fine...I looked in the media server settings to see if there is something I could change there, but I didn't see anything that might apply.

    Thanks

    Mark

  10. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 03 Jun 2009 Link to this post

    Hello Mark,

    I have not used the IIS7 to stream content, but it seems from this thread that there is a property that can be set when creating server-side playlists, "canSeek":

    http://forums.iis.net/t/1153297.aspx

    I am not sure whether this will apply in your case, but hopefully you will be able to use it.

    Please do come back to us if you figure out what the problem is.

    Best wishes,
    Miroslav
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top
DevCraft banner