Exemple #1
0
        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;
        }
Exemple #2
0
        //void DowloadAndPlayYoutube(string code) {
        //    MemoryStream ms = new MemoryStream();
        //    VideoInfo audio;
        //    try {
        //        string link = "http://www.youtube.com/watch?v=" + code;
        //        IEnumerable<VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls( link, false );

        //        audio = (from b in videoInfos
        //                           orderby b.AudioBitrate descending
        //                           where b.CanExtractAudio
        //                           select b).First();

        //        if ( audio.RequiresDecryption )
        //            DownloadUrlResolver.DecryptDownloadUrl( audio );

        //        var downloader = new MemoryAudioDownloader( audio, ms );
        //        downloader.Execute();
        //        // ms.Position = 0;

        //        ms = new MemoryStream( ms.ToArray() );
        //    } catch ( Exception erer) {
        //        _currentYoutubeThread = null;

        //        nextFile();
        //        return;
        //    }

        //    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;

        //        if ( OnTrack != null )
        //            OnTrack( audio.Title );
        //        _filePlayer.Play( ms );
        //    }
        //}

        public void CancelCurrentTrack()
        {
            if (_filePlayer != null)
            {
                _filePlayer.VolumeDownAndStop();
                _filePlayer = null;
            }
        }
Exemple #3
0
        public void StopRadio()
        {
            if (_oldPlayer != null)
            {
                _oldPlayer.VolumeDownAndStop();
                _oldPlayer = null;
            }

            if (_temp != null)
            {
                _temp.VolumeDownAndStop();
                _temp = null;
            }
        }