private void openRadioChannelInternal()
{
if (!channelOpen)
{
channelOpen = true;
if (getBackgroundVolume() > 0 && loadNewBackground && backgroundToLoad != null && !mute)
{
Console.WriteLine("Setting background sounds file to " + backgroundToLoad);
String path = Path.Combine(backgroundFilesPath, backgroundToLoad);
if (!backgroundPlayerInitialised)
{
initialiseBackgroundPlayer();
}
backgroundPlayer.Volume = getBackgroundVolume();
backgroundPlayer.Open(new System.Uri(path, System.UriKind.Absolute));
loadNewBackground = false;
}
// this looks like we're doing it the wrong way round but there's a short
// delay playing the event sound, so if we kick off the background before the bleep
if (getBackgroundVolume() > 0)
{
if (!backgroundPlayerInitialised)
{
initialiseBackgroundPlayer();
}
backgroundPlayer.Volume = getBackgroundVolume();
int backgroundDuration = 0;
int backgroundOffset = 0;
if (backgroundPlayer.NaturalDuration.HasTimeSpan)
{
backgroundDuration = (backgroundPlayer.NaturalDuration.TimeSpan.Minutes * 60) +
backgroundPlayer.NaturalDuration.TimeSpan.Seconds;
//Console.WriteLine("Duration from file is " + backgroundDuration);
backgroundOffset = random.Next(0, backgroundDuration - backgroundLeadout);
}
//Console.WriteLine("Background offset = " + backgroundOffset);
backgroundPlayer.Position = TimeSpan.FromSeconds(backgroundOffset);
backgroundPlayer.Play();
}
if (enableStartBleep)
{
if (useShortBeepWhenOpeningChannel)
{
playShortStartSpeakingBeep();
}
else
{
playStartSpeakingBeep();
}
}
}
}