TimeShift preparations:
// set folder for saving TimeShift buffer data
timeShift.SetTimeShiftFolder(pathToSave);
// set buffer duration in seconds
timeShift.SetMaxDuration(durationSec);
// set mode which defines what happens after reaching the left boundary of TimeShift buffer in paused mode
timeShift.SetSlidingMode(true);
Event model initialization:
window.stbEvent = {
onEvent: function ( event, info ) {
if ( Number(event) === 36 ) {
info = JSON.parse(info);
console.log('TimeShift mode is enabled. TimeShift data:', info);
}
}
};
Work with TimeShift event:
switch ( info.event_code ) {
case 1:
console.log('TimeShift system ready to start and writing buffer after start playing with solution extTimeShift.');
break;
case 2:
console.log('TimeShift was closed.');
break;
case 3:
console.log('Buffer continues writing to right boundary and drop all data from left boundary.');
break;
case 4:
console.log('Buffer is full. Buffer writing was stopped.');
break;
case 5:
console.log('Buffer will be full after 1 minute.');
break;
case 6:
switch ( parseInt(info.event_data, 10) ) {
case 1:
console.log('Folder error. May be folder was unmounted or full.');
break;
case 2:
console.log('Some else error');
break;
}
break;
case 7:
console.log('End playing of TimeShift buffer.');
break;
}
Start playback of an internet stream with one of the following methods:
// legacy
gSTB.Play('extTimeShift ' + uri);
// new recommended approach
stbPlayerManager.list[0].play({uri: uri, solution: 'extTimeShift'});
Enter TimeShift mode:
timeShift.EnterTimeShift();
Different methods to exit from TimeShift mode:
// return to real-time mode without saving:
timeShift.ExitTimeShift();
// return to real-time mode and save current TimeShift buffer via PVR:
timeShift.ExitTimeShiftAndSave(pathToSave2, fileName1);
// return to real-time mode and save TimeShift buffer via PVR with possibility to continue recording:
timeShift.ExitTimeShiftAndSaveDuration(pathToSave3, fileName2, durationSec2);