示例#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;
        }
示例#2
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;
                }
            }
        }
示例#3
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();
        }
示例#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);
        }
 public void PlayTrack(AudioTrack track)
 {
     CurrentTrack = track;
     _stream      = File.OpenRead(CurrentTrack.StorageLocation);        //GetStreamFromFile(CurrentTrack.StorageLocation);
     _simpleAudioPlayer.Load(_stream);
     _simpleAudioPlayer.Play();
 }
示例#6
0
        public async void Play(string pathFile, object alternative = null)
        {
            var file = await StorageFile.GetFileFromPathAsync(pathFile);

            player.Load(await file.OpenStreamForReadAsync());
            player.Play();
        }
示例#7
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>");
             }
         }
     }
 }
示例#8
0
        private void RunMessageLoop()
        {
            Task.Run(async() =>
            {
                while (this._user != null && this._user.Id > 0)
                {
                    Thread.Sleep(1000);
                    if (this._isBusy)
                    {
                        continue;
                    }
                    var response      = await ClientFactory.Client.Inbox.GetMessages(this._username);
                    this._hasNewer    = response.HasNewer;
                    this._hasOlder    = response.HasOlder;
                    var knownMessages = this._messages.ToList();

                    foreach (var message in response.Messages)
                    {
                        if (knownMessages.Any(m => m.Id == message.Id))
                        {
                            continue;
                        }

                        var last = knownMessages.LastOrDefault(m => m.CreatedAt < message.CreatedAt);
                        if (last == null)
                        {
                            knownMessages.Add(message);
                            Application.Current.Dispatcher.BeginInvokeOnMainThread(() =>
                            {
                                _messages.Add(message);
                                _audio.Play();
                            });
                            continue;
                        }
                        var i = knownMessages.IndexOf(last);

                        knownMessages.Insert(i + 1, message);
                        Application.Current.Dispatcher.BeginInvokeOnMainThread(() =>
                        {
                            _messages.Insert(i + 1, message);
                            _audio.Play();
                        });
                    }

                    Application.Current.Dispatcher.BeginInvokeOnMainThread(() =>
                    {
                        foreach (var message in this._messages.Where(m => m.Id == 0).ToList())
                        {
                            _messages.Remove(message);
                        }
                    });
                }
            });
        }
示例#9
0
        static void PlayFinishedSound(object data)
        {
            CancellationTokenSource cts = cancelSound; // safe copy

            do
            {
                player.Play();

                Thread.Sleep(500);
            } while (!cts.IsCancellationRequested);
        }
示例#10
0
 public void Pause()
 {
     if (player.IsPlaying)
     {
         player.Pause();
     }
     else
     {
         player.Play();
     }
 }
示例#11
0
 private void Errou()
 {
     _countdownThreadSourceToken.Cancel();
     _timeoutPlayer.Play();
     Task.Run(() =>
     {
         _timeoutPlayer.Play();
         Task.Delay(4000).Wait();
         TrocaGrupo();
     });
 }
示例#12
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;
        }
示例#13
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();
        }
示例#14
0
        private void PlayCurrentSound()
        {
            ISimpleAudioPlayer player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;

            player.Stop();
            player.Play();
        }
示例#15
0
 void PlaySound()
 {
     player.Loop   = true;
     player.Volume = 50;
     player.Load(GetStreamFromFile("RelaxSunset.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();
        }
示例#17
0
 private void _AlarmPlayer_PlaybackEnded(object sender, EventArgs e)
 {
     if (IsAlarmEnabled)
     {
         _AlarmPlayer.Play();
     }
 }
示例#18
0
 private void _BeepPlayer_PlaybackEnded(object sender, EventArgs e)
 {
     if (IsBeepEnabled)
     {
         _BeepPlayer.Play();
     }
 }
示例#19
0
 void PlaySound()
 {
     player.Loop   = true;
     player.Volume = 50;
     player.Load(GetStreamFromFile("Fireplace.mp3"));
     player.Play();
 }
示例#20
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");
            }
        }
示例#21
0
 public static void PlayWhoosh()
 {
     if (Preferences.Instance.SoundEffects)
     {
         Whoosh?.Play();
     }
 }
示例#22
0
        private void Button_Clicked(object sender, EventArgs e)
        {
            ISimpleAudioPlayer player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;

            player.Load(GetStreamFromFile("buzzer.mp3"));
            player.Play();
        }
示例#23
0
        private void PlaySound(string soundName)
        {
            ISimpleAudioPlayer player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;

            player.Load(GetStreamFromFile(soundName));
            player.Play();
        }
示例#24
0
 void PlaySound()
 {
     player.Loop   = true;
     player.Volume = 50;
     player.Load(GetStreamFromFile("RainRoof.mp3"));
     player.Play();
 }
示例#25
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();
            }
        }
示例#26
0
 public void PlayCorrect()
 {
     if (Initialized)
     {
         correctPlayer.Play();
     }
 }
示例#27
0
 public static void PlayJingle()
 {
     if (Preferences.Instance.SoundEffects)
     {
         Jingle?.Play();
     }
 }
示例#28
0
 public void PlayWrong()
 {
     if (Initialized)
     {
         wrongPlayer.Play();
     }
 }
示例#29
0
 void PlaySound()
 {
     player.Loop   = true;
     player.Volume = 50;
     player.Load(GetStreamFromFile("ForestBird.mp3"));
     player.Play();
 }
示例#30
0
 public void PlayCongrats()
 {
     if (Initialized)
     {
         congratsPlayer.Play();
     }
 }