Exemple #1
0
        public static bool Init()
        {
            if (_Playback != null)
            {
                return(false);
            }
            switch (CConfig.Config.Sound.PlayBackLib)
            {
            case EPlaybackLib.PortAudio:
                _Playback = new CPortAudioPlay();
                break;

            case EPlaybackLib.OpenAL:
                _Playback = new COpenALPlay();
                break;

            case EPlaybackLib.GstreamerSharp:
                _Playback = new CGstreamerSharpAudio();
                break;

            default:
                _Playback = new CPortAudioPlay();
                break;
            }
            return(_Playback.Init());
        }
Exemple #2
0
        public SimCorpMobile(IPlayback headset, ICharger charger, IOutput output)
        {
            var type        = BatteryBase.BatteryTypes.LithiumIonBattery;
            int capacityMAh = 2200;

            vBattery = new BatteryBase(type, capacityMAh);

            string number = "+380959992299";
            var    format = SimcardBase.SimFormats.Nano;

            vSimcard = new SimcardBase(number, format);

            vCamera = new Camera
            {
                MegaPixels     = 2000,
                IndivPixelSize = 1000,
                LensType       = Camera.LensTypes.Dual,
                ZoomType       = Camera.ZoomTypes.Optical
            };
            vScreen = new ScreenBase
            {
                HorizontalPixels = 640,
                VerticalPixels   = 960,
                Diagonal         = 3.5,
                ScreenType       = ScreenBase.ScreenTypes.LCD
            };

            vOutput  = output;
            vHeadSet = headset;
            vCharger = charger;
        }
Exemple #3
0
 public void DoorBell()
 {
     lock (lockObjectForSound)
     {
         stream = Context.GetPlugin<AudioPlugin>().Play(TmpResources.doorbell, 3);
     }
 }
        public static IPlayback GetPlayback(int headsetType)
        {
            IPlayback playback = null;

            switch (headsetType)
            {
            case 1:
                playback = new iPhoneHeadset(new ConsoleOutput());
                break;

            case 2:
                playback = new SamsungHeadset(new ConsoleOutput());
                break;

            case 3:
                playback = new UnoffocoaliPhoneHeadset(new ConsoleOutput());
                break;

            case 4:
                playback = new PhoneSpeaker(new ConsoleOutput());
                break;

            default:
                throw new ArgumentException("Invalis headset type");
            }
            return(playback);
        }
Exemple #5
0
 public static void AddOutgoingConnections(this IPlayback playback, IEnumerable <IOutputAudioDevice> devices)
 {
     foreach (var device in devices)
     {
         playback.AddOutgoingConnection(device);
     }
 }
        public static IPlayback GetPlaybackType(HeadSetTypes headSetType)
        {
            IPlayback playback = null;
            IOutput   output   = new TextBoxOutput();

            switch (headSetType)
            {
            case HeadSetTypes.iPhoneHeadset:
                playback = new iPhoneHeadset(output);
                break;

            case HeadSetTypes.SamsungHeadset:
                playback = new SamsungHeadset(output);
                break;

            case HeadSetTypes.UnofficialiPhoneHeadset:
                playback = new UnofficialiPhoneHeadset(output);
                break;

            case HeadSetTypes.PhoneSpeaker:
                playback = new PhoneSpeaker(output);
                break;

            default:
                throw new ArgumentException("Invalid playback type");
            }
            return(playback);
        }
Exemple #7
0
        public IPlayback SelectPlaybackComponent(ConsoleOutput consoleOutput)
        {
            Console.Clear();
            string playbackIndex = consoleOutput.GetChosenIndex(playbackComponent);

            switch (playbackIndex)
            {
            case "1":
                playbackComponent = new iPhoneHeadset(consoleOutput);
                break;

            case "2":
                playbackComponent = new SamsungHeadset(consoleOutput);
                break;

            case "3":
                playbackComponent = new UnofficialiPhoneHeadset(consoleOutput);
                break;

            case "4":
                playbackComponent = new PhoneSpeaker(consoleOutput);
                break;

            default:
                consoleOutput.WriteLine("Unknown playback component selected, please select component from the list.");
                consoleOutput.WriteLine("Press any key to continue...");
                Console.ReadKey();
                playbackComponent = SelectPlaybackComponent(consoleOutput);
                break;
            }
            return(playbackComponent);
        }
Exemple #8
0
 public void DoorBell()
 {
     lock (lockObjectForSound)
     {
         stream = Context.GetPlugin <AudioPlugin>().Play(TmpResources.doorbell, 3);
     }
 }
Exemple #9
0
 public static void ClearOutgoingConnections(this IPlayback playback)
 {
     foreach (var audioDevice in playback.OutgoingConnections.ToArray())
     {
         playback.RemoveOutgoingConnection(audioDevice);
     }
 }
Exemple #10
0
        private void radioButton_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton radioButton = (RadioButton)sender;

            if (!radioButton.Checked)
            {
                return;
            }

            switch (radioButton.Name)
            {
            case nameof(iPhoneHeadsetRB):
                Playback = new iPhoneHeadset(Output);
                break;

            case nameof(SamsungHeadsetRB):
                Playback = new SamsungHeadset(Output);
                break;

            case nameof(UnofficialiPhoneHeadsetRB):
                Playback = new UnofficialiPhoneHeadset(Output);
                break;

            case nameof(PhoneSpeakerRB):
                Playback = new SamsungHeadset(Output);
                break;

            default:
                throw new ArgumentException();
            }

            Output.WriteLine(radioButton.Name + " playback selected");
        }
Exemple #11
0
        public static IPlayback GetHeadset(Headsets headsets, IOutput output)
        {
            IPlayback playback = null;

            switch (headsets)
            {
            case Headsets.iPhoneHeadset:
                playback = new iPhoneHeadset(output);
                break;

            case Headsets.SamsungHeadset:
                playback = new SamsungHeadset(output);
                break;

            case Headsets.UnofficialiPhoneHeadset:
                playback = new UnofficialiPhoneHeadset(output);
                break;

            case Headsets.PhoneSpeaker:
                playback = new PhoneSpeaker(output);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(playback);
        }
Exemple #12
0
        static void Main(string[] args)
        {
            ConsoleOutput      consoleOutput = new ConsoleOutput();
            SimCorpMobilePhone mobile        = new SimCorpMobilePhone();

            consoleOutput.WriteLine(mobile.GetDescription());
            consoleOutput.WriteLine("Press any key to continue...");
            Console.ReadKey();
            var       consolePlaybackComponent = new ConsolePlaybackComponent();
            IPlayback playbackComponent        = consolePlaybackComponent.SelectPlaybackComponent(consoleOutput);

            mobile.PlaybackComponent = playbackComponent;
            consoleOutput.WriteLine("Set playback to Mobile...");
            mobile.Play();
            consoleOutput.WriteLine("Press any key to continue...");
            Console.ReadKey();
            var consoleChargerComponent = new ConsoleChargeComponent();

            mobile.ChargerComponent = consoleChargerComponent.SelectChargerComponent(consoleOutput);
            consoleOutput.WriteLine("Set charger to Mobile...");
            mobile.Charge();
            consoleOutput.WriteLine("Press any key to continue...");
            Console.ReadKey();
            Console.Clear();
            consoleOutput.WriteLine(mobile.GetDescription());
        }
        public void RemovePlayback(IPlayback playback)
        {
            Playbacks.Remove(playback);

            var disposable = playback as IDisposable;

            disposable?.Dispose();
        }
Exemple #14
0
 public static void Close()
 {
     if (_Playback != null)
     {
         _Playback.Close();
     }
     _Playback = null;
 }
Exemple #15
0
        public void PlaySound()
        {
            lock (lockObjectForSound)
            {
                StopSound();

                Logger.Info("Play sound");
                playback = Context.GetPlugin <AudioPlugin>().Play(SoundResources.Ring02, 25);
            }
        }
 public void PlaybackInfo(IPlayback data)
 {
     PlaybackComponent = data;
     PlaybackComponent.Play(data);
     output.WriteLine(" playback selected");
     output.WriteInfo();
     PlaybackComponent.Play(data);
     output.WriteLine(" sound");
     Console.ReadKey();
 }
		public void PlaySound()
		{
			lock (lockObjectForSound)
			{
				StopSound();

				Logger.Info("Play sound");
				playback = Context.GetPlugin<AudioPlugin>().Play(SoundResources.Ring02, 25);
			}
		}
        private void SetPlayback(IPlayback playback)
        {
            Output.WriteLine($"{playback.GetType().Name} playback selected");
            Output.WriteLine("Set playback to mobile...");
            Mobile.PlaybackComponent = playback;
            Output.WriteLine("Play sound in mobile:");
            var data = new object();

            Mobile.Play(data);
            Output.WriteLine("");
        }
        public static IPlayback GetPlayback(headsetTypik headsetType, IOutput output)
        {
            string typeName = headsetType.ToString();

            typeName = "SimCorp.IMS.MobilePhoneLibrary.MobilePhoneComponents.Headset." + typeName;
            Type      hType            = Type.GetType(typeName);
            object    HeadsetComponent = Activator.CreateInstance(hType, output);
            IPlayback headset          = HeadsetComponent as IPlayback;

            return(headset);
        }
		public void StopSound()
		{
			lock (lockObjectForSound)
			{
				if (playback != null)
				{
					Logger.Info("Stop all sounds");
					playback.Stop();
					playback = null;
				}
			}
		}
Exemple #21
0
        private void ApplyButton_Click(object sender, EventArgs e)
        {
            var output      = new LabelOutput(OutputLabel);
            var smsStorage  = new MessageStorage();
            var mobilePhone = new MobilePhone(Model.Iphone10, output, smsStorage);

            output.WriteLine(mobilePhone.GetDescription());

            var choice = -1;

            if (HeadPhonesRadioButton.Checked)
            {
                choice = 1;
            }
            if (SpeakersRadioButton.Checked)
            {
                choice = 2;
            }
            if (PhoneSpeakerRadioButton.Checked)
            {
                choice = 3;
            }

            IPlayback audioDevice = null;

            if (choice == -1)
            {
                return;
            }

            if (choice == 1)
            {
                audioDevice = new Headphones(output);
            }
            else if (choice == 2)
            {
                audioDevice = new Speakers(false, output);
            }
            else if (choice == 3)
            {
                audioDevice = new PhoneSpeaker(output);
            }
            else
            {
                output.Write("No Valid channel selected");
            }

            if (audioDevice != null)
            {
                mobilePhone.InsertEquipmentInJackStick(audioDevice);
                mobilePhone.AudioInJackStik.Play(new object());
            }
        }
        private void buttonPlaybackUnplug_Click(object sender, System.EventArgs e)
        {
            IPlayback unpluggedPlayback = mobile.PlaybackComponent;

            mobile.PlaybackComponent = null;
            if (unpluggedPlayback != null)
            {
                output.WriteLine($"{unpluggedPlayback.GetType().Name} unplugged.");
            }

            UpdateOutputEnabled();
        }
Exemple #23
0
 public void StopSound()
 {
     lock (lockObjectForSound)
     {
         if (playback != null)
         {
             Logger.Info("Stop all sounds");
             playback.Stop();
             playback = null;
         }
     }
 }
Exemple #24
0
        public static void Dispose(this IPlayback playback)
        {
            var disposable = playback as IDisposable;

            if (disposable != null)
            {
                disposable.Dispose();
                return;
            }

            playback.Stop();
            playback.ClearOutgoingConnections();
        }
Exemple #25
0
        public override void Load()
        {
            switch (_sequence.MusicType)
            {
            case MusicType.Sample:
                _playback = new MCIPlayback();
                break;

            case MusicType.MIDI:
                _playback = new MIDIPlayback();
                break;
            }
        }
Exemple #26
0
 public void StopDoorBell()
 {
     if (stream != null)
     {
         lock (lockObjectForSound)
         {
             if (stream != null)
             {
                 stream.Stop();
                 stream = null;
             }
         }
     }
 }
Exemple #27
0
        internal string GetChosenIndex(IPlayback playbackComponent)
        {
            var text = new StringBuilder();

            text.Append("Select playback component (specify index): " + System.Environment.NewLine);
            text.Append("1 - iPhoneHeadset" + System.Environment.NewLine);
            text.Append("2 - SamsungHeadset" + System.Environment.NewLine);
            text.Append("3 - UnofficialiPhoneHeadset" + System.Environment.NewLine);
            text.Append("4 - PhoneSpeaker");
            Console.WriteLine(text.ToString());
            string playbackIndex = Console.ReadLine();

            return(playbackIndex);
        }
        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 #29
0
        private void OnCurrentTrackChanged(ITrackInfo oldTrack, ITrackInfo newTrack)
        {
            if (_playback != null)
            {
                _playback.Ended -= OnCurrentTrackEnded;
                _playback.Dispose();
            }

            _playback        = _audioHub.CreatePlayback(newTrack.Uri);
            _playback.Name   = _playback.Name ?? newTrack.Name;
            _playback.Volume = Volume;
            _playback.Ended += OnCurrentTrackEnded;
            _playback.AddOutgoingConnections(OutgoingConnections);
        }
Exemple #30
0
        public static IPlayback GetHeadSet(IOutput outputType, HeadsetTypes hsType)
        {
            IPlayback headset = null;

            switch (hsType)
            {
            case HeadsetTypes.iPhone: { headset = new iPhoneHeadset(outputType); break; }

            case HeadsetTypes.Samsung: { headset = new SamsungHeadset(outputType);  break; }

            case HeadsetTypes.EarForceStealth: { headset = new EarForceStealthHeadset(outputType); break; }
            }
            return(headset);
        }
 private void SetHeadSetType()
 {
     if (this.rbHeadSetiPhone.Checked)
     {
         vHeadset = HeadsetFactory.GetHeadSet(this.vOutputType, HeadsetTypes.iPhone);
     }
     else if (this.rbHeadSetSamsung.Checked)
     {
         vHeadset = HeadsetFactory.GetHeadSet(this.vOutputType, HeadsetTypes.Samsung);
     }
     else if (this.rbHeadSetEFStealth.Checked)
     {
         vHeadset = HeadsetFactory.GetHeadSet(this.vOutputType, HeadsetTypes.EarForceStealth);
     }
 }
        static void Main(string[] args)
        {
            ConsoleOutput outputType = new ConsoleOutput();

            HeadsetTypes inputHSType   = ReadHeadSet(outputType);
            ChargerTypes inputChrgType = ReadCharger(outputType);

            IPlayback headset = HeadsetFactory.GetHeadSet(outputType, inputHSType);
            ICharger  charger = ChargerFactory.GetCharger(inputChrgType);

            var mymobile = new SimCorpMobile(headset, charger, outputType);

            Console.WriteLine(mymobile);
            Console.ReadKey();
        }
Exemple #33
0
        private static Mobile InstantiateSimCorpMobile(IOutput myOutputType)
        {
            Mobile mobile = null;

            ICharger  Charger = ChargerFactory.GetCharger(ChargerTypes.Powerbk);
            IPlayback Headset = HeadsetFactory.GetHeadSet(myOutputType, HeadsetTypes.iPhone);

            if (Charger != null)
            {
                if (Headset != null)
                {
                    mobile = new SimCorpMobile(Headset, Charger, myOutputType);
                }
            }
            return(mobile);
        }
Exemple #34
0
        public static bool PlaybackInit()
        {
            switch (CConfig.PlayBackLib)
            {
                case EPlaybackLib.PortAudio:
                    _Playback = new CPortAudioPlay();
                    break;

                case EPlaybackLib.OpenAL:
                    _Playback = new COpenALPlay();
                    break;

                default:
                    _Playback = new CPortAudioPlay();
                    break;
            }
            return true;
        }
 public void SetPlaybackControl(IPlayback playback)
 {
     playbackControl = playback; ;
 }
Exemple #36
0
		public void StopDoorBell()
		{
			if (stream != null)
			{
				lock (lockObjectForSound)
				{
					if (stream != null)
					{
						stream.Stop();
						stream = null;
					}
				}
			}
		}