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

User Events

1 Answer 27 Views
MediaPlayer
This is a migrated thread and some comments may be shown as answers.
M L
Top achievements
Rank 1
M L asked on 09 Oct 2013, 01:07 PM
Hello,
I'm looking for a way to intercept user events from media player.

A similar topic has been posted here http://www.telerik.com/community/forums/silverlight/media-player/radmediaplayer-play-button.aspx
However, the answer givent there doesnt meet my requirements.
I need to know when the user pressed the play, pause and stop buttons, as well as any action performed by the user on media players progress bar (moving to a new location). However, the current state changed event fires up also when the player itself issued the change order, for example when the video enters buffering state. When it finishes buffering im getting a "playing" state, but im not able to differenciate it between this behaviour and user pressing a play button.
I wonder, are there any events I could use for tracking user events?

1 Answer, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 09 Oct 2013, 08:59 PM
Hello Marcin,

All RadMediaPlayer events are described in the Events Overview tutorial. But looking at your requirements I cannot tell for sure whether the available events will help you implement your requirements.

However, if you take a look at the RadMediaPlayer ControlTemplate and specifically at the RadMediaPlayerWrapper element template structure, you can see that there are multiple RadButton elements visualizing the player control panel. This means that you can edit the default RadMediaPlayer ControlTemplate and attach Click event handlers on these buttons. You can also attach different events on the TimeSlider element (which is of type RadSlider) and track any changes in its value.

Moreover, the media option buttons all trigger different MediaCommands which you can access from code-behind. This means that you can attach an event handler for the executed method of the RoutedUICommands that come out-of-the-box with RadMediaPlayer. For instance you can attach an ExecutedHandler to all RoutedUICommands used within the RadMediaPlayer like this:
CommandManager.AddExecutedHandler(radMediaPlayer, new ExecutedRoutedEventHandler(OnCommandExecuted));
...
private void OnCommandExecuted(object sender, ExecutedRoutedEventArgs e)
{
             
}
The ExecutedRoutedEventArgs object will give you access to the RoutedUiCommand that was executed and through its Text property you can track which action was triggered.

The MediaCommands used within the default ControlTemplate of the player are the following:
  • MediaCommands.Play - the command triggered by the PlayButton button
  • MediaCommands.TogglePlayPause - the command triggered by the PlayPauseToggle button
  • MediaCommands.ToggleMuteOnOff - the command triggered by the MuteToggle button
  • MediaCommands.ToggleFullScreen - the command triggered by the FullscreenToggle button
  • MediaCommands.TogglePlaylist - the command triggered by the PlaylistToggle button
I hope this information will help you proceed with your development. However, please don't hesitate to write back if you need any further assistance.

Regards,
Tina Stancheva
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
MediaPlayer
Asked by
M L
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Share this question
or