public void PlaybackInfo(IPlayback data)
 {
     PlaybackComponent = data;
     PlaybackComponent.Play(data);
     output.WriteLine(" playback selected");
     output.WriteInfo();
     PlaybackComponent.Play(data);
     output.WriteLine(" sound");
     Console.ReadKey();
 }
Exemple #2
0
        public void Play()
        {
            if (CurrentTrack == null)
            {
                CurrentTrack = Tracks.First();
            }

            _playback?.Play();
        }
        public void SwitchToPlayback(IPlayback playback, bool resumePlaying)
        {
            if (playback == null)
            {
                throw new ArgumentException("Playback cannot be null");
            }
            // suspend the current one.
            int oldState       = Playback.State;
            int pos            = Playback.CurrentStreamPosition;
            var currentMediaId = Playback.CurrentMediaId;

            Playback.Stop(false);
            Playback.Callback = this;
            Playback.CurrentStreamPosition = pos < 0 ? 0 : pos;
            Playback.CurrentMediaId        = currentMediaId;
            Playback.Start();
            // finally swap the instance
            Playback = playback;
            switch (oldState)
            {
            case PlaybackStateCompat.StateBuffering:
            case PlaybackStateCompat.StateConnecting:
            case PlaybackStateCompat.StatePaused:
                Playback.Pause();
                break;

            case PlaybackStateCompat.StatePlaying:
                MediaSessionCompat.QueueItem currentMusic = queueManager.CurrentMusic;
                if (resumePlaying && currentMusic != null)
                {
                    Playback.Play(currentMusic);
                }
                else if (!resumePlaying)
                {
                    Playback.Pause();
                }
                else
                {
                    Playback.Stop(true);
                }
                break;

            case PlaybackStateCompat.StateNone:
                break;

            default:
                LogHelper.Debug(Tag, "Default called. Old state is ", oldState);
                break;
            }
        }
Exemple #4
0
        static void Main(string[] args)
        {
            SimcorpMobile Phone = new SimcorpMobile();

            Console.WriteLine(Phone);

            IPlayback playbackComponent = GetPlaybackComponent();

            Console.WriteLine($" {playbackComponent} selected");
            Console.WriteLine(" Set playback to Mobile ...");
            Console.WriteLine(" Play sound in Mobile:");
            playbackComponent.Play(new object());

            ICharger chargingDevice = GetChargingDevice();

            chargingDevice.Charge(Phone.Battery);
            Console.ReadKey();
        }
Exemple #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            richTextBox1.Clear();

            IOutput output = new TextBoxOutput(this);

            var       headsetType    = (HeadsetsFactory.HeadsetType)listBox1.SelectedItem;
            var       headsets       = new HeadsetsFactory();
            IPlayback playbackDevice = headsets.GetHeadset(headsetType, output);

            output.Write("Set playback to mobile...");
            playbackDevice.Play(new Sound());

            var          chargerType = (ChargersFactory.ChargerType)listBox2.SelectedItem;
            var          chargers    = new ChargersFactory();
            IPowerSource powerSource = chargers.GetPowerSource(chargerType, 2.4f, 5f);

            output.Write("Charger type:");
            output.Write(powerSource.ToString());
        }
Exemple #6
0
 public static void Play(int stream)
 {
     _Playback.Play(stream);
 }
Exemple #7
0
 public static void Play(int Stream)
 {
     _Playback.Play(Stream);
 }
Exemple #8
0
 public void Play(string data)
 {
     PlaybackComponent.Play(data);
 }
Exemple #9
0
 public void Play(IPlayback playbackDevice, IOutput output)
 {
     output.WriteLine("Play sound in Mobile");
     playbackDevice.Play();
 }
Exemple #10
0
 public void Play(object data)
 {
     PlaybackComponent.Play(data);
 }