A Dullard's Guide

Information on development, Silverlight, HD DVD, HDi, and whatever else Amy feels is missing from the interblags.

Saving Resume Information

Saving Resume Information

  • Comments 1

If you've purchased a DVD player in the last few years or used a software player, likely you've experienced a built in player feature that remembers where you last left off in the movie and allows you to resume play from that point.  That functionality is player dependent - and usually the memory is discarded when you eject the disc. Because HD DVD has persistent storage, you can add this resume playback feature to your disc so that the user experience will be consistent from player to player - even if the user ejects the disc before resuming playback at another time.

To determine when the user has stopped playback on the disc, you should listen for the application_end event.  Once this event fires, you have approximately 2 seconds to capture the necessary information and save it before the player shuts down.  This is plenty of time to capture the elapsed time of the current title and set a key in the content's info.txt file.

The code to do this is simple and straight forward:

function handleApplicationEnd(evt)
{
    var pstoreDevices = PersistentStorageManager.getPersistentStorageDevices(PersistentStorageManager.STORAGE_REQUIRED);
    var psd = pstoreDevices[0];
    psd.setContentInformation(PersistentStorageManager.contentId, "resume", Player.playlist.currentTitle.elapsedTime, function(result, key){});
}
addEventListener("application_end", handleApplicationEnd, false);


Then, next time your discs plays, call getContentInformation on that key you just set to obtain your restart point. 

In the attached project, the resume application runs as a title app.  When leaving a title (either by jumping or stopping the player), the application_end event will fire and a key related to the title id will be saved with the title's resume information.  On return to the title, if valid resume information is saved, the user will be asked if they wish to resume from the point they left off.  If the resume time is greater than or equal to the title duration, the user will not be prompted and the title will start from the beginning.

Note that the simulator does not fire the application_end event when you shut it down.  So, if you want to test this on the simulator, while the title with the application is playing, press CTRL+F to jump to the next title in the playlist which will trigger application_end.

 

Attachment: ResumePlay.zip
  • In a previous post , I stated that when you press the stop button on your player, you have 2 seconds

Page 1 of 1 (1 items)