public Player() { _player = new WMPPlayer(); _provider = new SoundCloudProvider(); _playlist = new DummyPlaylist(); _ui = new DasPlayer(this); // Hook up some _player events _player.StreamPlayerStateChanged += new PlayerStateChange(_player_StreamPlayerStateChanged); // Hook up playlist events _playlist.TrackChanged += new EventHandler(_playlist_TrackChanged); // Hook up some of the Player UI events _ui.ControlButtonPressed += new UIButtonEvent(ui_ControlButtonPressed); _ui.SearchRequested += new SearchRequested(_ui_SearchRequested); // Hook up the background worker for doing searches _bgSearch = new BackgroundWorker(); _bgSearch.WorkerReportsProgress = false; _bgSearch.WorkerSupportsCancellation = false; _bgSearch.DoWork += new DoWorkEventHandler(_backgroundWorker_DoWork); _bgSearch.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_backgroundWorker_RunWorkerCompleted); // We're nice, we'll poll the timer for the UI and make sure it // gets notified when the progress changes _timer = new Timer(); _timer.AutoReset = true; _timer.Elapsed += new ElapsedEventHandler(_timer_Elapsed); _timer.SynchronizingObject = (Form)_ui; // dirty hackiness }
private void CreateProxy() { string SearchAddress = string.Format("net.tcp://{0}:8000/TcpService", GetSelectedIP()); string StreamingAddress = string.Format("net.tcp://{0}:8001/TcpService", GetSelectedIP()); StreamServerProxy = ServiceProxy.ProxyFactory.CreateProxy<IStreamPlayer>(StreamingAddress); SearchProxy = ServiceProxy.ProxyFactory.CreateProxy<IServiceFacade>(SearchAddress); }
void _player_StreamPlayerStateChanged(IStreamPlayer sender, StreamPlayerState oldState, StreamPlayerState newState) { if (PlayerStateChanged != null) { PlayerStateChanged(this, _player.State); } // This means if we stop playing, and the user didn't initiate it, progress the playlist if( oldState == StreamPlayerState.Playing && newState == StreamPlayerState.NotPlaying && !_userChanging ) { _userChanging = true; _playlist.MoveForwards(); _player.Play(_playlist.Current.StreamURL); _timer.Enabled = true; } else { _userChanging = false; } }