In the past, some of the users have demanded an “automation on time” function: the ability to play a news jingle at a given time, fading out any other player. There have been scripting solutions for this, but they involved finding a free player, loading the jingle into it, and starting that player. Not too easy, altogether.
As of mAirList 2.1.7, we have the ability to play audio files “detached”, that is, independently from the players. “Independetly” means that the file cannot be stopped or accessed in any way later. It will simply play until the end (or cue out), and then release itself. This feature is used internally to fade out items during information while playing the next item in the same player (the old item gets “detached” then). But you can also access it from a script. Here’s a little howto.
The method PlayItemDetached takes two parameters: The item to be played, as an IPlaylistItem reference; and the audio device to use, as an IAudioDevice reference. Both can be created on the fly:
- To load a file and create a playlist item from it, use the CreatePlaylistItemFromFile method. You can choose whether to load file tags and/or the MMD.
- To create an IAudioDevice object, use the new BuildAudioDevice function and pass the device descriptor as a string, as found in mAirList.ini, for example ‘BASS::“1”::“SB Audigy 4 [B400]”::1::44100’.
Both functions are documented in the CHM file.
Here’s an example script. It will fade out or players, and stop the automation if active, and then play a news jingle on the ‘BASS::“1”::“SB Audigy 4 [B400]”::1::44100’ device (BASS wdm output, first device, front speakers).
[code]var i: integer;
begin
if CurrentPlaybackControl.GetAutomation then
CurrentPlaybackControl.AutomationStop
else
for i := 0 to CurrentPlaybackControl.GetPlayerCount - 1 do
CurrentPlaybackControl.PlayerFadeOut(i);
CurrentPlaybackControl.PlayItemDetached(
CreatePlaylistItemFromFile(‘F:\eldoradio\jingles\News_PosOpen~9.mp3’, true),
BuildAudioDevice(‘BASS::“1”::“SB Audigy 4 [B400]”::1::44100’));
end.[/code]
If you want to play the file on the same sound card one of your players is using, you can omit the creation of a new device reference, and just ask that player for his IAudioDevice reference with GetOutputDevice (or GetPFLOutputDevice for the PFL device). For example, to use the same device as the first player of this playlist, replace the last three lines by
CurrentPlaybackControl.PlayItemDetached(
CreatePlaylistItemFromFile('F:\eldoradio\jingles\News_PosOpen~9.mp3', true),
CurrentPlaybackControl.GetPlayer(0).GetOutputDevice);
I hope these mechanisms are useful for you. I will soon make them available as event actions (‘play file detached’, ‘play file detached and stop players’). For the moment, these scripts should be easy enough to use for anyone.
Torben