Altova MobileTogether Designer

MobileTogether's Audio playback feature enables predefined audio sounds (available on clients) or audio files located on the mobile device or at a remote location to be played back. Audio can be played back on five channels (numbered 1 to 5), and each Audio action is defined for one specific channel.


Audio playback is controlled via the Audio (Playback) action. Each Audio action defines one of the following: (i) start playback of a predefined sound or specified file on a specified channel (see screenshot below), (ii) pause playback on a specific channel, (iii) resume playback on a specific channel, (iv) stop playback on a specific channel, and (v) jump to a position in the audio file playing on a specific channel. See the description of the Audio action for details. Typically, each Audio action will be assigned to a control event, such as a button click. When the event occurs, the Audio action is triggered.


The Audio playback feature works as follows:


When the Audio Start action is triggered, the selected predefined sound or the audio file named in the action will be played on the channel specified.

You can choose from among the following predefined sounds (which are available on client devices): ClickOffOn, ClickOnOff, Ding, DingDong, ErrorDeepBuzz, ErrorWhoops, Goodbye, KeyClickTick, KeyClickTock, MessageBounce, MessageXylophone, WhooshDeep, WhooshExhale, WhooshLong, WhooshQuick, WhooshQuicker.

If you choose to play an audio file, then the audio file, if located on the client device, will play directly. If the file is located on a remote server, then the file will be downloaded to the client device. If a local cache file is specified in the settings, then the downloaded data will be saved to this local file. If the specified cache file already exists, then the cache file will be played and no download takes place.

MIDI file playback is supported on all client devices except Web browsers. On iOS devices, however, MIDI file playback requires a sound bank file. The location of this file must be entered in the Start action (see screenshot above).

In the Start action, you can specify whether the entire audio file should be played back, or only a segment of it. The segment is defined in terms of start and end times (see screenshot above).

Each Start action is assigned to a channel, numbered 1 to 5. You can therefore run up to five audio streams simultaneously. Each Audio action is defined for a specific channel, and the settings of the action will apply to that channel.

The Pause, Resume, and Stop actions are simple actions, each of which would typically be defined on a control such as a button. Each of these actions is defined for a particular channel. They carry out the respective action for the audio file playing on that channel.

The Seek To action applies to the audio file playing on the specified channel, and jumps to the specified position in that file.


Note:If an audio stream is playing when a solution is suspended, then playback is paused. Playback continues when the solution is resumed.


Note:Multi-channel audio/video playback is not supported on Windows Phone. Only one audio or video file can be played at a time: this is the file that was started last.


Note:Audio and video files cannot be deployed to MobileTogether Server via the MobileTogether Designer project's Deploy to Server mechanism. You can, however, copy audio/video files manually to the server, although you cannot stream them from there via a URL. If you wish to stream audio/video files that are located on your MobileTogether Server, then do the following: (i) use the Load Binary action to load the binary audio/video data to a page source node; (ii) use the Save Binary action to save the data in this node to a file on the client device; (iii) use audio/video playback actions to play the file that is now saved on the client device. Alternatively, you can save audio/video files to a web server—instead of saving to MobileTogether Server—and use a URL to stream the audio/video file from the web server.


Audio playback events

Audio playback events are defined for the entire project. There are three predefined audio playback events (listed below). A set of any of MobileTogether's available actions can be defined for each of these events. To access the dialog in which these event actions are defined, click the Additional Dialog button of the Audio Actions project property. Since each of these events apply across the entire project, each event could be triggered by the audio on any channel. The \$MT_AudioChannel dynamic variable contains the number of the channel that triggered the event. So, for example, if the user starts playback of an audio file that runs on Channel 2, you can use the \$MT_AudioChannel variable in an XPath expression of an OnAudioStarted event action. The action could, for example, display database information about the audio file running on Channel 2.


OnAudioStarted: Before this event occurs (that is, before the audio file starts playing), details of the audio file are not available, and the functions to get audio duration and current position (see below) should not be called; at this time, only the mt-audio-is-playing function will return valid information. The OnAudioStarted event can be used, for example, to log details of audio playback to an XML tree node (say, via the Update Node action).

OnAudioError: Possible errors could be: File not Found, a file format error, or download/playback interruption. Information about the error can be retrieved with the MobileTogether XPath extension function mt-external-error. If actions are defined for the event, these actions are executed. Otherwise, the error is shown in a message box.

OnAudioCompleted: Audio playback is considered to be completed when the file or specified segment plays to the end (without a Stop action being executed). The actions defined for this event are not performed when the audio is suspended (with the project property On Switch to Other Solution) or paused.


Audio-playback-related MobileTogether XPath extension functions

The following audio-playback-related MobileTogether XPath extension functions are available:


mt-audio-get-current-position( ChannelNumber as xs:integer ) as xs:decimal

mt-audio-get-duration( ChannelNumber as xs:integer ) as xs:decimal

mt-audio-is-playing( ChannelNumber as xs:integer ) as xs:boolean


You can use these functions in XPath expressions anywhere in the design, for example, to display to the user the current position of audio playback in seconds. Note that before audio playback starts, details about the audio file are not available. As a result, information such as the duration and current position will not be known. The corresponding functions should therefore only be used after playback starts.


© 2017-2023 Altova GmbH