locked
smooth title loop RRS feed

  • Question

  • hi,
    i have an intial title, with a small video and an advanced application with a couple of configuration options. I want this title to repeat itself until the user chooses an option.

    First of all i've simply set the onEnd attribute in the playlist to the title itself. But this is not smooth at all, when the title ends it reloads everything and the screen stays black for a little while.

    What im trying to do now is that one second before the end of the title, generate an event and jump to the begin of the title using javascript. Something like:

    <timing clock="title">
          <par>
            <cue begin="00:00:05:00" dur="1s">
              <event name="loopEvt"/>
            </cue>
          </par>
        </timing>

    and then:

    addEventListener("loopEvt", loopFunc, false);
    function loopFunc(evt){
        Player.playlist.titles["Title001"].chapters[0].jump("00:00:00:00", false);      
    }

    But my dear toshiba player freezes, so there is something wrong about the cue i am using... what is it? :-).

    And... is this the best option to use? I could use timers too, but i think is better to avoid them, isn't it?.
    Friday, September 28, 2007 2:30 PM

Answers

  • hi RollWhisTier,

    the freeze is caused by the fact that you have the clock for your app set to "title" and likely have other things in your markup that are violating the rules of being slaved to the "title" clock.   I dont remember all the restrictions of the top of my head, but an example is that you cant have any xpath your markup if you set the clock to "title".   So you need to set that back to "page". 

    In my opinion the best and really only option for doing this is with a scheduled event.   In your playlist you need to add something like this:

                <ScheduledControlList>
                    <Event id="looper1" titleTime="00:01:59:00"/>
                </ScheduledControlList>

    so the whole title would look like this:
           <Title titleNumber="1" titleDuration="00:02:00:00" id="Main" onEnd="Main">
                <PrimaryAudioVideoClip src="file:///dvddisc/HVDVD_TS/MENULOOP.MAP" dataSource="Disc" titleTimeBegin="00:00:00:00" titleTimeEnd="00:02:00:00">
                    <Video track="1" mediaAttr="1"/>
                </PrimaryAudioVideoClip>
                <ScheduledControlList>
                    <Event id="looper1" titleTime="00:01:59:00"/>
                </ScheduledControlList>
            </Title>

    in this scenario my onEnd is still set to match my ID, as a backup in case the scheduled event isn't received and acted upon accordingly.   you'll notice that the scheduled event is 1 second less than the title duration so that the event will trigger and the title will jump before it reached the end.   

    Now you need to add some javascript to listen for the scheduled event and act upon it.

    You need to add an eventListener

        addEventListener("scheduled_event",scheduledEventHandler,false);

    and then add the callback function you just noted in the listener:

    function scheduledEventHandler(evt){
        if (evt.id.indexOf("looper") != -1) {
            Player.playlist.titles[Player.playlist.currentTitle.attributes.id].jump("00:00:01:00", false);
        }
    }

    In the playlist I gave the event an ID named "looper1"...  this function checks the string of the ID for the substring of "looper", and if the event contained it, then jump the current title back to the beginning.   This is useful casue you can reuse the same javascript multiple looping titles.   In the playlist, by nature of being XML, IDs are required to be unique, which is why I labeled my event "looper1" and not just "looper"   so later on in the plaulist I might have "looper9" and  "looper22".   (it's my practice to enumerate the looper with the titleNumber value for that title)

    hope that helps.
    Friday, September 28, 2007 4:36 PM
  • Yes, you are allowed to have multiple timing elements in a markup file.  The begin and end values in when using a title clock can not be xpath expressions.  But, you do need to use a select attribute (sorry, I missed that in your earlier post). 

     

    <timing clock="title">
          <par>
            <cue select="id('VALID_DIV_NAME_HERE')" begin="00:00:05:00" dur="1s">
              <event name="loopEvt"/>
            </cue>
          </par>
    </timing>

    Monday, October 1, 2007 5:10 PM

All replies

  • hi RollWhisTier,

    the freeze is caused by the fact that you have the clock for your app set to "title" and likely have other things in your markup that are violating the rules of being slaved to the "title" clock.   I dont remember all the restrictions of the top of my head, but an example is that you cant have any xpath your markup if you set the clock to "title".   So you need to set that back to "page". 

    In my opinion the best and really only option for doing this is with a scheduled event.   In your playlist you need to add something like this:

                <ScheduledControlList>
                    <Event id="looper1" titleTime="00:01:59:00"/>
                </ScheduledControlList>

    so the whole title would look like this:
           <Title titleNumber="1" titleDuration="00:02:00:00" id="Main" onEnd="Main">
                <PrimaryAudioVideoClip src="file:///dvddisc/HVDVD_TS/MENULOOP.MAP" dataSource="Disc" titleTimeBegin="00:00:00:00" titleTimeEnd="00:02:00:00">
                    <Video track="1" mediaAttr="1"/>
                </PrimaryAudioVideoClip>
                <ScheduledControlList>
                    <Event id="looper1" titleTime="00:01:59:00"/>
                </ScheduledControlList>
            </Title>

    in this scenario my onEnd is still set to match my ID, as a backup in case the scheduled event isn't received and acted upon accordingly.   you'll notice that the scheduled event is 1 second less than the title duration so that the event will trigger and the title will jump before it reached the end.   

    Now you need to add some javascript to listen for the scheduled event and act upon it.

    You need to add an eventListener

        addEventListener("scheduled_event",scheduledEventHandler,false);

    and then add the callback function you just noted in the listener:

    function scheduledEventHandler(evt){
        if (evt.id.indexOf("looper") != -1) {
            Player.playlist.titles[Player.playlist.currentTitle.attributes.id].jump("00:00:01:00", false);
        }
    }

    In the playlist I gave the event an ID named "looper1"...  this function checks the string of the ID for the substring of "looper", and if the event contained it, then jump the current title back to the beginning.   This is useful casue you can reuse the same javascript multiple looping titles.   In the playlist, by nature of being XML, IDs are required to be unique, which is why I labeled my event "looper1" and not just "looper"   so later on in the plaulist I might have "looper9" and  "looper22".   (it's my practice to enumerate the looper with the titleNumber value for that title)

    hope that helps.
    Friday, September 28, 2007 4:36 PM

  • An additional comment, just to clarify in case you werent sure what is going on.  

    when an onEnd occurs, that means you have reached the end of a title, and thus the lifespan of the title has elapsed.   by the time this occurs the elapsedTime value has become "null" and thus the application and video are no longer valid to be on screen and running.   this is why you see the screen go black and your whole application restart when trying to loop using the onEnd.  the application was actually released from memory and all the video buffers cleared becuase the title ended, at which time the player looks at the onEnd for what it should do now that it has cleaned itself up and is ready to start something new.  You just happened to have telling to to play the menu loop again, so the all that starts over as if it was the first time. 

    You'll also notice that in the javascript code example I posted, that mu jump actually went to "00:00:01:00", so 1 second in, not the very beginning.   I do this for a similar reason to setting the scheduled event for the loop one second before the end.   That is, if you jump to the "00:00:00:00" the player will actually fire a titleBegin event.  I sometimes have animations or other code that is triggered by that titleBegin, and I want those actions to occur only when I am truely starting at the beginning of that title, not just looping.   so I offset the loop to jump to 1 second in.

    _scott
    Friday, September 28, 2007 4:49 PM

  • One more comment for microsoft specifically.

    I have written emails in the past in the hopes of fixing this issue with the xbox, but haven't ever really seen any traction on it.  this is an xbox specific comment, as the toshiba players as well as winDVD act like I would want them to. 

    during a title jump regardless of whether you have a title application and are jumping within your own title, or have a playlist application and are doing any kind of jump at all...   the xbox will stop writing the application to the screen while the laser is seeking to the new jump point.   So in the looping scenario being discussed on this thread, the application will dissappear for a second and then re-appear.   the app maintains state just fine, as if it had been there all along, it's just visually annoying to see it flicker off and back on at every loop. 

    In my opinion if the app is either a playlist app, or is a title app with it's clock set to anythign but "title", then the application should stay on the screen during the jump as the application is still valid.   Of course I'm not a hardware guy so I have no clue the implications of what I am asking for and there's probably good reason why the xbox does what it does, it's just annoying to see it when you dont see it on the other players.

    anybody from MS have a comment?

    _scott
    Friday, September 28, 2007 5:03 PM
  • The Xbox 'flashing' is a known issue and should be addressed in the future. Sorry I can't give you a date for the fix.

     

    FYI, in the following line:

     

           Player.playlist.titles[Player.playlist.currentTitle.attributes.id].jump("00:00:01:00", false);

     

    You could simplify to just:

     

           Player.playlist.currentTitle.jump("00:00:01:00", false);

     

    Friday, September 28, 2007 5:30 PM
  • RollWhistler,

    Is your application a title app or a playlist app?  Title clocks can only be used in title apps.  For a playlist app, your best bet is to use a scheduled event.  Or, if you prefer to use a markup cue (if you need to have more precise timing or you want the jumpt to occur during a specific timeframe), add a small title application to your title.  The event that it fires can also be caught by the playlist app.

     

    Keep in mind that if you use a scheduled event not to have it fired too close to the end of the title (give yourself about a second of margin) as exact timing of the scheduled event is not guarenteed.

     

    Friday, September 28, 2007 7:57 PM
  • Mmmm, i would say is a title app since it is defined in the playlist as an applicationSegment inside a Title tag... but i need to remind the differences between title and playlist apps... i will take a look :-).

    Thank you all for your answers :-).
    Monday, October 1, 2007 8:31 AM
  •  scott bates wrote:


    the freeze is caused by the fact that you have the clock for your app set to "title" and likely have other things in your markup that are violating the rules of being slaved to the "title" clock.   I dont remember all the restrictions of the top of my head, but an example is that you cant have any xpath your markup if you set the clock to "title".   So you need to set that back to "page". 



    I though that just everything inside the timing tag should follow the rules you mentioned... That i could have two timing tags, one title clock with no xpath on it, and another page clock with the rest of "triggers" without restrictions... isn't it like that?
    Or if i have one single timing tag title clocked... then i cannot have xpath variables in the rest of the markup? even outside the timing tag.


    Monday, October 1, 2007 9:13 AM
  • Yes, you are allowed to have multiple timing elements in a markup file.  The begin and end values in when using a title clock can not be xpath expressions.  But, you do need to use a select attribute (sorry, I missed that in your earlier post). 

     

    <timing clock="title">
          <par>
            <cue select="id('VALID_DIV_NAME_HERE')" begin="00:00:05:00" dur="1s">
              <event name="loopEvt"/>
            </cue>
          </par>
    </timing>

    Monday, October 1, 2007 5:10 PM