Altova MobileTogether Designer

The Audio action (screenshot below) plays back a predefined sound or an audio file. In the action, select one of these two options, and then define the parameters of the audio playback. You can define playback for up to five different sound channels.

MTActionAudioStart

 

Predefined audio

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

 

Either select the name of the predefined sound from the list in the combo box, or enter an XPath expression that evaluates to one of these predefined names. The names must exactly match the names in the previous paragraph.  

MTActionAudioPredefined

 

Using selected sound files

The Audio action also enables the playback of a sound file that you select. In the action's dialog, you can select one of the following actions: Start Audio, Pause, Resume, Stop, Seek (Jump) To.

 

Audio can be played back on five channels (numbered 1 to 5), and each Audio action is defined for one specific channel. So, for example, you could define the following sequence of actions:

 

1.Start audio playback on Channel 1

2.Pause audio playback on Channel 1

3.Start audio playback on Channel 2

4.Stop audio playback on Channel 2

5.Resume audio playback on Channel 1

6.Stop audio playback on Channel 1

 

Typically, the Audio action will be defined on a control event such as a button click (see screenshot below). The event triggers the associated Audio action. The various Audio actions are described below. For an overview of using audio in solutions, see the section Audio Playback.

 

Start audio

The Start audio action starts download and playback of the specified audio file on the specified channel. It takes the settings shown in the screenshot below.

MTActionAudioStart

Audio File: Click the Additional Dialog button to specify the audio file to play. The setting can be a URL or a relative file path, and can be either a static value or be located or generated by means of an XPath expression. Relative file paths are used to locate files that are stored on the mobile device. They are resolved relative to the base directory you specify for that device type (see screenshot below). For information on audio file formats, see Audio/Video Formats.

mtddevicedependentdirs_zoom80

Android: Select the Android device-directory from the dropdown list. If you select Default, which is the default selection, the MobileTogether app's sandbox directory is selected. Note, however, that, unless the Android device is rooted, no other app (besides MobileTogether) will be able to access the MobileTogether sandbox directory. So, trying to open a file in the MobileTogether sandbox with another app could fail.

Windows RT: Select the Windows Phone or Windows RT device folder from the dropdown list. If you select Default, which is the default selection, the MobileTogether app's sandbox directory is selected.

iOS: MobileTogether creates two directories on the user's device: (i) a Backed-up directory for files that are backed up by the operating system and will be available at later times, for example, after a restore. This directory is intended for files that are important for the user and that should not be lost; (ii) a Non-backed-up directory for files that do not need to be backed up, or if faster buffering is needed for playback. Select Backed-up directory or Non-backed-up directory as required.

Web browser: No selection is available. Relative paths are resolved within the context of the browser's sandbox.

If a value for the Audio File Cache setting is specified, then the downloaded file is cached to the designated local file. If the cache file already exists, the cache file will be played and no download takes place. Note that you must specify the full name of the cache file, including its extension, and the full file name (including the extension) must match the file name of the source file that is to be played. Note also that no advantage is gained if a cache file is specified for an audio file that is already located on the client device.

A sound bank file is required on iOS devices to play MIDI files. The Sound Bank File settings specify the locations of the sound bank file and its cache. If a cached sound bank file already exists, then the cache file will be used.

To play a segment of the audio file, enter the segment's From and To times in seconds. If you leave these fields blank, the audio file will play from start to end.

 

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.

 

Pause

This action is defined for a specific audio channel. When the action is triggered, the audio that is currently playing on the specified channel is paused. Typically, the action would be defined on a Pause Audio button. Note that this action applies across the project, and so would apply also to an audio file that was started on another page.

 

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

 

Resume

This action is defined for a specific channel, and resumes playback on that channel if it was previously paused. Typically, the action would be defined on a Resume Audio button. Note that this action applies to paused playback on the specified channel across the entire project, regardless of the page on which the audio file was started or paused.

 

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

 

Stop

When the Stop action is triggered, the audio that is currently playing on the specified channel is stopped. Typically, the action would be defined on a Stop Audio button, and it would apply to the audio file playing on the specified channel even if that file was started on another page.

 

Seek To

Causes playback to jump to the specified position (given in seconds) of the audio file playing on the specified channel. The action applies to the audio file playing on the specified channel regardless of the page on which playback was started.

 

Additional points

The section Audio (Playback) provides an overview of the audio playback feature of MobileTogether. There, you will also find information about Audio (playback) events.

 

MobileTogether extension functions

MobileTogether provides a range of XPath extension functions that have been specifically created for use in MobileTogether designs. Some functions can be particularly useful with specific actions. For example, mt-available-languages() returns the languages in which the solution is available and could, for example, be used with the Message Box action. If a function is especially relevant to this action, it is listed below. For a full list of extension functions and their descriptions, see the topic MobileTogether Extension Functions.

 

mt-audio-get-current-position()

mt-audio-get-duration()

mt-audio-is-playing()

mt-audio-is-recording()

mt-extract-file-extension()

mt-extract-file-name()

 

© 2018-2024 Altova GmbH