What event to use to get the Position Property

7 posts, 0 answers
  1. Juan
    Juan avatar
    6 posts
    Member since:
    Oct 2011

    Posted 13 Oct 2011 Link to this post

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

    Posted 18 Oct 2011 Link to this post

    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 >>

  3. DevCraft banner
  4. Juan
    Juan avatar
    6 posts
    Member since:
    Oct 2011

    Posted 26 Oct 2011 Link to this post

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

    Posted 31 Oct 2011 Link to this post

    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 >>

  6. Juan
    Juan avatar
    6 posts
    Member since:
    Oct 2011

    Posted 22 Nov 2011 Link to this post

    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

     

  7. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 25 Nov 2011 Link to this post

    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 >>

  8. Juan
    Juan avatar
    6 posts
    Member since:
    Oct 2011

    Posted 02 Dec 2011 Link to this post

    Hi Tina,
    Thank you very much for your help. That worked great for me.

    Regards,

    Juan
Back to Top
DevCraft banner