Esempio n. 1
0
        public QuizPage(Quiz temp)
        {
            InitializeComponent();

            quiz = temp;
            temp.NumAttemptsQuiz++;
            scoreCalculation = new int[quiz.NumQuestions];
            for (int i = 0; i < quiz.NumQuestions; i++)
            {
                scoreCalculation[i] = 4;
            }
            QuizTitle.Text           = quiz.QuizName;
            NumCorrect.Text          = "Questions Correct: " + QuestionsCorrect;
            QuestionTitle.Text       = quiz.Questions[QuestionNum].QuestionText;
            One.Text                 = quiz.Questions[QuestionNum].AnswerArray[0];
            Two.Text                 = quiz.Questions[QuestionNum].AnswerArray[1];
            Three.Text               = quiz.Questions[QuestionNum].AnswerArray[2];
            Four.Text                = quiz.Questions[QuestionNum].AnswerArray[3];
            PreviousButton.IsVisible = false;
            try
            {
                player.Load(quiz.Questions[QuestionNum].Audio);
                player.Play();
            }
            catch (Exception ex)
            {
                Console.WriteLine(quiz.Questions[QuestionNum].Audio + " does not exist!");
            }
            user = User.Instance;
        }
Esempio n. 2
0
        public void GOTsounds()
        {
            System.Random RandomNumber = new System.Random();

            string soundName0 = "got_s1e5_pays_his_debts.wav";
            string soundName1 = "got_s1e7_win_or_die.wav";
            string soundPath  = "ArTai.Sounds.GOT.";

            allSounds = CrossSimpleAudioPlayer.CreateSimpleAudioPlayer();

            int soundNumber = RandomNumber.Next(0, 2);         // 2-1 = total streams


            switch (soundNumber)
            {
            case 0:
                var GOT0 = GetStream(soundPath, soundName0);
                allSounds.Load(GOT0);
                break;

            case 1:
                var GOT1 = GetStream(soundPath, soundName1);
                allSounds.Load(GOT1);
                break;

            default:
                break;
            }

            allSounds.Volume = Global.SoundVolume;
            allSounds.Play();
        }
Esempio n. 3
0
        private void BtnAction(int action)
        {
            if (player.IsPlaying)
            {
                player.Stop();
            }

            playSong = false;

            player.Load(GetStreamFromFile(action == 1 ? "effects/good.wav" : "effects/wrong.wav"));

            player.Play();

            if (action == 1)
            {
                userData.Add(randomValue);
                Preferences.Set("userdata", JsonConvert.SerializeObject(userData));

                TextView counter = FindViewById <TextView>(Resource.Id.counterText);

                counter.Text = "Utwór " + userData.Count + "/" + musicTbl.Count;

                if (userData.Count >= musicTbl.Count)
                {
                    EndGame();

                    endingGame = true;

                    return;
                }
            }
        }
Esempio n. 4
0
        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            if (intent == null)
            {
                return(StartCommandResult.NotSticky);
            }

            try
            {
                //要求service 一旦startForegroundService() 启动,必须要在service 中startForeground(),
                //如果在这之前stop 或stopSelf,那就会用crash 来代替ANR
                TryStartForeground(intent);

                //播放MP3
                if (_mediaPlayer != null && !_mediaPlayer.IsPlaying)
                {
                    var assembly = typeof(App).GetTypeInfo().Assembly;
                    var path     = "DCMS.Client.Resources.raw";
                    using (var _audioStream = assembly?.GetManifestResourceStream($"{path}.cactus.mp3"))
                    {
                        if (_audioStream != null)
                        {
                            _mediaPlayer.Load(_audioStream);
                            _mediaPlayer.Loop = true;
                            _mediaPlayer.Play();
                            IsRun = true;
                        }
                    }
                }
            }
            catch (System.InvalidOperationException) { }
            catch (System.Exception) { }

            return(StartCommandResult.Sticky);
        }
Esempio n. 5
0
        public void PlaySelected(int songId)
        {
            SongData selectedSong = (from songs in DBConnection.ctx.SongDatas where songs.SongId == songId select songs).FirstOrDefault();

            player.Load(new MemoryStream(selectedSong.SongBytes));
            player.Play();
        }
Esempio n. 6
0
        public void StartRecording(out int warningStatus)
        {
            if (!IsAuthorized())
            {
                warningStatus = (int)Warning.AccessDenied;
                return;
            }

            var node            = AudioEngine.InputNode;
            var recordingFormat = node.GetBusOutputFormat(0);

            node.InstallTapOnBus(0, 1024, recordingFormat, (AVAudioPcmBuffer buffer, AVAudioTime when) => {
                LiveSpeechRequest.Append(buffer);
            });

            AudioEngine.Prepare();
            NSError error;

            AudioEngine.StartAndReturnError(out error);

            if (error != null)
            {
                Console.WriteLine(strings.speechStartRecordProblem);
                warningStatus = (int)Warning.RecordProblem;
                return;
            }

            // Play start sound
            if (player.IsPlaying)
            {
                player.Stop();
            }
            player.Load("Sounds/siri_start.mp3");
            player.Play();

            RecognitionTask = SpeechRecognizer.GetRecognitionTask(LiveSpeechRequest, (SFSpeechRecognitionResult result, NSError err) =>
            {
                if (err != null)
                {
                    Console.WriteLine(strings.speechRecordError);
                    viewController.ProcessSpeech(null);
                }
                else
                {
                    if (result.Final)
                    {
                        viewController.ProcessSpeech(result.BestTranscription.FormattedString);
                    }
                }
            });

            warningStatus = -1;
        }
Esempio n. 7
0
        private void PlaySound(string rawFileName = "")
        {
            player_.Loop = false;
            var stream = GetStreamFromFile(rawFileName);

            if (stream == null)
            {
                System.Diagnostics.Debug.WriteLine("Failed to to find file");
                return;
            }
            player_.Load(stream);
            player_.Play();
        }
        /// <summary>
        /// Loads the default songs if they are not yet installed.
        /// </summary>
        public static void LoadDefaultSong()
        {
            if (!installedSongs)
            {
                InstallSongs();
                installedSongs = true;
            }

            MusicList musicList  = JsonUtil.GetJsonMusicList();
            Song      s          = musicList.MusicContainer[0];
            Stream    songStream = new MemoryStream(s.Music);

            player.Load(songStream);
        }
Esempio n. 9
0
        public void Friendssounds()
        {
            System.Random RandomNumber = new System.Random();

            string soundName0 = "couldie.wav";
            string soundName1 = "howdoing.wav";
            string soundName2 = "ripped.wav";
            string soundName3 = "secrets.wav";
            string soundName4 = "smellyct.wav";
            string soundPath  = "ArTai.Sounds.friends.";

            allSounds = CrossSimpleAudioPlayer.CreateSimpleAudioPlayer();

            int soundNumber = RandomNumber.Next(0, 5);         // 2-1 = total streams


            switch (soundNumber)
            {
            case 0:
                var FRIENDS0 = GetStream(soundPath, soundName0);
                allSounds.Load(FRIENDS0);
                break;

            case 1:
                var FRIENDS1 = GetStream(soundPath, soundName1);
                allSounds.Load(FRIENDS1);
                break;

            case 2:
                var FRIENDS2 = GetStream(soundPath, soundName2);
                allSounds.Load(FRIENDS2);
                break;

            case 3:
                var FRIENDS3 = GetStream(soundPath, soundName3);
                allSounds.Load(FRIENDS3);
                break;

            case 4:
                var FRIENDS4 = GetStream(soundPath, soundName4);
                allSounds.Load(FRIENDS4);
                break;

            default:
                break;
            }

            allSounds.Volume = Global.SoundVolume;
            allSounds.Play();
        }
 public void PreviousTapped(object sender, EventArgs e)
 {
     try
     {
         Current--;
         player.Load(GetStreamFromFile(Songs[Current].Path));
         PlayTapped(null, null);
         LoadView();
     }
     catch (Exception u)
     {
         Current++;
         LoadView();
     }
 }
Esempio n. 11
0
        //-------------------------------------------------------------------------------------------------------------------------
        public void TickSoundStream()
        {
            var stream = GetStreamFromTickFile("dot.mp3");

            TickSoundPlayer = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.CreateSimpleAudioPlayer();
            TickSoundPlayer.Load(stream);
        }
Esempio n. 12
0
        public void CorrectSoundStream()
        {
            var stream = GetStreamFromCorrectFile("conjure_item.mp3");

            CorrectSoundPlayer = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.CreateSimpleAudioPlayer();
            CorrectSoundPlayer.Load(stream);
        }
Esempio n. 13
0
        //-------------------------------------------------------------------------------------------------------------------------

        public void SkipSoundStream()
        {
            var stream = GetStreamFromSkipFile("igplayerinvitedecline.mp3");

            SkipSoundPlayer = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.CreateSimpleAudioPlayer();
            SkipSoundPlayer.Load(stream);
        }
Esempio n. 14
0
        //-------------------------------------------------------------------------------------------------------------------------
        public void SettingsClosingSoundStream()
        {
            var stream = GetStreamFromSettingsCloseFile("draenei_chest_anims_close.mp3");

            SettingsClosingSoundPlayer = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.CreateSimpleAudioPlayer();
            SettingsClosingSoundPlayer.Load(stream);
        }
Esempio n. 15
0
        //-------------------------------------------------------------------------------------------------------------------------
        public void PlayTheGameSoundStream()
        {
            var stream = GetStreamFromPlayTheGameSoundFile("glueenterworldbutton.mp3");

            PlayGameSoundPlayer = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.CreateSimpleAudioPlayer();
            PlayGameSoundPlayer.Load(stream);
        }
Esempio n. 16
0
 void PlaySound()
 {
     player.Loop   = true;
     player.Volume = 50;
     player.Load(GetStreamFromFile("Fireplace.mp3"));
     player.Play();
 }
Esempio n. 17
0
        //-------------------------------------------------------------------------------------------------------------------------
        public void SettingsSoundStream()
        {
            var stream = GetStreamFromSettingsFile("chestOPEN.mp3");

            SettingsSoundPlayer = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.CreateSimpleAudioPlayer();
            SettingsSoundPlayer.Load(stream);
        }
Esempio n. 18
0
 void PlaySound()
 {
     player.Loop   = true;
     player.Volume = 50;
     player.Load(GetStreamFromFile("RelaxSunset.mp3"));
     player.Play();
 }
Esempio n. 19
0
 public void PlayAreaAmbientSounds(GameView gv, string filenameNoExtension)
 {
     if ((filenameNoExtension.Equals("none")) || (filenameNoExtension.Equals("")) || (!gv.mod.playSoundFx))
     {
         //play nothing
         return;
     }
     else
     {
         if (areaAmbientSoundsPlayer == null)
         {
             areaAmbientSoundsPlayer = CrossSimpleAudioPlayer.CreateSimpleAudioPlayer();
         }
         try
         {
             areaAmbientSoundsPlayer.Loop = true;
             areaAmbientSoundsPlayer.Load(GetStreamFromFile(gv, filenameNoExtension));
             areaAmbientSoundsPlayer.Play();
         }
         catch (Exception ex)
         {
             if (gv.mod.debugMode) //SD_20131102
             {
                 gv.cc.addLogText("<yl>failed to play area music" + filenameNoExtension + "</yl><BR>");
             }
         }
     }
 }
Esempio n. 20
0
        void carregaFase()
        {
            if (Singleton.Instance.dadosJogador.ProgressoFase[this.numeroFase] < 4)
            {
                player.Load(GetStreamFromFile(licoesAExecutar[Singleton.Instance.dadosJogador.ProgressoFase[this.numeroFase]].Audio));
                if (numeroFase >= 2)
                {
                    lblTituloLicao.Text  = "Qual a altura do segundo som?";
                    btnButton1.IsVisible = btnButton2.IsVisible = false;
                    btnButton3.IsVisible = btnButton4.IsVisible = true;
                    player2.Load(GetStreamFromFile(licoesAExecutar[Singleton.Instance.dadosJogador.ProgressoFase[this.numeroFase]].Audio2));
                }
                else
                {
                    lblTituloLicao.Text  = "Que tipo de som você escuta?";
                    btnButton1.IsVisible = btnButton2.IsVisible = true;
                    btnButton3.IsVisible = btnButton4.IsVisible = false;
                }



                validado = false;
                btnButton1.BackgroundColor = btnButton2.BackgroundColor = btnButton3.BackgroundColor = btnButton4.BackgroundColor = Color.Gray;
                stcResult.BackgroundColor  = Color.White;
                btnButton5.Text            = "Verificar";
            }
            else
            {
                Singleton.Instance.dadosJogador.adcionaNovaFase(this.numeroFase);
                Singleton.Instance.Save();
                Singleton.Instance.abrindoTela = false;
                Navigation.PopModalAsync();
            }
        }
Esempio n. 21
0
        private void PlaySound(string soundName)
        {
            ISimpleAudioPlayer player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;

            player.Load(GetStreamFromFile(soundName));
            player.Play();
        }
Esempio n. 22
0
        public Localisation()
        {
            InitializeComponent();

            _bleService = BLEService.Instance();

            _isAlarmStarted = false;
            _isStarted      = false;
            _firstTimer     = 0;

            // Init player
            _player = CrossSimpleAudioPlayer.Current;
            _player.Load("bing.mp3");
            _player.Volume = 1;

            MessagingCenter.Subscribe <BLEService>(this, "deviceConnectionLost", (sender) =>
            {
                OnDeviceDisconnected();
            });

            MessagingCenter.Subscribe <BLEService, CharacteristicUpdatedEventArgs>(this, "characteristicUpdated", (sender, args) =>
            {
                OnCharacteristicUpdated(args);
            });
        }
Esempio n. 23
0
        public GameLogicViewModel()
        {
            resetScore();
            operators = new Operators();
            initialize();
            gameStopWatch = new Stopwatch();
            gameStopWatch.Start();


            CalculateCommand = new Command <string>(EvaluateUserChoice);

            var correctAssembly   = typeof(App).GetTypeInfo().Assembly;
            var inCorrectAssembly = typeof(App).GetTypeInfo().Assembly;

            var correctAudioStream = correctAssembly.GetManifestResourceStream("MinuteMath.DingSound.wav");

            correctDing = CrossSimpleAudioPlayer.CreateSimpleAudioPlayer();
            correctDing.Load(correctAudioStream);


            var incorrectAudioStream = correctAssembly.GetManifestResourceStream("MinuteMath.duck.wav");

            incorrectQuack = CrossSimpleAudioPlayer.CreateSimpleAudioPlayer();
            incorrectQuack.Load(incorrectAudioStream);
        }
Esempio n. 24
0
        public bool Open(string strFile)
        {
            bool bOpen = false;

            bOpen = player.Load(strFile);
            return(bOpen);
        }
Esempio n. 25
0
        //-------------------------------------------------------------------------------------------------------------------------

        public void ScoreSoundStream()
        {
            var stream = GetStreamFromScoreFile("lvlUP.mp3");

            ScoreSoundPlayer = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.CreateSimpleAudioPlayer();
            ScoreSoundPlayer.Load(stream);
        }
Esempio n. 26
0
        private void Button_Clicked(object sender, EventArgs e)
        {
            Button Gumb = sender as Button;

            Posast.Moja_Izbira = Convert.ToInt32(Gumb.Text);

            if (Posast.Preveri_ustreznost())
            {
                var stream = GetStreamFromFile("ja.mp3");
                Igralnik = CrossSimpleAudioPlayer.CreateSimpleAudioPlayer();
                Igralnik.Load(stream);
                Igralnik.Play();
                DisplayAlert("Pošastko sporoča", "BRAVO! Pravilna rešitev!", "Nadaljuj");
                Uredi();
            }

            else
            {
                var stream = GetStreamFromFile("ne.mp3");
                Igralnik = CrossSimpleAudioPlayer.CreateSimpleAudioPlayer();
                Igralnik.Load(stream);
                Igralnik.Play();
                DisplayAlert("Pošastko sporoča", "NAROBE! Rešitev ni pravilna!", "Nadaljuj");
                Uredi();
            }
        }
Esempio n. 27
0
        public async void Play(string pathFile, object alternative = null)
        {
            var file = await StorageFile.GetFileFromPathAsync(pathFile);

            player.Load(await file.OpenStreamForReadAsync());
            player.Play();
        }
Esempio n. 28
0
        private async Task RecordAudio()
        {
            try
            {
                if (!recorder.IsRecording)
                {
                    playRecordingButton.IsEnabled = false;

                    var audiorecordTask = await recorder.StartRecording();

                    startListeningButton.Text = "Stop Listening";

                    audioFile = await audiorecordTask;
                    startListeningButton.Text     = "Start Listening";
                    playRecordingButton.IsEnabled = true;
                    listenlabel.Text = audioFile;
                    //player.Play(audioFile);
                    aplayer.Load(audioFile);
                    aplayer.Play();
                }
                else
                {
                    startListeningButton.IsEnabled = false;
                    await recorder.StopRecording();

                    player.Play(audioFile);
                    startListeningButton.IsEnabled = true;
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Error occured in recording audio.", ex.Message, "OK");
            }
        }
Esempio n. 29
0
 void PlaySound()
 {
     player.Loop   = true;
     player.Volume = 50;
     player.Load(GetStreamFromFile("ForestBird.mp3"));
     player.Play();
 }
        public void PlayAudio(SoundEffectType effect)
        {
            string fileName = "";

            switch (effect)
            {
            case SoundEffectType.FacebookAlert:
                fileName = "~Assets/facebook_sound.mp3";
                break;

            case SoundEffectType.FacebookPop:
                fileName = "~Assets/facebook_pop.mp3";
                break;

            case SoundEffectType.Notification:
                fileName = "";
                break;
            }

            //Platform Specific UWP code for running audio

            ISimpleAudioPlayer player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;

            player.Load(File.OpenRead(fileName));
            player.Play();
        }