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

What event to use to get the Position Property

6 Answers 112 Views
MediaPlayer
This is a migrated thread and some comments may be shown as answers.
Juan
Top achievements
Rank 1
Juan asked on 13 Oct 2011, 07:55 PM
Hi,
I am new with telerik controls and I am using RadMediaPlayer. I added a grid with one column where I will display the chapters. I can jump to any position in the Player when I click one of the row of the grid and what I want now is depending on the Position highlight the row in the grid. I tried using the ChapterReached event but didn't do anything. Could you tell me what event should I use to get what I want?

Thanks.

6 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 18 Oct 2011, 01:42 PM
Hello Juan,

I am not sure if i understand your scenario completely but basically when you reach a chapter it gets selected. And the default style of the RadMediaChapter element describes a selection state and you can change it to better fit your requirements.

I attached a sample solution to demonstrate this approach, please have a look at the it and let me know if it works for you.

Kind regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Juan
Top achievements
Rank 1
answered on 26 Oct 2011, 04:06 PM
Hello Tina,
What I need is that when the the chapter is reached, I can have an event that is triggered in order to get the time of the chapter and highlight the row in the grid. As I told you before, I thought of ChapterReached event but this one is not executing.

Regards,

Juan
0
Tina Stancheva
Telerik team
answered on 31 Oct 2011, 05:11 PM
Hi Juan,

Thank you for getting back to us. Can you please elaborate on the issue with the ChapterReached event, because in the sample project I sent you can handle the ChapterReached event and you can get the position from the arguments - (e.OriginalSource as RadMediaItem).Position and then use it to implement your scenario.

Doesn't that work for you and if not can you please modify my solution to better illustrate your scenario. Thank you in advance for your cooperation.

All the best,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Juan
Top achievements
Rank 1
answered on 22 Nov 2011, 08:26 PM
Hi Tina,
Thank you very much for your answer. I could finally get the ChapterReached event but I still don't know how to jump in the Gridview to the selected chapter. Attached you have an image about the design. My goal is that when a chapter is reached then highlight the corresponding one in the Gridview. Can you help me with this one?

 

 

 

private void OnDemand_ChapterReached(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
   TimeSpan tsPosition = (e.OriginalSource as RadMediaItem).Position;
  
   //Code to highlight the row that has the same position as tsPosition
  
}

Let me know if you need more info.

Regards,
Juan

 

0
Tina Stancheva
Telerik team
answered on 25 Nov 2011, 03:35 PM
Hi Juan,

You can get the reached chapter like so:
private void player_ChapterReached(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
    RadMediaItem item = e.OriginalSource as RadMediaItem;
    RadMediaChapter reachedChapter = item.SelectedItem as RadMediaChapter;
}
But a better approach would be to bind the SelectedIndex of the ListBox control that displays the chapters:
<ListBox x:Name="Chapters" SelectedIndex="{Binding ElementName=player, Path=SelectedItem.SelectedIndex, Mode=TwoWay}">
    <ListBoxItem Content="Chapter 1" />
    <ListBoxItem Content="Chapter 2" />
    <ListBoxItem Content="Chapter 3" />
</ListBox>

I attached a sample project to demonstrate this approach - please note how the two way binding works in both directions.

Best wishes,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Juan
Top achievements
Rank 1
answered on 02 Dec 2011, 07:32 PM
Hi Tina,
Thank you very much for your help. That worked great for me.

Regards,

Juan
Tags
MediaPlayer
Asked by
Juan
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Juan
Top achievements
Rank 1
Share this question
or