Name
PlayMusic -- start playback of a music object (V2.0)
Synopsis
PlayMusic(id[, table])
Function
This command starts the playback of the music object specified by id. This music object must have been opened with either the @MUSIC preprocessor command or the OpenMusic() command.

Please note that before Hollywood 6.0 only one music could be played at a time. Starting with Hollywood 6.0 this limit is no longer there, but it is still enforced in order to be compatible with older scripts. Thus, if a music object is already playing and you call this command, that music will be stopped first before playback of the new music starts. If you need to play multiple music objects at the same time, you will have to explicitly disable this behaviour by calling LegacyControl() and setting the SingleMusic tag to False. PlayMusic() will no longer stop any playing music. See LegacyControl for details.

Prior to Hollywood 4.5, the second argument was optional and specified how many times the music object should be played. Starting with Hollywood 4.5, the second argument is now an optional table argument. Of course, the old syntax is still supported for compatibility. New scripts should use the new syntax though. The optional table argument recognizes the following tags:

Times:
This tag can be used to specify how many times the music object shall be played. This tag defaults to 1 which means that the music object is only played once. If you want your music object to loop infinitely, pass 0 as the second argument.

Volume:
Set this to the desired playback volume. This field can range from 0 to 64. If not specified, the music object's default volume will be used (you can modify the default volume of a music object by calling SetMusicVolume()).

Channel:
Channel to use for playback of this music object. By default, PlayMusic() will automatically choose a vacant channel and will fail if there is no vacant channel. To override this behaviour, you can use this field. When specified, it will always enforce playback on the very channel specified here. If the channel is already playing, it will be stopped first. (V6.1)

Inputs
id
identifier of the music object to start
table
optional: table argument specifying further options (V4.5)
Example
See OpenMusic


Show TOC