top

Play Video

Published 2014-10-27 | (Compatible with SDK 2.5,3.5,4.5,5.0,5.1 and 2011,2012,2013,2014 models)

Play Video

** This class will not be supported in 2015.

   All functionalities of AppsFramework are more improved, integrating with CAPH. Therefore Appsframework is not supported since 2015 Smart TV.

 

This section demonstrates playing video contents with the VideoPlayer of the Service API.

 

Playing Contents

The contents can be played as full screen, partial screen or both (converting between full and partial). All the key handlings are processed by the VideoPlayer component of the Service API. Videos can be played by passing the URL.

The following code plays the content in partial screen.

// Sets partial play position.
sf.service.VideoPlayer.setPosition({
    left: 100,
    top: 100,
    width: 500,
    height: 400
});
// The bottom of the area is occupied by the Controller UI. Its height for 540p is 73pixel. So the controller's height should be added to "height" value.

// Starts playback
sf.service.VideoPlayer.play({
    url: 'http://mydomain.com/TestContent.mp4',
    fullScreen: false    // Sets Player to partial mode
});

The following code plays content in full screen.

// Sets Player as fullscreen mode
sf.service.VideoPlayer.setFullScreen(true);

// Set key handler for RETURN key explicitly to return to the previous view.
sf.service.VideoPlayer.setKeyHandler(sf.key.RETURN, function () {
    // If user press RETURN key during the Fullscreen view, stops the playback.
    // If the setPosition is not defined, this closes the Fullscreen view and returns to previous view.
    sf.service.VideoPlayer.stop();
});

// starts playback
sf.service.VideoPlayer.play({
    url: 'http://mydomain.com/TestContent.mp4',
    fullScreen: true
});

The sample code for playing video content as fullscreen is in SamsungTVAF2_VideoPlayer_FullScreen.zip.

Converting between Full Screen and Partial Screen

Convert between full and partial screen by calling the setFullScreen method.

/*** during the playback as partial screen ***/

sf.service.VideoPlayer.setKeyHandler(sf.key.RETURN, function () {
    // If user press RETURN key during the Fullscreen view, convert to partial screen.
    sf.service.VideoPlayer.setFullScreen(false);
});
sf.service.VideoPlayer.setFullScreen(true); // convert to fullscreen

The sample code for playing video content is in SamsungTVAF2_VideoPlayer_Partial.zip.