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:
|
|
|
|
|
|
|
|
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:
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:
https://www.npmjs.com/package/cordova-plugin-media
The ZERO flag is set when the {return} value is zero.
The OVER flag is set if the value returned is too large to be stored into the {return} variable.
{volume} must be within the range of 0 to 100.
The supported {action} values are defined as follows:
|
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. |
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.
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.
The event number used in EVENTREG is:
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
See Also: CLIENT, Client Methods, Method Syntax
![]() |