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; }
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; } } }
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(); }
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(); }
public async void Play(string pathFile, object alternative = null) { var file = await StorageFile.GetFileFromPathAsync(pathFile); player.Load(await file.OpenStreamForReadAsync()); player.Play(); }
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>"); } } } }
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); } }); } }); }
static void PlayFinishedSound(object data) { CancellationTokenSource cts = cancelSound; // safe copy do { player.Play(); Thread.Sleep(500); } while (!cts.IsCancellationRequested); }
public void Pause() { if (player.IsPlaying) { player.Pause(); } else { player.Play(); } }
private void Errou() { _countdownThreadSourceToken.Cancel(); _timeoutPlayer.Play(); Task.Run(() => { _timeoutPlayer.Play(); Task.Delay(4000).Wait(); TrocaGrupo(); }); }
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; }
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(); }
private void PlayCurrentSound() { ISimpleAudioPlayer player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current; player.Stop(); player.Play(); }
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(); }
private void _AlarmPlayer_PlaybackEnded(object sender, EventArgs e) { if (IsAlarmEnabled) { _AlarmPlayer.Play(); } }
private void _BeepPlayer_PlaybackEnded(object sender, EventArgs e) { if (IsBeepEnabled) { _BeepPlayer.Play(); } }
void PlaySound() { player.Loop = true; player.Volume = 50; player.Load(GetStreamFromFile("Fireplace.mp3")); player.Play(); }
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"); } }
public static void PlayWhoosh() { if (Preferences.Instance.SoundEffects) { Whoosh?.Play(); } }
private void Button_Clicked(object sender, EventArgs e) { ISimpleAudioPlayer player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current; player.Load(GetStreamFromFile("buzzer.mp3")); player.Play(); }
private void PlaySound(string soundName) { ISimpleAudioPlayer player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current; player.Load(GetStreamFromFile(soundName)); player.Play(); }
void PlaySound() { player.Loop = true; player.Volume = 50; player.Load(GetStreamFromFile("RainRoof.mp3")); player.Play(); }
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(); } }
public void PlayCorrect() { if (Initialized) { correctPlayer.Play(); } }
public static void PlayJingle() { if (Preferences.Instance.SoundEffects) { Jingle?.Play(); } }
public void PlayWrong() { if (Initialized) { wrongPlayer.Play(); } }
void PlaySound() { player.Loop = true; player.Volume = 50; player.Load(GetStreamFromFile("ForestBird.mp3")); player.Play(); }
public void PlayCongrats() { if (Initialized) { congratsPlayer.Play(); } }