public void OnMediaEnded(MediaPlayer mediaPlayer, object args) { while (listPlayMp3.Count() > 0) { var currentUrl = listPlayMp3.Dequeue(); Mp3.play(currentUrl); } }
private void processCustomAction(string main_action, QueryString args) { try { switch (main_action) { case "reload": WordId = int.Parse(args["WordId"]); var _item = DataAccess.GetVocabularyById(WordId); VocabularyToast.loadByVocabulary(_item); _item = null; break; case "play": WordId = int.Parse(args["WordId"]); int playId = int.Parse(args["PlayId"]); if (WordId > 0) { string _mp3Url; if (VocabularyToast.reloadLastToast()) { _mp3Url = args["PlayUrl"]; } else { _item = DataAccess.GetVocabularyById(WordId); VocabularyToast.loadByVocabulary(_item); if (playId == 2) { _mp3Url = _item.PlayURL2; } else { _mp3Url = _item.PlayURL; } } if (!String.IsNullOrEmpty(_mp3Url)) { if (mediaPlayer.PlaybackSession.PlaybackState == MediaPlaybackState.Playing) { listPlayMp3.Enqueue(_mp3Url); } else { checkMediaPlayer(); Mp3.play(_mp3Url); } } } break; case "next": WordId = int.Parse(args["WordId"]); if (WordId > 0) { WordId++; } else { WordId = DataAccess.GetFirstWordId(); } var _item2 = DataAccess.GetVocabularyById(WordId); VocabularyToast.loadByVocabulary(_item2); _item2 = null; break; case "view": string SearchUrl = args["url"]; // The URI to launch var uriBing = new Uri(SearchUrl); // Launch the URI var success = Windows.System.Launcher.LaunchUriAsync(uriBing); break; } } catch (Exception ex) { Helper.ShowToast("Action Background Error: " + ex.Message); } }