Multimedia Guide and Reference

Recommended connections

You can make any connection between objects. The following explains certain key connections that can be made.

Getting the buttons to work

Only two connections are necessary. First, connect the player attribute of any button or button block to the self attribute of the audio wave player or digital video player. When this connection exists, the button can communicate with the player and take action when a button is pressed.

Next, connect the stateChanged event of the player to the setEmphasis action of the buttons. This enables and disables the buttons based on the state of the player. This connection is optional but gives your application a common look and feel.

Opening and closing the application

When your application opens, you should make a connection to open the audio wave player. The easiest way to open the audio wave player is by connecting the openedWidget event of your window to the openFile action of the audio wave player. Then, connect the name of the file you want to open to the aFileName parameter of the openFile connection.

When your application is finished working with the audio wave player, we recommend that you close it. Then, when your application ends, the player does not remain open. Closing the audio wave player ensures that other applications that use audio will have access to the player. One example is to connect the aboutToCloseWidget event of your window to the close action of the audio wave player.

Tips
It is important that, once opened, a multimedia player close before it, or another player, opens again. Otherwise, the system might hang or another unexpected result might occur.

Error handling

The easiest way for you to add error handling to your application is to tear off the lastError attribute and connect the errorOccured event of lastError to the display action of lastError. Now, whenever an error occurs, a message box displays.

There are three different types of errors: critical, warning and information. You can control which errors are displayed in the message box by setting errorThreshold. There are three values that you can set:

1
Displays only critical errors.
2
Displays both critical and warning errors.
3
Displays critical, warning and information errors.

The default error threshold is 2. To change this, you can connect the aboutToOpenWidget event of your window to the errorThreshold attribute of lastError. Set the argument to be either 1, 2, or 3.

Performance improvement

Depending on how your application's user interface is designed, you might want to take advantage of the fileToLoad attribute. For example, you can build a user interface that contains both a list box which lists the audio wave form files and the motion buttons. To play the selected file, you have two alternatives. The first is that every time you make a selection from the list, you open up the file. When the audio wave player receives an open, it loads up the file and prepares for playback. For large files, this can be time consuming. A better alternative is to update the fileToLoad attribute as the user maneuvers through the list. The file loads only when the user presses one of the buttons, such as Play.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]