Tutorial: Work with player

Work with player

Use the first available player:

var player = stbPlayerManager.list[0];

Playback preparations:

gSTB.SetTopWin(0);
player.aspectConversion = 4;
player.videoWindowMode = 0;
player.setViewport({x: 0, y: 500, width: 800, height: 600});

Event model alternative approach:

player.onTracksInfo = function () {
    console.log('Information on audio and video tracks of the media content is received.');
};

player.onPlayStart = function () {
    console.log('Video playback has begun.');
};

Play video with auto solution:

player.play({
    uri: 'http://www.mediacollege.com/downloads/video/timecode/tc_25fps_20mins.m2v',
    solution: 'auto'
});

Player manipulations on user input:

window.addEventListener('keydown', function ( event ) {
    switch ( event.keyCode ) {
        case 107:
            console.log('keydown: volume up');
            player.volume++;
            break;
        case 109:
            console.log('keydown: volume down');
            player.volume--;
            break;
        case 83:
            if ( event.altKey ) {
                console.log('keydown: stop');
                player.stop();
            }
            break;
    }
});