Name
OpenMusic -- open a music file (V2.0)
Synopsis
[id] = OpenMusic(id, filename$[, table])
Function
This function opens the music file specified by filename$ and assigns the id to it. If you pass Nil in id, OpenMusic() will automatically choose a vacant identifier and return it. The file specified in filename$ will be opened and prepared for playback. Please note that files opened using OpenMusic() will be played using audio streaming. LoadSample() on the other hand, will load the entire sound file into memory first. Thus, you should use LoadSample() for playing short sounds and OpenMusic() for longer sounds and background music.

Music formats that are supported on all platforms are RIFF WAVE, IFF 8SVX, IFF 16SV, Protracker modules, and formats you have a plugin for. Depending on the platform Hollywood is running on, more music formats might be supported. For example, on Windows, Hollywood supports all formats that DirectShow can load, and on macOS, all formats recognized by Apple's AudioFile interface are supported.

Starting with Hollywood 6.0, this function accepts an optional table argument which allows you to pass additional parameters:

Loader:
This tag allows you to specify one or more format loaders that should be asked to load this music file. This must be set to a string containing the name(s) of one or more loader(s). Defaults to default. See Loaders and adapters for details. (V6.0)

Adapter:
This tag allows you to specify one or more file adapters that should be asked to open the specified file. This must be set to a string containing the name(s) of one or more adapter(s). Defaults to default. See Loaders and adapters for details. (V6.0)

This command is also available from the preprocessor: Use @MUSIC to preload music objects!

Inputs
id
identifier for the music object or Nil for auto id selection
filename$
file to load
table
optional: table configuring further options (see above) (V6.0)
Results
id
optional: identifier of the music object; will only be returned when you pass Nil as argument 1 (see above)
Example
OpenMusic(1, "Turrican2_Remix.mod")
PlayMusic(1)
The code above plays "Turrican2_Remix.mod".

Show TOC