Tutorial: Work with Personal Video Recorder manager

Work with Personal Video Recorder manager

PVR preparations:

// parallel recording max amount
pvrManager.SetMaxRecordingCnt(max);

Event model initialization:

window.stbEvent = {
    onEvent: function ( event, info ) {
        switch ( Number(event) ) {
            case 39:
                console.log('Task started recording. Info data:', info);
                // {"id":0}
                break;
            case 34:
                console.log('Task has been finished successfully. Info data:', info);
                // {"id":0}
                break;
            case 35:
                console.log('Task has been finished with error. Info data:', info);
                // {"id":0}
                break;
        }
    }
};

Create new recording task:

pvrManager.CreateTask(uri1, pathToSave, startTime1, endTime1);

Create another recording task with operation status check:

if ( pvrManager.CreateTask(uri2, pathToSave2, startTime2, endTime2) < 0 ) {
    console.log('Was not able to create a task!');
}

Get all records general information and save task ids:

var tasks   = JSON.parse(pvrManager.GetAllTasks()),
    task1Id = tasks[0].id,
    task2Id = tasks[1].id;

Get task information by id:

console.log('task information by id:', pvrManager.GetTaskByID(task1Id));

Get task list by identifier list:

console.log('task list by identifier list:', pvrManager.GetTasksByIDs(JSON.stringify([task1Id, task2Id])));

Remove recording task by id:

// do not remove any files
pvrManager.RemoveTask(task2Id, 0);

// if temporary file exists, rename it into resulting file
pvrManager.RemoveTask(task2Id, 1);

// remove only temporary file, if it exists
pvrManager.RemoveTask(task2Id, 2);

// remove both temporary and resulting files
pvrManager.RemoveTask(task2Id, 3);

Change recording end time:

pvrManager.ChangeEndTime(task1Id, endTime3);