ChapterReached Event

8 posts, 1 answers
  1. Scott Laughton
    Scott Laughton avatar
    12 posts
    Member since:
    May 2006

    Posted 09 Mar 2009 Link to this post

    Hi there,
            I am wanting to update a panel with relevant content at specific points of time as the video is playing.  I thought to do this, I would add some chapters to a MediaItem, and add some logic to the ChapterReached event to detect what chapter had just ended and take the appropriate action.  However I do not want the chapter title to appear on the video, and there seems to be no reliable way to know what chapter raised the event.  I set the chapters Position property to "00:00:10" and then when I check the MediaElementCurrentTime property in the ChapterReached event, sometimes it is "00:00:10" and sometimes it is "00:00:09".  I can't use the ChapterTitle property as that shows on the video and I don't want that.  So what is a reliable way to detect what chapter raised the ChapterReached event?

    BTW:
    Here is my setup:
     - RadControls for Silverlight 2008 3 1217
     - Microsoft Visual Studio 2008 Version 9.0.30729.1 SP
     - Microsoft .NET Framework Version 3.5 SP1
     - Windows XP Pro x64

    Regards,

        Scott.
  2. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 12 Mar 2009 Link to this post

    Hi Scott Laughton,

    You can use the Tag property to detect what chapter threw the event.

    Hope this helps.

    Regards,
    Miroslav Nedyalkov
  3. DevCraft banner
  4. Scott Laughton
    Scott Laughton avatar
    12 posts
    Member since:
    May 2006

    Posted 12 Mar 2009 Link to this post

    Miroslav,
        Thanks for the reply.   I did see that the Chapter element had a Tag property, but could not see how locate the current chapter object from inside the ChapterReached event to see what the value of the Tag property on the current chapter was.  Can you provide a sample of how to do this?

    Regards,

        Scott.
  5. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 13 Mar 2009 Link to this post

    Hi Scott Laughton,

    I investigated the problem and found out that there is no good way to get the current chapter object. We put this in our tasks list for the SP1. There is workaround that is doing the job. You can use the following method to get the current RadMediaChapter object and after that you can use it as you need to:

            public static RadMediaChapter GetCurrentChapter(RadMediaPlayer player) 
            { 
                TimeSpan currentPosition = player.MediaElement.Position; 
                RadMediaItem currentItem = player.CurrentItem; 
                if (currentItem == null
                { 
                    return null
                } 
     
                RadMediaChapter currentChapter = null
     
                foreach (RadMediaChapter chapter in player.ChildrenOfType<RRadMediaChapter()) 
                { 
                    TimeSpan chapterPosition = TimeSpan.Parse(chapter.Position); 
                    if (chapterPosition <= currentPosition) 
                    { 
                        currentChapter = chapter; 
                    } 
                } 
     
                return currentChapter; 
            } 


    Regards,
    Miroslav Nedyalkov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. Scott Laughton
    Scott Laughton avatar
    12 posts
    Member since:
    May 2006

    Posted 16 Mar 2009 Link to this post

    Miroslav,
            Thanks for the reply, however you workaround incures the problem outlined in my original post:

    "I set the chapters Position property to "00:00:10" and then when I check the MediaElementCurrentTime property in the ChapterReached event, sometimes it is "00:00:10" and sometimes it is "00:00:09"."

    How long till SP1 is available?

    Regards,

        Scott.
  7. Answer
    Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 18 Mar 2009 Link to this post

    Hello Scott Laughton,

    Yes, I noticed it is not showing the exact time, but you can easily guess which chapter just begun by using this code. If you don't think it is reliable enough, you can find the nearest position and this will be the chapter that invoked the event. Most probably the SP1 will be released within a month.

    Regards,
    Miroslav Nedyalkov
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. Eralp Pinardag
    Eralp Pinardag avatar
    1 posts
    Member since:
    Jun 2012

    Posted 18 Nov 2009 Link to this post

    I am using 2009/Q3 and still have the same problem defined here. Was this feature ever added? I don't see how to reference the RadMediaChapter reached so I can use the "Tag" property. Please update. Thanks...

    Eralp
  9. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 19 Nov 2009 Link to this post

    Hi Eralp,

    I have posted an answer to you support ticket. Have a look at it and if you have additional question, let me know.

    Best wishes,
    Kiril Stanoev
    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.
Back to Top
DevCraft banner