Video Events

How can I handle video events in the script

For example, when new chapter started. Or when certain frame reached.

 

 



Answer this question

Video Events

  • ab2304

    It needs to be "scheduled_event", not "ScheduledEvent" in your AddEventListener

     


  • Sunil Dutt

    I will try that.

    What's odd is I just ran the HDValidator and it complains the ScheduledControlList is not an allowed Element for Title! However the spec clearly says it is. I will post this question in a new thread.


  • sajithpt

     Bryan Kilian - MSFT wrote:

    It needs to be "scheduled_event", not "ScheduledEvent" in your AddEventListener



    Ok that was it - THANKS!

    But why Where in the spec does it define the name of the scheduled event parameter

    Table 8.3.1-1 just calls it "Scheduled".


  • malignate

    try

    {

    Player.video.main.capture(filename,VideoMainCaptureCallback);

    }

    is the correct one.

    VideoMainCaptureCallback is the callback function. No need of passing parameters as this function is called internally.

    function VideoMainCaptureCallback(status,uri)
    {
    // you can use status and uri to check whether captured image is stored

    //in respective uri successfully or failed

    if(status == Player.Finished)

    {

    //capture succeeded

    }

    Player.playlist.play();

    }



  • stallion_alpa

    It's in Z.6.2-1, the column labeled "Value" is the one you want.


  • sroughley

    Listen to the chapter event for chapter changes -- if you have the spec, the events are defined in Z.6.2-1

    Example code:

    addEventListener("chapter", handleChapter, false);

    function handleChapter(evt)
    {
    var oldChapter = evt.oldValue;
    // int or NaN if no previous chapter
    var newChapter = evt.newValue;
    // int of new chapter number

    // do something useful...
    }

    For knowing when certain frames are reached, you can either use scheduled events (in the playlist) or you can have cues in the markup bound to the title clock that fire events on a given frame.



  • David Srbecky

    For stopping at certain frames, here is a bit of playlist:

    <ScheduledControlList>
    <Event id="Capture" titleTime="00:01:30:00" />
    </ScheduledControlList>

    and here is some Script to handle it (which pauses, captures the video frame, then resumes):

    application.addEventListener( "scheduled_event", OnScheduledEvent, false )

    function VideoMainCaptureCallback(i,uri)
    {
    Player.playlist.play();
    }

    function PlayerVideoMainCapture(filename)
    {
    try
    {
    Player.video.main.capture(filename,VideoMainCaptureCallback);
    }
    catch (ex)
    {
    }
    }


    function OnScheduledEvent(evt)
    {
    if (evt.id == 'Capture')
    {
    Player.playlist.pause();
    PlayerVideoMainCapture("
    file:///filecache/test.cvi");
    }
    }



  • moss

    Andy Pennell MSFT wrote:

    For stopping at certain frames, here is a bit of playlist:

    <ScheduledControlList>
    <Event id="Capture" titleTime="00:01:30:00" />
    </ScheduledControlList>

    and here is some Script to handle it (which pauses, captures the video frame, then resumes):

    application.addEventListener( "scheduled_event", OnScheduledEvent, false )

    function VideoMainCaptureCallback(i,uri)
    {
    Player.playlist.play();
    }

    function PlayerVideoMainCapture(filename)
    {
    try
    {
    Player.video.main.capture(filename,VideoMainCaptureCallback);
    }
    catch (ex)
    {
    }
    }


    function OnScheduledEvent(evt)
    {
    if (evt.id == 'Capture')
    {
    Player.playlist.pause();
    PlayerVideoMainCapture("
    file:///filecache/test.cvi");
    }
    }



    I tried a simple version of this and cannot get it to work. No pause at 10 seconds.

    ## js ##

    function OnScheduledEvent(evt) {
    if (evt.id == "ev1") {
    Player.playlist.pause();
    }
    }
    addEventListener("ScheduledEvent", OnScheduledEvent, false);

    ## playlist ##

    <Title titleNumber="3" titleDuration="00:04:18:00" id="greenday" displayName="Green Day" onEnd="robthomas">
    <PrimaryAudioVideoClip titleTimeBegin="00:00:00:00" titleTimeEnd="00:04:17:00"
    src="file:///dvddisc/HVDVD_TS/GreenDay_AmericanIdiot_700.wmv" dataSource="Disc">
    <Video track="1" />
    <Audio track="1" streamNumber="1" />
    </PrimaryAudioVideoClip>
    <ChapterList>
    <Chapter titleTimeBegin="00:00:00:00" />
    </ChapterList>
    <ScheduledControlList>
    <Event id="ev1" titleTime="00:00:10:00" />
    </ScheduledControlList>
    </Title>



  • Xcel

    Awesome! Thanks.

    I must have thumbed over that small section a dozen times this afternoon ;)




  • iSerg

    Can someone verify that the iHDSim recgonizes video events I've got a very simple implementation, it seems to follow the spec, yet it isn't working.


  • Neftali Reyes

    I'm confused.

    try
    {
    Player.video.main.capture(filename,VideoMainCaptureCallback);
    }

    Shouldn't it be:

    try
    {
    Player.video.main.capture(filename, VideoMainCaptureCallback(int status, String uri));
    }

    To match the signature specified in Z.10.19.3

    And also, I don't understand why the interface for that callback. Why pass the uri and status


  • Video Events