User Events

2 posts, 0 answers
  1. M L
    M L avatar
    16 posts
    Member since:
    May 2010

    Posted 09 Oct 2013 Link to this post

    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?
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 09 Oct 2013 Link to this post

    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 >>
  3. DevCraft banner
Back to Top