Audio player

The Audio player control allows to reproduce audio media files into your developed apps. This control offer several properties and methods in order to set the behaviour and made some related control task.

There is a AudioPlayer sample app included with the installation of DecSoft App Builder. Take a look to see this control in action!

Audio player CSS rules

This control has a default style, and, some control JavaScript properties (see below), can also changes the control style, not to mention the Classes property, that you can use to establish one or more CSS classes to be applied to the control.

In addition to that style, you can also set custom CSS rules for the control by using the IDE controls style inspector. If this is not enough, you can include any number of CSS stylesheets in the app by using the app files manager.

If you want to use CSS stylesheets, you need to know how to refer to the control, so take a look at the Runtime selectors help topic.

Audio player designtime properties

The Audio player control put at your disposition the below designtime properties or variables. Designtime means here that these properties are only available in designtime and not in runtime.

Audio player runtime properties

The Audio player control put at your disposition the below runtime properties or variables. You can set almost all these variables in designtime, and, they are also available to be use when the app is running. Note that we named here these variables in a capitalized way, because is like you can see it in the designtime control's inspector, however, at runtime we use the lower camel case way.

Audio player methods

The Audio player control put at your disposition the below methods. You can use these methods in runtime in order to perform various control related tasks.

Audio player events

The Audio player control put at your disposition the below events handlers:

Audio player designtime properties

Audio player Top property

Designtime. Integer variable. The Top property stores the top position of the control in pixels. The pixels are relative to the app view, dialog or frame, and, is used "as is" if the app have the "Scale" app option is set to "false". Remember that this control property is only for designtime and is not available in runtime.

Audio player Left property

Designtime. Integer variable. The Left property stores the left position of the control in pixels. The pixels are relative to the app view, dialog or frame, and, is used "as is" if the app have the "Scale" app option is set to "false". Remember that this control property is only for designtime and is not available in runtime.

Audio player Width property

Designtime. Integer variable. The Width property stores the width of the control in pixels. The pixels are relative to the app view, dialog or frame, and, is used "as is" if the app have the "Scale" app option is set to "false". Remember that this control property is only for designtime and is not available in runtime.

Audio player Height property

Designtime. Integer variable. The Height property stores the height of the control in pixels. The pixels are relative to the app view, dialog or frame, and, is used "as is" if the app have the "Scale" app option is set to "false". Remember that this control property is only for designtime and is not available in runtime.

Audio player Locked property

Designtime. Boolean variable. The Locked property determines if the control can be moved or resized in app view designer or not. Set a "false" value mean the control can be moved and resized. Set a "true" value (by default) mean the control cannot be moved nor resized. Remember that this control property is only for designtime and is not available in runtime.

Audio player runtime properties

Audio player Name property

Runtime. String variable. The Name control property stores the name of the Audio player control as you set in designtime. The Name property value must be unique for the same app view, dialog or frame, that is, it's possible to have more than one "yourControlName" in the app, if that controls resides in different app views, dialogs or frames. Note that you must consider this variable as read only: change the name of a control in runtime can cause unexpected results.

Audio player Event property

Runtime. Mixed variable. The Event control property stores the "event" variable received in all the control events. This variable can contain the target (HTML element of the control) that fire the event and more useful stuff.

Audio player AutoPlay property

Runtime. Boolean variable. The AutoPlay control property can be set to "true" (it's "false" by default) at designtime in order to start the reproduction of the audio when the app view is show. Note, however, that some platforms can refuse to play a audio without the user intervention. Some platforms allows autoplayed audios only if muted. You can mute the audio using the Muted property.

Audio player Controls property

Runtime. Boolean variable. The Controls control property determines if the default player controls (play, stop buttons, seek bar, etc.) must be shown or not. This property is "true" by default but you can set to "false" in order to hide the default player controls. Remember that it's possible to control the player reproduction using the available control methods.

Audio player Loop property

Runtime. Boolean variable. The Loop control property determines if the media player must start to reproduce the media file again and again after their complete reproduction. This property is "false" by default but you can set to "true" in order to loop the player reproduction.

Audio player Muted property

Runtime. Boolean variable. The Muted control property determine if the reproduction sound must be muted. This variable is "false" by default but you can set to "true" to mute the sound. This property can be useful to use with the AutoPlay property for platforms and browsers that allows autoplayed audio, but only if they are muted.

Audio player Sources property

Runtime. Array of objects variable. The Sources control property allows to specify more than one differents audio media source files to be used. The browser or platform can then pick one of then in order to be reproduced.

You can set the Sources property at designtime using the Media sources dialog, or, can set it un runtime using the appendSource() method.

Note that, after the Sources property has been filled we cannot change the Audio player source (to be reproduced) using this property: when we need this we must manually set the Source property or by using the setSource() method.

Audio player Source property

Runtime. Object variable. The Source control property allows to set the current media file source to be reproduced in the Audio player. We can set this property manually or by using the setSource() method.

A source object is composed with the below properties:

Name Type Description
url String The media file URL to be set as the source of the Audio player.
type String The media file type / codec to be used. This property is optional, and, if not provided, the browser or platform try to automatically detect the media type and codec to be use.

Audio player Volume property

Runtime. Number variable. The Volume control property stores the current Audio player sound volume, which can be a value between 0 and 1. You can check this property to know the current volume level. To set the Audio player sound volume, however, you must use the setVolume() method.

Audio player AudioDuration property

Runtime. Number variable. The AudioDuration control property stores the length of the media file in seconds. This property is available after the DurationChange event has been fired.

Audio player CurrentTime property

Runtime. Number variable. The CurrentTime control property stores the current reproduction position in seconds. This property is available after the TimeUpdate event has been fired.

Audio player IsPaused property

Runtime. Boolean variable. The IsPaused control property determine if the Audio player reproduction has been paused or not. This property has a "true" value if the reproduction is paused, or "false" if not.

Audio player LastError property

Runtime. Object variable. The LastError control property stores information about the last error while fetching the media data. This property is available in the Error event and it's an object with the below properties. Note, however, that it's possible that the Error property was "null" in some cases.

Name Type Description
code Number The error code.
message String The error message.

Audio player Title property

Runtime. String variable. The Title control property stores some small but descriptive text, mainly to be used to be show that text when the user place the mouse cursor into the control.

Audio player Classes property

Runtime. String variable. The Classes control property stores one or more additionals CSS classes (space separated) to be applied to the control.

Audio player Hidden property

Runtime. Boolean variable. The Hidden control property determines if the control appear visible to the user or not. Set to "true" to hide the control, or to "false" to show the control (by default).

Audio player runtime methods

Audio player playAudio() method

Runtime method. You can use this Audio player control method to start to play the audio media file. This method do not require any argument.

Audio player pauseAudio() method

Runtime method. You can use this Audio player control method to pause a previously started reproduction of the audio media file. This method do not require any argument.

Audio player stop() method

Runtime method. You can use this Audio player control method to stop a previously started reproduction of the audio media file. This method do not require any argument.

Audio player seek() method

Runtime method. You can use this Audio player control method to go to certain specific position in the audio reproduction. This method requires the below argument:

Name Type Description
seconds Number The specific seconds to seek the audio.

Audio player setVolume() method

Runtime method. You can use this Audio player control method to set the audio volume of the audio reproduction. This method requires the below argument:

Name Type Description
volume Number A number between 0 and 1 that represent the volume level to be set.

Audio player setSource() method

Runtime method. You can use this Audio player control method to set the source of the Audio player at runtime. Remember that, once the Sources property is established the at designtime or in runtime, we need to use the Source property in order to change the source of the Audio player: you can use this method to establish the Source property. This method requires the below arguments:

Name Type Description
mediaUrl String The media file URL to be set as the source of the Audio player.
mediaType String The media file type / codec to be used. This argument is optional, and, if not provided, the browser or platform try to automatically detect the media type and codec to be use.

Audio player appendSource() method

Runtime method. You can use this Audio player control method to append a new media source into the Sources property at runtime. Remember that you can set the Sources property at designtime. You can use this method to fill the Sources property at runtime, however, once the Sources has been established, you must use the setSource() method to change the Audio player source.

Name Type Description
mediaUrl String The media file URL to be set as the source of the Audio player.
mediaType String The media file type / codec to be used. This argument is optional, and, if not provided, the browser or platform try to automatically detect the media type and codec to be use.

Audio player events

Audio player CanPlay event

The CanPlay event handler is fired when the browser or platform can resume playback of the media data, but estimates that if playback were to be started now, the media resource could not be rendered at the current playback rate up to its end without having to stop for further buffering of content. See the CanPlayThrough event. See also the available events variables.

Audio player CanPlayThrough event

The CanPlayThrough event handler is fired when the browser or platform estimates that if playback were to be started now, the media resource could be rendered at the current playback rate all the way to its end without having to stop for further buffering. See also the available events variables.

Audio player Play event

The Play event handler is fired when the Audio player is no longer paused. It's fired after the play() method has returned, or when the AutoPlay property has caused playback to begin. See also the available events variables.

Audio player Pause event

The Pause event handler is fired when the Audio player has been paused. It's fired after the pause() method has returned. See also the available events variables.

Audio player DurationChange event

The DurationChange event hander is fired when the Duration property has just been updated. See also the available events variables.

Audio player TimeUpdate event

The TimeUpdate event hander is fired when the current playback position changed as part of normal playback or in an especially interesting way, for example discontinuously. See the CurrentTime property. See also the available events variables.

Audio player Ended event

The Ended event hander is fired when the playback has stopped because the end of the media source was reached. See also the available events variables.

Audio player Seeking event

The Seeking event hander is fired when the browser or platform has started seeking to a new position. See the seek() method. See also the available events variables.

Audio player Seeked event

The Seeked event hander is fired after the current playback position was changed. See the seek() method. See also the available events variables.

Audio player VolumeChange event

The VolumeChange event hander is fired after the Volume property or the Muted property was changed. See the setVolume() method. See also the available events variables.

Audio player Error event

The Error event hander is fired when an error occurs while fetching the media data. See the Error property. See also the available events variables.

Audio player Click event

The Click event handler is fired when the user click or tap into the Audio player control. See also the available events variables.

Audio player DblClick event

The DblClick (Double Click) event handler is fired when the user double click or double tap into the Audio player control. See also the available events variables.

Audio player MouseUp event

The MouseUp event handler is fired when the user up the mouse into the Audio player control. See also the available events variables.

Audio player MouseDown event

The MouseDown event handler is fired when the user down the mouse into the Audio player control. See also the available events variables.

Audio player MouseMove event

The MouseMove event handler is fired when the user move the mouse into the Audio player control. See also the available events variables.

Audio player MouseEnter event

The MouseEnter event handler is fired when the user enter the mouse into the Audio player control. See also the available events variables.

Audio player MouseLeave event

The MouseLeave event handler is fired when the user leave the mouse from the Audio player control. See also the available events variables.

Audio player ContextMenu event

The ContextMenu event handler is fired when the browser must shown the context menu of the the Audio player control, which occur when the user click with the right mouse button into the Audio player control. See also the available events variables.

Audio player events variables

The below JavaScript variables are available in all the referred Audio player control events handlers:

Name Type Description
event Mixed This variable is received in almost all control events. You can use this variable to stop the propagation of the event, to access the HTML element who fire the event and more.
self Object Stores the control object. This is a shortcut to the control variable, and it's available since we are talking about specific control events.
view Object

Stores the current app view or dialog. This variable allow us to access to that view or dialog properties and methods and also their controls properties and methods. For example, you can access to a control properties using the variable "view.yourControlName", suposing the control is named "yourControlName".

views Object Stores all the loaded app views. Note that loaded views mean that the app views has been previously show to the user. It's possible to access to the app view controls properties like "views.view1.yourControlName", suposing the view is named "view1" and the control is named "yourControlName". In the same way we can access to other controls of the view and to other loaded views and their controls.
frames Object Stores all the app frames. You can use this variable to access to all the app frames and their controls.
dialogs Object Stores all the app dialogs. You can use this variable to access to all the app dialogs and their controls.
app Object Stores all the app properties and methods. You can use this variable to access to all the app properties and app methods.