top

SF.SERVICE.VIDEOPLAYER

** This class will not be supported in 2015.

   All functionalities of sf.service.VideoPlayer class are more improved, integrating with CAPH. Therefore sf.service.VideoPlayer class is not supported since 2015 Smart TV. To use functions of sf.service.VideoPlayer class, refer to here.


This class describes functions for video control with service API and defines various functions that play, stop, pause, resume of video and so on.

Add the following line for sf.service.VideoPlayer class into a html file your own :

  script type="text/javascript" src="$MANAGER_WIDGET/Common/af/2.0.0/loader.js">/script>

You can declare sf.service.VideoPlayer class like this :

  ex) var videoPlayer = sf.service.VideoPlayer;


Methods

focus

Description
This function sets the focus to the VideoPlayer. This API works only in full-screen mode.
Parameters
none
Return■Void
Emulator SupportN
SDK ConstraintNone
Example
sf.service.VideoPlayer.focus();

getZIndex

Description
This function returns z-index of VideoPlayer.
Parameters
none
Return■Number
  - the z-index of the VideoPlayer.
Emulator SupportN
SDK ConstraintNone
Example
var zIndex = sf.service.VideoPlayer.getZIndex();

hide

Description
This function hides the VideoPlayer.
Parameters
none
Return■Void
Emulator SupportN
SDK ConstraintNone
Example
sf.service.VideoPlayer.hide();

init

Description
This function initialize the VideoPlayer with given option.
Parameters
■option (Optional)
  - Object
  - Contains event handler 
   {
         onstatechange: function(state) {...}, // called when VideoPlayer state changes
         onend: function() {...},              // called when video play ends
         onerror: function(error) {...}        // called when error occurs
   }
 
   * state can be one of:
     - sf.service.VideoPlayer.STATE_PLAYING
     - sf.service.VideoPlayer.STATE_STOPPED
     - sf.service.VideoPlayer.STATE_PAUSED
     - sf.service.VideoPlayer.STATE_BUFFERING
     - sf.service.VideoPlayer.STATE_SCANNIG
Return■Void
Emulator SupportN
SDK ConstraintNone
Example
sf.service.VideoPlayer.init({
    onstatechange: function (state) {
        alert('Current State : ' + state);
    },
    onend: function(){
        alert('Video ended.');
    },
    onerror: function (error) {
        alert('Error : ' + error);
    }
});

pause

Description
This function pauses the video.
Parameters
none
Return■Boolean
  - true : Succeeded
  - false : fail
Emulator SupportN
SDK ConstraintNone
Example
sf.service.VideoPlayer.pause();

play

Description
This function plays the video with the specified given option.
Parameters
■option
  - Object
  - Contains the video information 
   {
       url: 'http://www.samsung.com/samsung.mkv', Video URL.
       title: 'Samsung movie' ,  Video title.
   }
   This will be shown on full screen information bar.
Return■Void
Emulator SupportN
SDK ConstraintNone
Example
sf.service.VideoPlayer.play(item);

resume

Description
This function resumes the video.
Parameters
none
Return■Boolean
  - true : Succeeded
  - false : fail
Emulator SupportN
SDK ConstraintNone
Example
sf.service.VideoPlayer.resume();

setFullScreen

Description
This function sets or unsets the full-screen mode. In the full-screen mode, VideoPlayer takes key handling from scene. Add key handlers using setKeyHandler().
Parameters
■bOn 
  - Boolean
  - true : set full-screen, false : unset full-screen
Return■Void
Emulator SupportN
SDK ConstraintNone
Example
sf.service.VideoPlayer.setFullScreen(true);
sf.service.VideoPlayer.setFullScreen(false);

setKeyHandler

Description
This function sets the key handler. This function is for full-screen mode only.
Parameters
■key 
  - Number
  - sf.key value 
■handler 
  - Function
  - The key handler function. If the given key is pressed, this function is called.
Return■Void
Emulator SupportN
SDK ConstraintNone
Example
sf.service.VideoPlayer.setKeyHandler(sf.key.RETURN, function () {
       sf.service.VideoPlayer.stop();
   });

setKeyHelp

Description
This function sets key help description to Key Help Bar on full-screen mode.
Parameters
■key 
  - Number
  - sf.key value. 
■desc 
  - String
  - key description.
Return■Void
Emulator SupportN
SDK ConstraintNone
Example
sf.service.VideoPlayer.setKeyHelp(sf.key.TOOLS, 'Tools');

setPosition

Description
This function sets the VideoPlayer position at the specified rect. The VideoPlayer information panel is shown inside the rect. It takes some of the rect base.
Parameters
■rect 
  - Object
  - The position information 
   {
       left: 100,  left-coordinate of VideoPlayer area.
       top: 100,  top-coordinate of VideoPlayer area.
       width: 500, width of VideoPlayer area.
       height: 400, height of VideoPlayer area.
   }
   VideoPlayer takes some of the area base to show information panel (73px for 540p).
Return■Void
Emulator SupportN
SDK ConstraintNone
Example
sf.service.VideoPlayer.setPosition(this.videoPos);

setZIndex

Description
This function sets z-index of VideoPlayer.
Parameters
■zIndex
  - Number
  - z-index
Return■Void
Emulator SupportN
SDK ConstraintNone
Example
sf.service.VideoPlayer.setZIndex();

show

Description
This function shows the VideoPlayer.
Parameters
none
Return■Void
Emulator SupportN
SDK ConstraintNone
Example
sf.service.VideoPlayer.show();

stop

Description
This function stops playing video.
Parameters
none
Return■Void
Emulator SupportN
SDK ConstraintNone
Example
sf.service.VideoPlayer.stop();