Exemple #1
0
 public void switchToAnotherPlayer()
 {
     if (this.myMediaPlayer.GetType() == typeof(MediaPlayerAdapter))
     {
         this.myMediaPlayer = new NAudioAdapter();
         this.isWorking     = true;
         Console.WriteLine("Switching to NAudio...");
     }
     else
     {
         this.myMediaPlayer = new MediaPlayerAdapter();
         this.isWorking     = true;
         Console.WriteLine("Switching to MediaPlayer...");
     }
 }
        private PlayerService()
        {
            Tracks       = new List <Track>();
            CurrentTrack = new Track();

            mediaPlayer  = App.Container.Resolve <IMyMediaPlayer>();
            trackManager = App.Container.Resolve <ITrackManager>();

            RepeatTracks  = false;
            ShuffleTracks = false;

            updateProgressThread = new Thread(updateProgres);
            updateProgressThread.IsBackground = true;
            updateProgressThread.Start();

            Tracks = trackManager.GetAllTracks().GetAwaiter().GetResult();
        }
Exemple #3
0
        public MusicPlayer()
        {
            this.turnedOffState = new TurnedOffState(this);
            this.standbyState   = new StandByState(this);
            this.playingState   = new PlayingState(this);
            this.pausedState    = new PausedState(this);
            this.lockedState    = new LockedState(this);
            this.currentState   = turnedOffState;

            this.currentSongIndex = 0;
            this.songs            = new List <Song>();
            this.myMediaPlayer    = new NAudioAdapter();

            timer           = new Timer();
            timer.Interval  = 1000;
            timer.Elapsed  += OnTimedEvent;
            timer.AutoReset = true;
        }