top

SF.SERVICE.AUDIOPLAYER

** This class will not be supported in 2015.

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


This class describes functions for audio control with service API. This class defines various functions in addition to the basic functions. The basic functions are play, stop, pause, resume etc.

Add the following line for sf.service.AudioPlayer 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.AudioPlayer class like this :

  ex) var audioPlayer = sf.service.AudioPlayer;


Methods

getControllerArea

Description
This function gets coordinate of controller area.
Parameters
none
Return■Object
  - The controller's area rectangle. 
  - Object containing 'left', 'top', 'width' and 'height'.
Emulator SupportN
SDK ConstraintNone
Example
var rect = sf.service.AudioPlayer.getControllerArea();

getCurrentTime

Description
This function gets current playing time.
Parameters
none
Return■Number
  - Current playing time
Emulator SupportN
SDK ConstraintNone
Example
var a = sf.service.AudioPlayer.getCurrentTime();

getDuration

Description
This function gets total playing time.
Parameters
none
Return■String
  - Duration of the audio in milliseconds.
Emulator SupportN
SDK ConstraintNone
Example
var duration = sf.service.AudioPlayer.getDuration();

getPlayingItem

Description
This function gets audio item information of current playing item.
Parameters
none
Return■String
  - current audio item
Emulator SupportN
SDK ConstraintNone
Example
var item = sf.service.AudioPlayer.getPlayingItem();

getRepeatMode

Description
This function gets current repeat mode.
Parameters
none
Return■String
  - current repeat mode
Emulator SupportN
SDK ConstraintNone
Example
document.getElementById('AudioPlayerCtrlRepeat').innerHTML = statesymbols[sf.service.AudioPlayer.getRepeatMode()];

getShuffleMode

Description
This function gets current shuffle mode.
Parameters
none
Return■String
  - current shuffle mode
Emulator SupportN
SDK ConstraintNone
Example
var a = sf.service.AudioPlayer.getShuffleMode();

getState

Description
This function gets current audioplayer state.(play/stop/pause/and so on..)
Parameters
none
Return■String
  - current audioplayer state
Emulator SupportN
SDK ConstraintNone
Example
var state = sf.service.AudioPlayer.getState();

getZIndex

Description
This function gets Zindex of Controller.
Parameters
none
Return■Number
  - The controller's zindex.
Emulator SupportN
SDK ConstraintNone
Example
var zindex = sf.service.AudioPlayer.getZIndex();

hideController

Description
This function hides controller.
Parameters
none
Return■Boolean
  - true : Success
  - false : Fail
Emulator SupportN
SDK ConstraintNone
Example
sf.service.AudioPlayer.hideController();

init

Description
This function initializes audio player.
Parameters
none
Return.
Emulator SupportN
SDK ConstraintNone
Example
sf.service.AudioPlayer.init();

jumpTo

Description
This function moves current playing location to requested location.
Parameters
■requestedLocation
  - Number
  - requested location to jump
Return■Number
  - Time to jump in milliseconds.
Emulator SupportN
SDK ConstraintNone
Example
sf.service.AudioPlayer.jumpTo(sf.service.AudioPlayer.getCurrentTime()-5000);

next

Description
This function moves current item to next item.
Parameters
none
Return■Boolean
  - true : Success 
  - false : there's no next item in playlist, this function returns false regarding the repeat mode.
Emulator SupportN
SDK ConstraintNone
Example
sf.service.AudioPlayer.next();

pause

Description
This function pauses the item.
Parameters
none
Return■Boolean
  - true : Success
  - false : Fail
Emulator SupportN
SDK ConstraintNone
Example
sf.service.AudioPlayer.pause();

play

Description
This function plays the item.
Parameters
■item
  - Number or Object:PlayItem 
  - Index of playlist(0-based) or item object to play. (See "Class PlayItem" for more details about item.)
Return■Boolean
  - true : Success
  - false : Fail
Emulator SupportN
SDK ConstraintNone
Example
sf.service.AudioPlayer.play();

prev

Description
This function moves current item to previous item.
Parameters
none
Return■Boolean
  - true : Success
  - false : there's no previous item in playlist, this function returns false regarding the repeat mode.
Emulator SupportN
SDK ConstraintNone
Example
sf.service.AudioPlayer.prev();

resume

Description
This function resumes the item.
Parameters
none
Return■Boolean
  - true : Success
  - false : Fail
Emulator SupportN
SDK ConstraintNone
Example
sf.service.AudioPlayer.resume();

setControllerArea

Description
This function sets coordinate of controller area.
Parameters
■rect
  - Object
  - Rectangle area of controller containing below properties.
   * left - (Number) Left position with pixel.
   * top - (Number) Top position with pixel.
   * width - (Number) Width with pixel.
   * height - (Number) Height with pixel.
Return■Boolean
  - true : Success
  - false : Fail
Emulator SupportN
SDK ConstraintNone
Example
sf.service.AudioPlayer.setControllerArea(ctrlarea);

setPlayList

Description
This function sets audio lists for playing.
Parameters
■aPlayList
  - Object array
  - Array for object of play list
Return■Boolean
  - true : Success
  - false : Fail
Emulator SupportN
SDK ConstraintNone
Example
sf.service.AudioPlayer.setPlayList(aPlayList);

setRepeatMode

Description
This function sets repeat mode.
Parameters
■repeatMode
  - Repeat mode
  - state can be one of:
   * sf.service.AudioPlayer.REPEAT_NO
   * sf.service.AudioPlayer.REPEAT_ALL
   * sf.service.AudioPlayer.REPEAT_CURRENT
Return■Boolean
  - true : Success
  - false : Fail
Emulator SupportN
SDK ConstraintNone
Example
sf.service.AudioPlayer.setRepeatMode(this.repeatModes[this.iRepeatMode]);

setShuffleMode

Description
This function sets shuffle mode.
Parameters
■shuffleMode
  - Shuffle mode
  -  state can be one of:
   * sf.service.AudioPlayer.SHUFFLE_DISABLE
   * sf.service.AudioPlayer.SHUFFLE_ENABLE
Return■Boolean
  - true : Success
  - false : Fail
Emulator SupportN
SDK ConstraintNone
Example
sf.service.AudioPlayer.setShuffleMode(this.shuffleModes[this.iShuffleMode]);

setZIndex

Description
This function sets Zindex of controller.
Parameters
■zindex
  - Number
  - zindex to be set
Return■Void
Emulator SupportN
SDK ConstraintNone
Example
sf.service.AudioPlayer.setZIndex(100);

showController

Description
This function shows controller.
Parameters
none
Return■Boolean
  - true : Success
  - false : Fail
Emulator SupportN
SDK ConstraintNone
Example
sf.service.AudioPlayer.showController();

stop

Description
This function stops playing current item.
Parameters
none
Return■Boolean
  - true : Success
  - false : Fail
Emulator SupportN
SDK ConstraintNone
Example
sf.service.AudioPlayer.stop();