media_play(STRING* name,BMAP* target, var volume)

media_loop(STRING* name,BMAP* target, var volume)

Plays a movie or audio stream from a file to the screen or to a texture or panel. media_play plays the stream once, media_loop repeats it until it is explicitly stopped. As many movie, sound or music files as supported by the hardware can be played simultaneously - for instance, to play two midi files at the same time you'd normally need two sound cards. All file formats supported by installed CODECs can be played with this instruction - .avi, .mpg, .divx, .wmv, .wma, .wav, .mid, .mp3, .ogg and so on, even some still image formats like .bmp or .jpg.

Parameters:

name Name of the multimedia file.  !!  The file is streamed from hard disk; therefore it must exist in the work folder, and won't be found in the path, in a buffer,  or in a resource. Playing from a subfolder is only possible when adding the folder name, f.i. media_loop("media\\scene.avi", NULL, 100);.
target  C  Pointer to a bmap that serves as target texture for the video stream, or NULL for playing the video in the whole engine window. Using a target texture, the video can be played on a model or sprite surface in the level.
volume Individual audio volume of the stream, 0 ..100. The master volume for all streams is controlled by the midi_vol variable

Returns:

Handle of the multimedia stream, or 0 if the stream couldn't be played.

Speed:

Medium

Remarks:

Example:

// Play music "ribanna.mid" at 50% volume endlessly.
mhandle = media_loop("ribanna.mid",NULL,50);
// Play movie "news.avi" on the tv_model entity with maximum volume
media_play("news.avi",bmap_for_entity(tv_model,0),100); 
// Play movie "news.mpg" on the full screen with maximum volume
media_play("news.mpg",NULL,100); 

See also:

media_pause, media_playing, media_start, media_stop, media_tune, media_layer, midi_vol, num_mediastreams, snd_play

► latest version online