Samsung Electronics logo

Samsung Web API: AVPlayer


Introduction

This API allows developers to stream audio or video and control the AV player.

It provides MRCP (Media Renderer Control Point) features for control of the audio or video files playing on a remote Digital Living Network Alliances (DLNA) device that supports Digital Media Renderer (DMR), which is described in the DLNA specification.


Table of Contents


Summary of Interfaces and Methods

Interface Method
AVPlayerSuccessCallback void onsuccess(DeviceId playerId)
AVPlayerPlayPositionSuccessCallback void onsuccess(unsigned long position, DeviceId playerId)
AVPlayerVolumeSuccessCallback void onsuccess(unsigned short level, DeviceId playerId)
AVPlayerMuteSuccessCallback void onsuccess(boolean mute, DeviceId playerId)
AVPlayerErrorCallback void onerror(WebAPIError error, DeviceId playerId)
AVPlayerStateChangedCallback void onstatechange(AVPlayerState state, DeviceId playerId)
AVPlayerStateCallback void onsuccess(AVPlayerState state, DeviceId playerId)
AVPlayerMediaInfoSuccessCallback void onsuccess(MediaInfo mediaInfo, DeviceId playerId)
ContentInfo
MediaInfo
AVPlayer void getState(AVPlayerStateCallback successCallback, AVPlayerErrorCallback? errorCallback)
void play(Item item, AVPlayerSuccessCallback successCallback, AVPlayerErrorCallback? errorCallback, ContentInfo? contentInfo)
void stop(AVPlayerSuccessCallback successCallback, AVPlayerErrorCallback? errorCallback)
void seek(unsigned long position, AVPlayerSuccessCallback successCallback, AVPlayerErrorCallback? errorCallback)
void pause(AVPlayerSuccessCallback successCallback, AVPlayerErrorCallback? errorCallback)
void resume(AVPlayerSuccessCallback successCallback, AVPlayerErrorCallback? errorCallback)
void getVolume(AVPlayerVolumeSuccessCallback successCallback, AVPlayerErrorCallback? errorCallback)
void setVolume(unsigned short level, AVPlayerSuccessCallback successCallback, AVPlayerErrorCallback? errorCallback)
void getMute(AVPlayerMuteSuccessCallback successCallback, AVPlayerErrorCallback? errorCallback)
void setMute(boolean muted, AVPlayerSuccessCallback successCallback, AVPlayerErrorCallback? errorCallback)
void getPlayPosition(AVPlayerPlayPositionSuccessCallback successCallback, AVPlayerErrorCallback? errorCallback)
void getMediaInfo(AVPlayerMediaInfoSuccessCallback successCallback, AVPlayerErrorCallback errorCallback)
long addAVPlayerStateChangeListener(AVPlayerStateChangedCallback stateCallback)
void removeAVPlayerStateChangeListener(long changeListenerId)

1. Type Definitions

1.1. AVPlayerState

Specifies the state of AVPlayer.

    enum AVPlayerState { "UNKNOWN", "STOPPED", "BUFFERING", "PLAYING", 
                         "PAUSED", "CONTENT_CHANGED" };
  • UNKNOWN: The AVPlayer is in an unknown state.
  • STOPPED: The AVPlayer is in the stopped state.
  • BUFFERING: The AVPlayer is in the buffering state.
  • PLAYING: The AVPlayer is in the playing state.
  • PAUSED: The AVPlayer is in the paused state.
  • CONTENT_CHANGED: The AVPlayer is in the content changed state.

2. Interfaces

2.1. AVPlayerSuccessCallback

Provides a generic AVPlayer success callback.

    [Callback=FunctionOnly, NoInterfaceObject] interface AVPlayerSuccessCallback {
        
        void onsuccess(DeviceId playerId);
    };

METHODS

onsuccess

Invoked when a request results in success.

Signature
void onsuccess(DeviceId playerId);
Parameters
  • playerId
    • Optional: No.
    • Nullable: No.
    • Type: DeviceId.
    • Description: The identifier of the AVPlayer device on which the request was performed.

2.2. AVPlayerPlayPositionSuccessCallback

Provides an interface for getting playback position response from AVPlayer.

    [Callback=FunctionOnly, NoInterfaceObject] interface AVPlayerPlayPositionSuccessCallback {    

         void onsuccess(unsigned long position,
                        DeviceId playerId);    
    };

METHODS

onsuccess

Invoked when a request results in success.

Signature
void onsuccess(unsigned long position, DeviceId playerId);
Parameters
  • position
    • Optional: No.
    • Nullable: No.
    • Type: unsigned long.
    • Description: Returned current Playback position.
  • playerId
    • Optional: No.
    • Nullable: No.
    • Type: DeviceId.
    • Description: The identifier of the AVPlayer device from which the playback position was obtained.

2.3. AVPlayerVolumeSuccessCallback

Provides an interface for getting volume level response from AVPlayer.

    [Callback=FunctionOnly, NoInterfaceObject] interface AVPlayerVolumeSuccessCallback  {    
        
         void onsuccess(unsigned short level,
                        DeviceId playerId);    
    };

METHODS

onsuccess

Invoked when a request results in success.

Signature
void onsuccess(unsigned short level, DeviceId playerId);
Parameters
  • level
    • Optional: No.
    • Nullable: No.
    • Type: unsigned short.
    • Description: Returned current Playback position.
  • playerId
    • Optional: No.
    • Nullable: No.
    • Type: DeviceId.
    • Description: The identifier of the AVPlayer device from which the playback position was obtained.

2.4. AVPlayerMuteSuccessCallback

Provides an interface for getting mute status response from AVPlayer.

    [Callback=FunctionOnly, NoInterfaceObject] interface AVPlayerMuteSuccessCallback {    

         void onsuccess(boolean mute,
                        DeviceId playerId);                         
    };

METHODS

onsuccess

Invoked when a request results in success.

Signature
void onsuccess(boolean mute, DeviceId playerId);
Parameters
  • mute
    • Optional: No.
    • Nullable: No.
    • Type: boolean.
    • Description: Returned current mute value.
  • playerId
    • Optional: No.
    • Nullable: No.
    • Type: DeviceId.
    • Description: The identifier of the AVPlayer device from which the mute status was obtained.

2.5. AVPlayerErrorCallback

Provides a generic AVPlayer error callback.

    [Callback=FunctionOnly, NoInterfaceObject] interface AVPlayerErrorCallback {
        
        void onerror(WebAPIError error,
                     DeviceId playerId);
    };

METHODS

onerror

Invoked when an error occurred while performing operations related to AVPlayer.

Signature
void onerror(WebAPIError error, DeviceId playerId);
Parameters
  • error
    • Optional: No.
    • Nullable: No.
    • Type: WebAPIError.
    • Description: WebAPIError which was raised.
  • playerId
    • Optional: No.
    • Nullable: No.
    • Type: DeviceId.
    • Description: The identifier of the AVPlayer device on which the error was raised.

2.6. AVPlayerStateChangedCallback

Provides an interface for getting state change events from AVPlayer.

    [Callback=FunctionOnly, NoInterfaceObject] interface AVPlayerStateChangedCallback {

         void onstatechange(AVPlayerState state, 
                            DeviceId playerId);
    };

METHODS

onstatechange

Invoked when state change event occurred.

Signature
void onstatechange(AVPlayerState state, DeviceId playerId);
Parameters
  • state
    • Optional: No.
    • Nullable: No.
    • Type: AVPlayerState.
    • Description: New AVPlayer state information.
  • playerId
    • Optional: No.
    • Nullable: No.
    • Type: DeviceId.
    • Description: The identifier of the AVPlayer device on which state was changed.

2.7. AVPlayerStateCallback

Provides an interface for getting state of AVPlayer.

    [Callback=FunctionOnly, NoInterfaceObject] interface AVPlayerStateCallback {
 
          void onsuccess(AVPlayerState state, 
                         DeviceId playerId);     
    };

METHODS

onsuccess

Invoked when a request results in success.

Signature
void onsuccess(AVPlayerState state, DeviceId playerId);
Parameters
  • state
    • Optional: No.
    • Nullable: No.
    • Type: AVPlayerState.
    • Description: Returned AVPlayer state.
  • playerId
    • Optional: No.
    • Nullable: No.
    • Type: DeviceId.
    • Description: The identifier of the AVPlayer device from which the state was obtained.

2.8. AVPlayerMediaInfoSuccessCallback

Provides interface for getting media information from AVPlayer.

    [Callback=FunctionOnly, NoInterfaceObject] interface AVPlayerMediaInfoSuccessCallback {    

         void onsuccess(MediaInfo mediaInfo,
                         DeviceId playerId);    
    };

METHODS

onsuccess

Invoked if a request results in success.

Signature
void onsuccess(MediaInfo mediaInfo, DeviceId playerId);
Parameters
  • mediaInfo
    • Optional: No.
    • Nullable: No.
    • Type: MediaInfo.
    • Description: MediaInfo object returned from the device.
  • playerId
    • Optional: No.
    • Nullable: No.
    • Type: DeviceId.
    • Description: The identifier of the AVPlayer device from which the state was obtained.

2.9. ContentInfo

Dictionary to set the playing option for content information.

    dictionary ContentInfo {
    
        long long startingPosition;
        
    };

Dictionary members

long long startingPosition

Represents the starting position for playing content, seconds.

The default value is 0.

2.10. MediaInfo

Provides interface for representing media information.

    [NoInterfaceObject] interface MediaInfo {
        
        readonly attribute unsigned long long duration;
        
    };

ATTRIBUTES

readonly unsigned long long duration

Represents duration of media object in seconds.

This attribute is read-only.

2.11. AVPlayer

Provides an interface for remote AV player device.

    [NoInterfaceObject] interface AVPlayer : DeviceDevice {        
                
        readonly attribute boolean isAudioSupported;
        
        readonly attribute boolean isVideoSupported;        
        
        void getState(AVPlayerStateCallback successCallback, 
                      optional AVPlayerErrorCallback? errorCallback);                          
        
        void play(Item item,
                  AVPlayerSuccessCallback successCallback, 
                  optional AVPlayerErrorCallback? errorCallback,
                  optional ContentInfo? contentInfo);
        
        void stop(AVPlayerSuccessCallback successCallback, 
                  optional AVPlayerErrorCallback? errorCallback);
        
        void seek(unsigned long position, 
                  AVPlayerSuccessCallback successCallback, 
                  optional AVPlayerErrorCallback? errorCallback);


        void pause(AVPlayerSuccessCallback successCallback, 
                   optional AVPlayerErrorCallback? errorCallback);
        
        void resume(AVPlayerSuccessCallback successCallback, 
                    optional AVPlayerErrorCallback? errorCallback);
        
        
        void getVolume(AVPlayerVolumeSuccessCallback successCallback, 
                       optional AVPlayerErrorCallback? errorCallback);
        
        
        void setVolume(unsigned short level, 
                       AVPlayerSuccessCallback successCallback, 
                       optional AVPlayerErrorCallback? errorCallback);

        void getMute(AVPlayerMuteSuccessCallback successCallback, 
                     optional AVPlayerErrorCallback? errorCallback);

        void setMute(boolean muted,
                     AVPlayerSuccessCallback successCallback, 
                     optional AVPlayerErrorCallback? errorCallback);
        
        void getPlayPosition(AVPlayerPlayPositionSuccessCallback successCallback, 
                             optional AVPlayerErrorCallback? errorCallback);

        void getMediaInfo(AVPlayerMediaInfoSuccessCallback successCallback,
                          AVPlayerErrorCallback errorCallback);
        
        long addAVPlayerStateChangeListener(AVPlayerStateChangedCallback stateCallback);


        void removeAVPlayerStateChangeListener(long changeListenerId);        
    };
Code example
 
 var serviceProvider; // it is assumed that you obtained serviceProvider. For further details, see the creatServiceProvider(..).
 var deviceId;           // it is assumed that an avplayer's device Id is already distingushed
 
 try {
     var avplayer = serviceProvider.getDeviceFinder().getDevice("AVPLAYER", deviceId);

     // Print out the device's name
     console.log(avplayer.name);
     
 } catch(e) {
      console.log(e.name);
 }
 
 

ATTRIBUTES

readonly boolean isAudioSupported

Determines whether the player supports audio content or not.

This attribute is read-only.

readonly boolean isVideoSupported

Determines whether the player supports video content or not.

This attribute is read-only.

METHODS

getState

Asynchronous function for getting the AVPlayer state.

Signature
void getState(AVPlayerStateCallback successCallback, optional AVPlayerErrorCallback? errorCallback);

The error callback is launched with these error types:

  • UnknownError: In the case of any other error
Parameters
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: AVPlayerStateCallback.
    • Description: Callback function called if the request is successfull.
  • errorCallback
    • Optional: Yes.
    • Nullable: Yes.
    • Type: AVPlayerErrorCallback.
    • Description: Callback function called if the request has failed.
Exceptions
  • WebAPIException:

    with error type NotSupportedError, if this feature is not supported.

    with error type SecurityError, if this functionality is not allowed.

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

Code example
 
 var serviceProvider; // it is assumed that you obtained serviceProvider. For further details,  see createServiceProvider() or getServiceProvider().

 function sStateCB(state, avplayerId) {
     console.log(state);
 }

 function eStateCB(error, avplayerId) {
     console.log(error.name);
 }

 try {
     // Obtain available avplayers
     var avplayers = serviceProvider.getDeviceFinder().getDevices("AVPLAYER");
     if (avplayers.length > 0) {
         avplayers[0].getState(sStateCB, eStateCB);
     }
 } catch(e) {
      console.log(e.name);
 }
 
 

play

Asynchronous function for playing content on the AVPlayer device.

Signature
void play(Item item, AVPlayerSuccessCallback successCallback, optional AVPlayerErrorCallback? errorCallback, optional ContentInfo? contentInfo);

The error callback is launched with these error types:

  • InvalidValuesError: if any of the input parameters contain an invalid value.
  • NotFoundError: if the item does not exist.
Parameters
  • item
    • Optional: No.
    • Nullable: No.
    • Type: Item.
    • Description: Item you would like to play.
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: AVPlayerSuccessCallback.
    • Description: Callback function called if the request is successfull.
  • errorCallback
    • Optional: Yes.
    • Nullable: Yes.
    • Type: AVPlayerErrorCallback.
    • Description: Callback function called if the request has failed.
  • contentInfo
    • Optional: Yes.
    • Nullable: Yes.
    • Type: ContentInfo.
    • Description: Items content info that you would like to provide to player.
Exceptions
  • WebAPIException:

    with error type NotSupportedError, if this feature is not supported.

    with error type SecurityError, if this functionality is not allowed.

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

Code example
 var serviceProvider; // it is assumed that you obtained serviceProvider. For further details,  see the createServiceProvider() or getServiceProvider().
 var playerId;           // assumed to be the identifier of the avplayer selected by the user.
 var item;                // it is assumed that an item is already retrieved 

 function sucessCB(avplayerId) {
     console.log("now on playing");
 }

 function errorCB(error, avplayerId) {
     console.log(error.name);
 }

 try {
     var deviceFinder = serviceProvider.getDeviceFinder();

     // Obtain the avplayer which is playing the media
     var avplayer = deviceFinder.getDevice("AVPLAYER", playerId);

     avplayer.play(item, sucessCB, errorCB);

 } catch(e) {
      console.log(e.name);
 }
 

stop

Asynchronous function for stopping content play on the AVPlayer device.

Signature
void stop(AVPlayerSuccessCallback successCallback, optional AVPlayerErrorCallback? errorCallback);

The error callback is launched with these error types:

  • UnknownError: In the case of any other error
Parameters
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: AVPlayerSuccessCallback.
    • Description: Callback function called if the request is successfull.
  • errorCallback
    • Optional: Yes.
    • Nullable: Yes.
    • Type: AVPlayerErrorCallback.
    • Description: Callback function called if the request has failed.
Exceptions
  • WebAPIException:

    with error type NotSupportedError, if this feature is not supported.

    with error type SecurityError, if this functionality is not allowed.

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

Code example
 
 var serviceProvider; // it is assumed that you obtained serviceProvider. For further details,  see createServiceProvider() or getServiceProvider().
 var playerId;           // assumed to be the identifier of an avplayer device which is currently playing media.

 function sucessCB(avplayerId) {
     console.log("playing a media is stopped");
 }

 function errorCB(error, avplayerId) {
     console.log(error.name);
 }

 try {
     var deviceFinder = serviceProvider.getDeviceFinder();

     // Obtain the avplayer which is playing the media
     var avplayer = deviceFinder.getDevice("AVPLAYER", playerId);

     avplayer.stop(sucessCB, errorCB);

 } catch(e) {
      console.log(e.name);
 }
 
 

seek

Asynchronous function for changing the playing position of the AVPlayer in second.

Signature
void seek(unsigned long position, AVPlayerSuccessCallback successCallback, optional AVPlayerErrorCallback? errorCallback);

The error callback is launched with these error types:

  • InvalidValuesError: if any of the input parameters contain an invalid value.
  • UnknownError: In the case of any other error
Parameters
  • position
    • Optional: No.
    • Nullable: No.
    • Type: unsigned long.
    • Description: Playing time to be changed in seconds.
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: AVPlayerSuccessCallback.
    • Description: Callback function called if the request is successfull.
  • errorCallback
    • Optional: Yes.
    • Nullable: Yes.
    • Type: AVPlayerErrorCallback.
    • Description: Callback function called if the request has failed.
Exceptions
  • WebAPIException:

    with error type NotSupportedError, if this feature is not supported.

    with error type SecurityError, if this functionality is not allowed.

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

pause

Asynchronous function for pausing content playing on AVPlayer device.

Signature
void pause(AVPlayerSuccessCallback successCallback, optional AVPlayerErrorCallback? errorCallback);

The error callback is launched with these error types:

  • UnknownError: In the case of any other error
Parameters
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: AVPlayerSuccessCallback.
    • Description: Callback function called if the request is successfull.
  • errorCallback
    • Optional: Yes.
    • Nullable: Yes.
    • Type: AVPlayerErrorCallback.
    • Description: Callback function called if the request has failed.
Exceptions
  • WebAPIException:

    with error type NotSupportedError, if this feature is not supported.

    with error type SecurityError, if this functionality is not allowed.

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

resume

Asynchronous function for resuming content playing on AVPlayer device.

Signature
void resume(AVPlayerSuccessCallback successCallback, optional AVPlayerErrorCallback? errorCallback);

The error callback is launched with these error types:

  • UnknownError: In the case of any other error
Parameters
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: AVPlayerSuccessCallback.
    • Description: Callback function called if the request is successful.
  • errorCallback
    • Optional: Yes.
    • Nullable: Yes.
    • Type: AVPlayerErrorCallback.
    • Description: Callback function called if the request has failed.
Exceptions
  • WebAPIException:

    with error type NotSupportedError, if this feature is not supported.

    with error type SecurityError, if this functionality is not allowed.

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

getVolume

Asynchronous function for getting volume of AVPlayer device.

Signature
void getVolume(AVPlayerVolumeSuccessCallback successCallback, optional AVPlayerErrorCallback? errorCallback);

The error callback is launched with these error types:

  • UnknownError: In the case of any other error
Parameters
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: AVPlayerVolumeSuccessCallback.
    • Description: Callback function called if the request is successful.
  • errorCallback
    • Optional: Yes.
    • Nullable: Yes.
    • Type: AVPlayerErrorCallback.
    • Description: Callback function called if the request has failed.
Exceptions
  • WebAPIException:

    with error type NotSupportedError, if this feature is not supported.

    with error type SecurityError, if this functionality is not allowed.

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

setVolume

Asynchronous function for setting volume of AVPlayer device.

Signature
void setVolume(unsigned short level, AVPlayerSuccessCallback successCallback, optional AVPlayerErrorCallback? errorCallback);

The error callback is launched with these error types:

  • InvalidValuesError: if any of the input parameters contains an invalid value.
  • UnknownError: In the case of any other error
Parameters
  • level
    • Optional: No.
    • Nullable: No.
    • Type: unsigned short.
    • Description: Volume level you would like to set. The volume value range is 0~100.
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: AVPlayerSuccessCallback.
    • Description: Callback function called if the request is successfull.
  • errorCallback
    • Optional: Yes.
    • Nullable: Yes.
    • Type: AVPlayerErrorCallback.
    • Description: Callback function called if the request has failed.
Exceptions
  • WebAPIException:

    with error type NotSupportedError, if this feature is not supported.

    with error type SecurityError, if this functionality is not allowed.

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

getMute

Asynchronous function for getting mute status of the AVPlayer device.

Signature
void getMute(AVPlayerMuteSuccessCallback successCallback, optional AVPlayerErrorCallback? errorCallback);

The error callback is launched with these error types:

  • UnknownError: In the case of any other error
Parameters
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: AVPlayerMuteSuccessCallback.
    • Description: Callback function called if the request is successful.
  • errorCallback
    • Optional: Yes.
    • Nullable: Yes.
    • Type: AVPlayerErrorCallback.
    • Description: Callback function called if the request has failed.
Exceptions
  • WebAPIException:

    with error type NotSupportedError, if this feature is not supported.

    with error type SecurityError, if this functionality is not allowed.

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

setMute

Asynchronous function for setting mute status of AVPlayer device.

Signature
void setMute(boolean muted, AVPlayerSuccessCallback successCallback, optional AVPlayerErrorCallback? errorCallback);

The error callback is launched with these error types:

  • UnknownError: In the case of any other error
Parameters
  • muted
    • Optional: No.
    • Nullable: No.
    • Type: boolean.
    • Description: Mute status you would like to set.
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: AVPlayerSuccessCallback.
    • Description: Callback function called if the request is successfull.
  • errorCallback
    • Optional: Yes.
    • Nullable: Yes.
    • Type: AVPlayerErrorCallback.
    • Description: Callback function called if the request has failed.
Exceptions
  • WebAPIException:

    with error type NotSupportedError, if this feature is not supported.

    with error type SecurityError, if this functionality is not allowed.

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

getPlayPosition

Asynchronous function for getting the current position of the media playing on an AVPlayer device.

Signature
void getPlayPosition(AVPlayerPlayPositionSuccessCallback successCallback, optional AVPlayerErrorCallback? errorCallback);

The error callback is launched with these error types:

  • UnknownError: In the case of any other error
Parameters
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: AVPlayerPlayPositionSuccessCallback.
    • Description: Callback function called if the request is successfull.
  • errorCallback
    • Optional: Yes.
    • Nullable: Yes.
    • Type: AVPlayerErrorCallback.
    • Description: Callback function called if the request has failed.
Exceptions
  • WebAPIException:

    with error type NotSupportedError, if this feature is not supported.

    with error type SecurityError, if this functionality is not allowed.

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

Code example
 
 var serviceProvider; // it is assumed that you obtained serviceProvider. For further details,  see the createServiceProvider() or getServiceProvider().
 var playerId;           // assumed to be the identifier of an avplayer device which is currently playing media.

 function sucessCB(position, avplayerId) {
     console.log("current playing time : " + position);
 }

 function errorCB(error, avplayerId) {
     console.log(error.name);
 }

 try {
     var deviceFinder = serviceProvider.getDeviceFinder();

     // Obtain the avplayer which is playing the media
     var avplayer = deviceFinder.getDevice("AVPLAYER", playerId);

     avplayer.getPlayPosition(sucessCB, errorCB);

 } catch(e) {
      console.log(e.name);
 }
 
 

getMediaInfo

Asynchronous function for getting the media information which is playing on a remote AV player.

Signature
void getMediaInfo(AVPlayerMediaInfoSuccessCallback successCallback, AVPlayerErrorCallback errorCallback);

The error callback is launched with these error types:

  • UnknownError: In the case of any other error
Parameters
  • successCallback
    • Optional: No.
    • Nullable: No.
    • Type: AVPlayerMediaInfoSuccessCallback.
    • Description: Callback function called if the request is successfull.
  • errorCallback
    • Optional: No.
    • Nullable: No.
    • Type: AVPlayerErrorCallback.
    • Description: Callback function called if the request has failed.
Exceptions
  • WebAPIException:

    with error type NotSupportedError, if this feature is not supported.

    with error type SecurityError, if this functionality is not allowed.

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

Code example
 
 var serviceProvider; // it is assumed that you obtained serviceProvider. For further details,  see the createServiceProvider() or getServiceProvider().
 var playerId;           // assumed to be the identifier of an avplayer device which is currently playing media.

 function sucessCB(mediaInfo, avplayerId) {
     console.log("total running time : " + mediaInfo.duration);
 }

 function errorCB(error, avplayerId) {
     console.log(error.name);
 }

 try {
     var deviceFinder = serviceProvider.getDeviceFinder();

     // Obtain the avplayer which is playing the media
     var avplayer = deviceFinder.getDevice("AVPLAYER", playerId);

     avplayer.getPlayPosition(sucessCB, errorCB);

 } catch(e) {
      console.log(e.name);
 }
 
 

addAVPlayerStateChangeListener

Registers a player state change listener.

Signature
long addAVPlayerStateChangeListener(AVPlayerStateChangedCallback stateCallback);
Parameters
  • stateCallback
    • Optional: No.
    • Nullable: No.
    • Type: AVPlayerStateChangedCallback.
    • Description: Callback function called if the state is changed.
Return value
long Registered listener id.
Exceptions
  • WebAPIException:

    with error type NotSupportedError, if this feature is not supported.

    with error type SecurityError, if this functionality is not allowed.

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

Code example
 
 var serviceProvider; // it is assumed that you obtained serviceProvider. For further details,  see createServiceProvider() or getServiceProvider().
 var playerId;            // assumed to be the identifier of an avplayer device which is currently playing media.

 function sucessCB(state, avplayerId) {
     console.log(state);
 }

 try {
     var deviceFinder = serviceProvider.getDeviceFinder();

     // Obtain the avplayer which is playing the media
     var avplayer = deviceFinder.getDevice("AVPLAYER", playerId);

     // Attach a state change listener
     var listenerId = avplayer.addAVPlayerStateChangedListener(stateCB);

 } catch(e) {
      console.log(e.name);
 }
 
 

removeAVPlayerStateChangeListener

Clears a player state change listener.

Signature
void removeAVPlayerStateChangeListener(long changeListenerId);
Parameters
  • changeListenerId
    • Optional: No.
    • Nullable: No.
    • Type: long.
    • Description: Player state change listener id
Exceptions
  • WebAPIException:

    with error type NotSupportedError, if this feature is not supported.

    with error type InvalidValuesError, if argument is invalid.

    with error type SecurityError, if this functionality is not allowed.

    with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.

Code example
 
 var serviceProvider; // it is assumed that you obtained serviceProvider. For further details,  see createServiceProvider() or getServiceProvider().
 var playerId;           // assumed to be the identifier of an avplayer device which is currently playing media.
 var listenerId;         // it is assumed that a state change listener is already registered

 function sucessCB(state, avplayerId) {
     console.log(state);
 }

 try {
     var deviceFinder = serviceProvider.getDeviceFinder();

     // Obtain the avplayer which is playing the media
     var avplayer = deviceFinder.getDevice("AVPLAYER", playerId);

     // Attach a state change listener
     avplayer.removeAVPlayerStateChangedListener(listenerId);

 } catch(e) {
      console.log(e.name);
 }
 
 

3. Full WebIDL

module AVPlayer {  
          
    enum AVPlayerState { "UNKNOWN", "STOPPED", "BUFFERING", "PLAYING", 
                         "PAUSED", "CONTENT_CHANGED" };
    
    [Callback=FunctionOnly, NoInterfaceObject] interface AVPlayerSuccessCallback {
        
        void onsuccess(DeviceId playerId);
    };
    
    [Callback=FunctionOnly, NoInterfaceObject] interface AVPlayerPlayPositionSuccessCallback {    

         void onsuccess(unsigned long position,
                        DeviceId playerId);    
    };

    [Callback=FunctionOnly, NoInterfaceObject] interface AVPlayerVolumeSuccessCallback  {    
        
         void onsuccess(unsigned short level,
                        DeviceId playerId);    
    };

    [Callback=FunctionOnly, NoInterfaceObject] interface AVPlayerMuteSuccessCallback {    

         void onsuccess(boolean mute,
                        DeviceId playerId);                         
    };
    
    [Callback=FunctionOnly, NoInterfaceObject] interface AVPlayerErrorCallback {
        
        void onerror(WebAPIError error,
                     DeviceId playerId);
    };
    
    [Callback=FunctionOnly, NoInterfaceObject] interface AVPlayerStateChangedCallback {

         void onstatechange(AVPlayerState state, 
                            DeviceId playerId);
    };


    [Callback=FunctionOnly, NoInterfaceObject] interface AVPlayerStateCallback {
 
          void onsuccess(AVPlayerState state, 
                         DeviceId playerId);     
    };

    [Callback=FunctionOnly, NoInterfaceObject] interface AVPlayerMediaInfoSuccessCallback {    

         void onsuccess(MediaInfo mediaInfo,
                         DeviceId playerId);    
    };
    
    dictionary ContentInfo {
    
        long long startingPosition;
        
    };

    [NoInterfaceObject] interface MediaInfo {
        
        readonly attribute unsigned long long duration;
        
    };

    [NoInterfaceObject] interface AVPlayer : DeviceDevice {        
                
        readonly attribute boolean isAudioSupported;
        
        readonly attribute boolean isVideoSupported;        
        
        void getState(AVPlayerStateCallback successCallback, 
                      optional AVPlayerErrorCallback? errorCallback);                          
        
        void play(Item item,
                  AVPlayerSuccessCallback successCallback, 
                  optional AVPlayerErrorCallback? errorCallback,
                  optional ContentInfo? contentInfo);
        
        void stop(AVPlayerSuccessCallback successCallback, 
                  optional AVPlayerErrorCallback? errorCallback);
        
        void seek(unsigned long position, 
                  AVPlayerSuccessCallback successCallback, 
                  optional AVPlayerErrorCallback? errorCallback);


        void pause(AVPlayerSuccessCallback successCallback, 
                   optional AVPlayerErrorCallback? errorCallback);
        
        void resume(AVPlayerSuccessCallback successCallback, 
                    optional AVPlayerErrorCallback? errorCallback);
        
        
        void getVolume(AVPlayerVolumeSuccessCallback successCallback, 
                       optional AVPlayerErrorCallback? errorCallback);
        
        
        void setVolume(unsigned short level, 
                       AVPlayerSuccessCallback successCallback, 
                       optional AVPlayerErrorCallback? errorCallback);

        void getMute(AVPlayerMuteSuccessCallback successCallback, 
                     optional AVPlayerErrorCallback? errorCallback);

        void setMute(boolean muted,
                     AVPlayerSuccessCallback successCallback, 
                     optional AVPlayerErrorCallback? errorCallback);
        
        void getPlayPosition(AVPlayerPlayPositionSuccessCallback successCallback, 
                             optional AVPlayerErrorCallback? errorCallback);

        void getMediaInfo(AVPlayerMediaInfoSuccessCallback successCallback,
                          AVPlayerErrorCallback errorCallback);
        
        long addAVPlayerStateChangeListener(AVPlayerStateChangedCallback stateCallback);


        void removeAVPlayerStateChangeListener(long changeListenerId);        
    };
};