MediaPlayer + AdaptiveStreamingSource + Smooth Streaming ISM

3 posts, 1 answers
  1. steven lacharite
    steven lacharite avatar
    5 posts
    Member since:
    Dec 2005

    Posted 08 Feb 2010 Link to this post

    Hello,

    I'm having dificulty getting the RadMediaPlayer to play ISM smooth streaming videos. The server is setup correctly and I can play videos with the smooth streaming player from the toolkit. I'm also able to load and play the video by simply loading it and adding it to the layout root.
    Here is my code. I simply attached it to a button.
    string uriString = "http://stevenlacharite.com/demoism/demo1.ism"
     
    MediaElement MyMediaElement = new MediaElement(); 
    Uri MyAdaptiveStreamUrl = new Uri(uriString + "/Manifest"); 
    MyMediaElement.Stretch = Stretch.Uniform; 
    LayoutRoot.Children.Add(MyMediaElement); 
    AdaptiveStreamingSource src = new AdaptiveStreamingSource(); 
    src.ManifestUrl = MyAdaptiveStreamUrl; 
    src.MediaElement = MyMediaElement; 
    src.StartPlayback(); 
    MyMediaElement.Play(); 
     
    What I would like to be able to do is load the films via code behind and set title, descriptions and chapters.
    However whenever I try this the video never loads, the titles descriptions images and chapters all show fine.
    Also when creating a new AdaptiveStream source, I cannot assing the media element to the source because it's looking for a MediaElement and not a RadMediaItem.
    RadMediaItem media = new RadMediaItem(); 
    // set media item stuff. 
    Uri MyAdaptiveStreamUrl = new Uri(uriString + "/Manifest"); 
    AdaptiveStreamingSource MainSrc = new AdaptiveStreamingSource(); 
    MainSrc.ManifestUrl = MyAdaptiveStreamUrl; 
    MainSrc.MediaElement = media; 
    // ^^^ Error above because of type difference. 
    So I guess my question is how do I get all this to work together.

    Thanks,

    Steven
  2. Answer
    Miro Miroslavov
    Admin
    Miro Miroslavov avatar
    588 posts

    Posted 09 Feb 2010 Link to this post

    Hi Steven,

    I've attached an example project with RadMediaPlayer, playing Smooth Streaming Videos. We are currently working on new version of the player with native Smooth Streaming support.

    Kind regards,
    Miro Miroslavov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  3. DevCraft banner
  4. steven lacharite
    steven lacharite avatar
    5 posts
    Member since:
    Dec 2005

    Posted 09 Feb 2010 Link to this post

    Thanks for the reply!

    Here is your code adapted to work 100% from code behind. For those of you that generate the data from a db or xml, this should help.

    RadMediaPlayer mediaPlayer = new RadMediaPlayer(); 
     
            public MainPage() 
            { 
                InitializeComponent(); 
                this.Loaded += new RoutedEventHandler(MainPage_Loaded); 
                EventManager.RegisterClassHandler(typeof(MainPage), RadMediaItem.CurrentItemChangedEvent, new RoutedEventHandler(OnCurrentItemChangedEventHandler), true); 
                mediaPlayer.CurrentItem = null
            } 
     
            private void MainPage_Loaded(object sender, RoutedEventArgs e) 
            { 
                this.Dispatcher.BeginInvoke(() => 
                { 
                    this.LoadMedia(); 
                }); 
            } 
     
            private void LoadMedia() 
            { 
                this.mediaPlayer.Items.Clear(); 
     
                RadMediaItem mediaItem = new RadMediaItem(); 
     
                mediaItem.ImageSource = new BitmapImage(new Uri("", UriKind.RelativeOrAbsolute)); 
                mediaItem.Tag = "http://video3.smoothhd.com.edgesuite.net/ondemand/Big%20Buck%20Bunny%20Adaptive.ism/Manifest"; mediaItem.Title = "Test Title"
                mediaItem.Description = "Test Description"
     
                RadMediaChapter chapter = new RadMediaChapter(); 
                chapter.Position = "00:00:05"
                chapter.Title = "Start"
                mediaItem.Items.Add(chapter); 
     
                chapter = new RadMediaChapter(); 
                chapter.Position = "00:00:45"
                chapter.Title = "Point 1"
                mediaItem.Items.Add(chapter); 
     
                chapter = new RadMediaChapter(); 
                chapter.Position = "00:1:30"
                chapter.Title = "Point 2"
                mediaItem.Items.Add(chapter); 
     
                chapter = new RadMediaChapter(); 
                chapter.Position = "00:2:00"
                chapter.Title = "End"
                mediaItem.Items.Add(chapter); 
     
                AddMediaItem(ref mediaPlayer, mediaItem); 
     
                LayoutRoot.Children.Add(mediaPlayer); 
            } 
     
            private void AddMediaItem(ref RadMediaPlayer mPlayer, RadMediaItem mItem) 
            { 
                if (mPlayer.Items.Contains(mItem) == false
                { 
                    mPlayer.Items.Add(mItem); 
                } 
            } 
     
     
            private static void OnCurrentItemChangedEventHandler(object sender, RoutedEventArgs e) 
            { 
                MainPage t = sender as MainPage; 
     
                AdaptiveStreamingSource source = new AdaptiveStreamingSource 
                { 
                    ManifestUrl = new Uri(t.mediaPlayer.CurrentItem.Tag.ToString(), UriKind.Absolute), 
                    MediaElement = t.mediaPlayer.MediaElement 
                }; 
     
                source.StartPlayback(); 
            } 

    Thanks again,
    Steven
Back to Top