public bool PlayUri(string RadioUri) { try { lock (LockObject) { if (TempUpPlayer != null) { lock (TempUpPlayer) { TempUpPlayer.OnStartPlay -= TempUpPlayer_OnStartPlay; TempUpPlayer.OnStoped -= TempUpPlayer_OnStoped; TempUpPlayer.OnNewTrack -= TempUpPlayer_OnNewTrack; TempUpPlayer.OnError -= TempUpPlayer_OnError; TempUpPlayer.OnFftCalculated -= TempUpPlayer_OnFftCalculated; TempUpPlayer.Stop(); } } TempUpPlayer = new StreamPlayer(); TempUpPlayer.OnStartPlay += TempUpPlayer_OnStartPlay; TempUpPlayer.OnStoped += TempUpPlayer_OnStoped; TempUpPlayer.OnNewTrack += TempUpPlayer_OnNewTrack; TempUpPlayer.OnError += TempUpPlayer_OnError; TempUpPlayer.OnFftCalculated += TempUpPlayer_OnFftCalculated; TempUpPlayer.Volume = MasterVolume; TempUpPlayer.Play(RadioUri); IsPlaying = true; } return(true); } catch (Exception e) { // Console.WriteLine(e.Message); return(false); } }
public void PlayRadio(string url) { if (_oldPlayer != null) { _oldPlayer.VolumeDownAndStop(); _oldPlayer = null; } if (!string.IsNullOrEmpty(url)) { _oldPlayer = _temp; _temp = new StreamPlayer(this); _temp.OnError += _temp_OnError; _temp.OnStartPlay += _temp_OnStartPlay; _temp.OnStoped += _temp_OnStoped; ShoutcastStream s = new ShoutcastStream(url); s.StreamTitleChanged += (a, b) => { if (OnTrack != null) { OnTrack(((ShoutcastStream)a).StreamTitle); } }; _temp.Play(s); //OnTrack } _radioUrl = url; }
public void PlayFile(string filePath) { lock ( _lockObject ) { if (_filePlayer != null) { _filePlayer.VolumeDownAndStop(); _filePlayer = null; } _filePlayer = new StreamPlayer(this); _filePlayer.OnError += _filePlayer_OnStoped; _filePlayer.OnStartPlay += _filePlayer_OnStartPlay; _filePlayer.OnStoped += _filePlayer_OnStoped; _filePlayer.Play(new FileStream(filePath, FileMode.Open, FileAccess.Read)); } }
public void Play() { underlyingPlayer.Play(); }
private void NextRadio() { // If there is a long file currently playing, store the playback status if (MusicOutput.PlaybackState == PlaybackState.Playing) { Progress[Selected] = MusicFile.CurrentTime; } // Stop the streaming radio and local file Streaming.Stop(); MusicOutput.Stop(); // Is the next radio is vanilla if (Next.Type == RadioType.Vanilla) { Game.RadioStation = (RadioStation)Next.ID; } // If the radio is a single large file else if (Next.Type == RadioType.SingleFile || Next.Type == RadioType.Radio) { Game.RadioStation = RadioStation.RadioOff; if (MusicFile != null) { MusicFile.Dispose(); } if (Next.Type == RadioType.Radio && !CurrentSong.ContainsKey(Next)) { CurrentSong[Next] = Next.Songs[Randomizer.Next(Next.Songs.Count)]; } string SongFile = Next.Type == RadioType.SingleFile ? Next.Location : Next.Location + "\\" + CurrentSong[Next].File; // "The data specified for the media type is invalid, inconsistent, or not supported by this object." with MediaFoundationReader if (Next.CodecFix) { WaveFileReader TempWave = new WaveFileReader(SongFile); MusicFile = WaveFormatConversionStream.CreatePcmStream(TempWave); } else { MusicFile = new MediaFoundationReader(SongFile); } MusicOutput.Init(MusicFile); if (Progress.ContainsKey(Next)) { MusicFile.CurrentTime = Progress[Next]; } else { int RandomPosition = Randomizer.Next((int)MusicFile.TotalTime.TotalSeconds); TimeSpan RandomTimeSpan = TimeSpan.FromSeconds(RandomPosition); MusicFile.CurrentTime = RandomTimeSpan; } MusicOutput.Play(); } // If the radio is a stream else if (Next.Type == RadioType.Stream) { Game.RadioStation = RadioStation.RadioOff; Streaming.Play(Next.Location); } // Set the next radio as the selected one Selected = Next; }
private void PlayCommand_Executed(object sender, ExecutedRoutedEventArgs e) { player.Play(); }
public void Play() { player.Play(); }