public static void Update() { if (_AllFileNames.Count > 0 && _CurrentMusicStream != -1) { float timeToPlay; if (_CurrentPlaylistElement.Finish == 0f) //No End-Tag defined { timeToPlay = CSound.GetLength(_CurrentMusicStream) - CSound.GetPosition(_CurrentMusicStream); } else //End-Tag found { timeToPlay = _CurrentPlaylistElement.Finish - CSound.GetPosition(_CurrentMusicStream); } bool finished = CSound.IsFinished(_CurrentMusicStream); if (_Playing && (timeToPlay <= CSettings.BackgroundMusicFadeTime || finished)) { if (_RepeatSong) { CSound.SetPosition(_CurrentMusicStream, 0); if (_VideoEnabled && _Video != -1) { CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap); } } else { Next(); } } } }
private static void LoadVideo() { if (_Video == -1) { _Video = CVideo.VdLoad(_CurrentPlaylistElement.VideoFilePath); CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap); _VideoEnabled = true; _FadeTimer.Reset(); _FadeTimer.Start(); } }
public static void Pause() { if (!_Playing) { return; } if (_VideoEnabled && _Video != -1) { CVideo.VdPause(_Video); CVideo.VdSkip(_Video, CSound.GetPosition(_CurrentMusicStream) + CSettings.BackgroundMusicFadeTime, _CurrentPlaylistElement.VideoGap); } CSound.FadeAndPause(_CurrentMusicStream, 0f, CSettings.BackgroundMusicFadeTime); _Playing = false; }
public static void Previous() { if (_PreviousFileNames.Count > 0 || _PreviousMusicIndex >= 0) { float pos = CSound.GetPosition(_CurrentMusicStream); if (CSound.GetPosition(_CurrentMusicStream) >= 1.5f) { CSound.SetPosition(_CurrentMusicStream, 0); if (_VideoEnabled && _Video != -1) { CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap); } } else { Stop(); _PreviousMusicIndex--; if (_PreviousMusicIndex < 0) { _PreviousMusicIndex = 0; //No previous songs left, so play the first } _CurrentPlaylistElement = _PreviousFileNames[_PreviousMusicIndex]; _CurrentMusicStream = CSound.Load(_CurrentPlaylistElement.MusicFilePath); CSound.SetStreamVolumeMax(_CurrentMusicStream, CConfig.BackgroundMusicVolume); if (_VideoEnabled) { LoadVideo(); } CSound.SetStreamVolume(_CurrentMusicStream, 0f); Play(); } } else if (_CurrentMusicStream != -1) { CSound.SetPosition(_CurrentMusicStream, 0); if (_VideoEnabled && _Video != -1) { CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap); } } }