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

MediaPlayer Source

4 Answers 158 Views
MediaPlayer
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alexey
Top achievements
Rank 2
Alexey asked on 15 Jan 2010, 07:54 AM
Hi

How to set RadMediaPlayer Source in VIewModel.

Thanks.

4 Answers, 1 is accepted

Sort by
0
Tihomir Petkov
Telerik team
answered on 18 Jan 2010, 03:22 PM
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.

Greetings,
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.
0
Guillermo
Top achievements
Rank 1
answered on 04 Sep 2012, 03:18 PM
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}"/>
                   </Components:CustomRadMediaPlayer>

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()
0
Hristo
Telerik team
answered on 07 Sep 2012, 01:06 PM
Hello,

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?

Regards,
Hristo
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Guillermo
Top achievements
Rank 1
answered on 07 Sep 2012, 01:48 PM
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 .
Tags
MediaPlayer
Asked by
Alexey
Top achievements
Rank 2
Answers by
Tihomir Petkov
Telerik team
Guillermo
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or