Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > MediaPlayer > Play video stored in database

Not answered Play video stored in database

Feed from this thread
  • RAVINDRA avatar

    Posted on Jun 16, 2011 (permalink)

    Hi

    I am storing the video in database as byte[]. Please let me know how do I use the byte[] to play the video??

    Thanks
    Ravindra

    Reply

  • Tina Stancheva Tina Stancheva admin's avatar

    Posted on Jun 16, 2011 (permalink)

    Hi RAVINDRA,

    The RadMediaPlayer is basically a wrapper around the Silverlight's MediaElement control. Therefore RadMediaPlayer supports the same media formats as SIlverlight's MediaElement does. You can find a full list of the supported media formats here.

    In cases when you want to use a byte stream to set the RadMediaPlayer items, you can set the RadMediaPlayer.MediaElement source:

    //buffer is the byte array
    Stream stream = new MemoryStream(buffer);
      
    mediaPlayer.MediaElement.SetSource(stream);
    Unfortunately there is a known issue when setting the RadMediaPlayer source like this - a null reference exception is thrown. The item is logged in our PITS, where you can track its progress.

    This is why it might be better to keep your videos on the server and keep in the database only the addresses/information of the files. Then you will be able to define the RadMediaPalyer playlist using the address of each video file.



    Best wishes,
    Tina Stancheva
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

    Reply

  • Nina avatar

    Posted on Mar 8, 2012 (permalink)

    Dear Tina,
    I am sorry.
    Is it true? Telerik MEdia Player CANNOT play stream.
    I am using Silverlight MediaPlayer from Windows.Controls to play Back stream from "TExt to Speech".
    And Now try to use Silverilght Telerik MEdiaPLayer.  And I got MediaElement equals NULL.
    Tell me, please ,  Is it no chance to use Telerik for stream not for file?
    THank you advanced.
    Nina

    Reply

  • Tina Stancheva Tina Stancheva admin's avatar

    Posted on Mar 13, 2012 (permalink)

    Hi Nina,

    The RadMediaPlayer.MediaElement property is of type MediaElement and you should be able to use it as the MS MediaElement, which you've previously used. But in order to access the MediaElement you'll need to make sure that the RadMediaPlayer is fully initialized. For that purpose you can handle the MediaPlayer.Loaded event and get the MeidaElement in a Dispatcher like this:
    private void myMediaPlayer_Loaded(object sender, RoutedEventArgs e)
    {
        Dispatcher.BeginInvoke(() =>
        {
            var mediaElement = (sender as RadMediaPlayer).MediaElement;
            if (mediaElement != null)
            {
            }
        });
    }

    Unfortunately the RadMediaPlayer issue with opening files from the client machine is still not fixed and this may cause issues while implementing your scenario.

    All the best,
    Tina Stancheva
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>

    Reply

  • Nina avatar

    Posted on Mar 13, 2012 (permalink)

    THanks Tina it works.
    NIna

    Reply

  • Barry avatar

    Posted on Mar 18, 2012 (permalink)

    Hi Tina,

    I am also trying to play a media item from a byte[] stored in a database. I see that there is a known bug for some time around the mediaitem being null. I have tried to use your suggested work around but I find even on the loaded event for the radmediaplayer the mediaitem is still null.

    My xaml declaration is:

            <telerik1:RadMediaPlayer Canvas.Left="38" Canvas.Top="37" Height="79" Name="radMediaPlayer1" Width="287"
                                     IsPlaylistVisible="False" FullScreenChanged="mediaPlayer_FullScreenChanged"
                                     AutoPlay="False" CurrentStateChanged="radMediaPlayer1_CurrentStateChanged"
                                     SelectedIndex="0" IsFullScreen="False" Background="Black" Loaded="radMediaPlayer1_Loaded">

    My code behind is:

      private void radMediaPlayer1_Loaded(object sender, RoutedEventArgs e)
            {
                Dispatcher.BeginInvoke(() =>
                {
                    var mediaElement = (sender as RadMediaPlayer).MediaElement;
                    if (mediaElement != null)
                    {
                    }
                });
            }
    I have set break points on this method and can see that the mediaitem for the player is still null even though the Loaded event has fired.

    Are there any other work arounds that I can try.

    regards
    Barry

    Reply

  • Tina Stancheva Tina Stancheva admin's avatar

    Posted on Mar 21, 2012 (permalink)

    Hello Barry,

    We aren't aware of any workarounds. However as I am not sure how you implement your scenario, it might be better to send us a sample project demonstrating your approach. This way we'll be able to look for workarounds in your particular case.

    Regards,
    Tina Stancheva
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > MediaPlayer > Play video stored in database
Related resources for "Play video stored in database"

Silverlight MediaPlayer Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]