AppMedia Method (CLIENT)


PLB Web Only, 9.9

 

The AppMedia method provides the ability to play audio files on a mobile device. The method uses the following format:

 

[label]

{object}.AppMedia

[GIVING {return}] USING *Action=]{action}[:

 

 

[*Url=]{url}][,[*Volume=]{Volume}]

 

Where:

label

Optional. A Program Execution Label.

object

Required. A CLIENT object.

return

Optional. A Numeric Variable that returns the success or failure of the method.

action

Required. A Numeric Variable or decimal number that specifies the action to be performed by this method.

url

Optional. A Character String Variable or string literal that specifies a valid URL string to be used by this method as the source.

volume

Optional. A Numeric Variable or decimal number that specifies the volume to be used for this method.

Flags Affected: OVER, ZERO

Note the following:

  1. This method is only used for a Sunbelt PL/B Web Client App using Cordova\PhoneGap operations. See the following link for details on the Cordova plugin used:

  2.  

         https://www.npmjs.com/package/cordova-plugin-media

     

  3. The ZERO flag is set when the {return} value is zero.

  4. The OVER flag is set if the value returned is too large to be stored into the {return} variable.

  5. {volume} must be within the range of 0 to 100.

  6. The supported {action} values are defined as follows:

  7.  

    Value

    Type

    Action

    0

    AppMediaPlay

    The current media source starts to play.

    1

    AppMediaPause

    The current media source pauses.

    2

    AppMediaRewind

    The current media source is reset to the start.

    3

    AppMediaStop

    The current media source stops any play.

    4

    AppMediaRelease

    The current media source is released.

     

  8. If the {url} parameter is used, any old media source is released and a new media source is created using the given URI containing the audio content.

  9. This method starts an asynchronous operation on the mobile device which returns the results using the 'AppEventMedia' CLIENT object event where the event data is returned in ARG1 which contains a JSON notation string. The result of the media source creation is returned using the PLB event with the event data being returned in ARG1 in JSON notation. This event is returned when the media source has completed the current play, or stop action without any event data.

  10.  

    The event number used in EVENTREG is:

     

    AppEventMedia EQU 109 //Event number for EVENTREG.

     

    The event data is returned by this method with a JSON Error object as follows.

     

    JSON Error Object Event Data fields are defined as follows:

     

    Field

    Description

    code

    One of the pre-defined error codes listed below.

     

    MEDIA_ERR_ABORTED EQU 1

     

    MEDIA_ERR_NETWORK EQU 2

     

    MEDIA_ERR_DECODE EQU 3

     

    MEDIA_ERR_NONE_SUPPORTED EQU 4

    message

    Error message.

     

    Sample Code

     

    resMedia DIM 250

    dUrl INIT "http://audio.ibeat.org/content/p1rj1s/":

                  "p1rj1s_-_rockGuitar.mp3"

    .

             EventReg Client,AppEventMedia,MediaEvent,ARG1=resMedia

    .

            Client.AppMedia Using AppMediaPlay, *URL=dUrl

 

 

See Also: CLIENT, Client Methods, Method Syntax



PL/B Language Reference AddJs Method (CLIENT) AppPickContact Method (CLIENT)