MediaPlayer Source

5 posts, 0 answers
  1. Alexey
    Alexey avatar
    79 posts
    Member since:
    Oct 2008

    Posted 15 Jan 2010 Link to this post


    How to set RadMediaPlayer Source in VIewModel.


  2. Tihomir Petkov
    Tihomir Petkov avatar
    576 posts

    Posted 18 Jan 2010 Link to this post

    Hi Alexey,

    There are a number of possible scenarios:

    - bind the ItemsSource property of the MediaPlayer to a property of your ViewModel, e.g. List<RadMediaItem> MediaItems, and add items to that property in your ViewModel. Please note that in order for the binding to work you need to set the DataContext of your page/usercontrol/window to point ot an instance of your ViewModel.

    - same as above, but the property may be a list of strings that represent the sources of the media elements. In this case you will need to set the ItemTemplate property of the MediaPlayer to a DataTemplate that will create a new RadMediaItem for each string in the source and bind its source property to the business object (a string from the list of strings in your ViewModel).

    - if you need a single MediaItem only, you can create that item in XAML and only bind its Source property to a string property of your ViewModel that will hold the path to the actual media file.

    Let me know if the above suggestions work for you.

    Tihomir Petkov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. Guillermo
    Guillermo avatar
    4 posts
    Member since:
    Aug 2012

    Posted 04 Sep 2012 Link to this post

    Hello I'm trying to use the third approach you mention, look at my code
    <Components:CustomRadMediaPlayer Visibility="Visible" x:Name="MainMediaPlayer" Playing="{Binding Path=Playing}"    Cursor="Hand" Height="1"  telerik:StyleManager.Theme="Vista" Width="1" IsPlaying="{Binding Path=IsPlaying, Mode=TwoWay}" >
                           <telerik:RadMediaItem VideoHeight="0" VideoWidth="0" 
                                           Source="{Binding Path=FileLocation,Mode=TwoWay}"/>

    But the media element does not react to changes as they occur n source and remains in the closed state.
    I give play and nothing works, but if I put the address directly and it works.
    Can you help with this?
    Has a clarification of my radmediaplayer, inherited from you and add a property of type bool. Where is set to true will run Play () and when is set to false will run Stop()
  5. Hristo
    Hristo avatar
    352 posts

    Posted 07 Sep 2012 Link to this post


    Is the property you are using to bind the source to implementing a INotifyPropertyChanged notation (i.e. firing the PropertyChanged event)? If not, this could be the reason RadMediaPlayer does not play the movie.
    Also could you please check if the RadMediaItem Source property is set to non null value?

    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Guillermo
    Guillermo avatar
    4 posts
    Member since:
    Aug 2012

    Posted 07 Sep 2012 Link to this post

    Hi Hristo thanks  for you quick answer, yes the property is working fine, and the mediaelement of the RadMediaPlayer.MediaElement Property is not null but it Source Property it is.
    Anyway, i clear all and start from the scratch with the last version Q1 2012 SP1 and now is working, but another issue came to the surface.
    The autoplay = false not working, I had to capture the event MediaOpened and do player.Stop() to avoid the autoplay behavior.
    There is another way ?
    I have another question, how i now where le media item is loading ? i want to use a busyIndicator .
Back to Top
DevCraft banner