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

MediaPlayer + AdaptiveStreamingSource + Smooth Streaming ISM

2 Answers 196 Views
MediaPlayer
This is a migrated thread and some comments may be shown as answers.
steven lacharite
Top achievements
Rank 1
steven lacharite asked on 08 Feb 2010, 05:31 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Miro Miroslavov
Telerik team
answered on 09 Feb 2010, 02:36 PM
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.
0
steven lacharite
Top achievements
Rank 1
answered on 09 Feb 2010, 04:04 PM
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
Tags
MediaPlayer
Asked by
steven lacharite
Top achievements
Rank 1
Answers by
Miro Miroslavov
Telerik team
steven lacharite
Top achievements
Rank 1
Share this question
or