void WorldUpdate() { var playerPosition = playerTile.Allocation; //if user is in a foreach (var spike in spikesTiles) { if (spike.Allocation.IntersectsWith(playerPosition)) { PerformPlayerDied(); return; } } foreach (var gem in gemsTiles) { if (gem.Allocation.IntersectsWith(playerTile.Allocation)) { gemsTiles.Remove(gem); gem.Parent.RemoveChild(gem); points++; coinSound.Play(); break; } } pointsLabel.Text = points.ToString(); }
private void Play() { if (_engineSettings.DisableSoundNotifications) { return; } var songToPlay = string.Empty; var repeat = false; switch (_engine.Phase) { case PomodoroPhase.Work: songToPlay = _settings.WorkSong; repeat = _settings.RepeatWorkSong; break; case PomodoroPhase.Break: songToPlay = _settings.BreakSong; repeat = _settings.RepeatBreakSong; break; case PomodoroPhase.BreakEnded: case PomodoroPhase.WorkEnded: break; } if (File.Exists(songToPlay)) { _musicPlayer.Load(songToPlay); _musicPlayer.Play(repeat, _engineSettings.Volume); } }
private void PlayBeatmap(Beatmap map) { var audioLocation = ((BeatmapExtension)map).FullAudioFileLocation(); bool onlineSource = false; if (audioLocation == string.Empty) { if (map.MapSetId <= 20) { return; } onlineSource = true; audioLocation = $@"https://b.ppy.sh/preview/{map.MapSetId}.mp3"; } RunAsWorker(() => { resetEvent.WaitOne(250); if (map.Equals(_model.CurrentBeatmap)) { musicPlayer.Play(audioLocation, _view.IsMusicPlayerMode || onlineSource ? 0 : Convert.ToInt32(Math.Round(map.PreviewTime / 1000f))); } }); }
public override void Execute(IExecutionEnvironment environment, MessageReceivedEvent e, string commandArgs) { if (e.Instigator.VoiceChannel is null) { e.Channel.SendMessageAsync("Вам требуется зайти в какой-либо голосовой канал").RunSync(); return; } IMusicSearchService musicSearchService = environment.GetService <IMusicSearchService>(); IMusicPlayer musicPlayer = environment.GetService <IMusicPlayer>(); string[] results = musicSearchService.GetOrCreateMusicSources(commandArgs).ToArray(); if (results.Length == 0) { e.Channel.SendMessageAsync("Не найдено ни одного результата по данному запросу").RunSync(); return; } string source = results[Random.Next(results.Length)]; musicPlayer.Play(e.Instigator.VoiceChannel, e.Channel, e.GuildId, source); EmbedBuilder builder = new EmbedBuilder(); builder.AddField(Path.GetFileNameWithoutExtension(source), $"Now playing (selected from {results.Length} sources)"); builder.WithColor(Color.Green); e.Channel.SendMessageAsync(null, false, builder.Build()).RunSync(); }
public void Play(string audioFile, int startTime) { Uri uri = new Uri(audioFile); if (uri.HostNameType == UriHostNameType.Dns) { var tempFolderPath = Path.Combine(Path.GetTempPath(), "CM-previews"); Directory.CreateDirectory(tempFolderPath); var directoryInfo = new DirectoryInfo(tempFolderPath); var files = directoryInfo.GetFiles(); if (files.Length > 100) { foreach (var file in files.OrderBy(f => f.LastWriteTimeUtc).Take(30)) { file.Delete(); } } var tempFilePath = Path.Combine(tempFolderPath, uri.Segments.Last()); if (!File.Exists(tempFilePath)) { using (WebClient ws = new WebClient()) { ws.DownloadFile(audioFile, tempFilePath); } } audioFile = tempFilePath; } musicPlayer.Play(audioFile, startTime); }
private void PlaySongAction() { if (PlayingSong.FilePath != SelectedSong.FilePath) { StopSongAction(); PlayingSong = SelectedSong; _playingIndex = SelectedIndex; ArtistAlbumInfo = PlayingSong.Artist + " - " + PlayingSong.Album + " [" + PlayingSong.Year + "]"; TrackTitleInfo = PlayingSong.TrackNumber + ". " + PlayingSong.Title; _player.Play(new Uri(PlayingSong.FilePath)); } else { _player.Play(); } StartTimers(); }
public override void Execute(IExecutionEnvironment environment, MessageReceivedEvent e, string commandArgs) { IMusicSearchService musicSearchService = environment.GetService <IMusicSearchService>(); IMusicPlayer musicPlayer = environment.GetService <IMusicPlayer>(); IEnumerable <string> files = musicSearchService.GetOrCreateMusicSources(commandArgs); if (files.Count() == 0) { e.Channel.SendMessageAsync("Не найдено ни одного результата по данному запросу").RunSync(); return; } EmbedBuilder builder = null; if (files.Count() > 1) { builder = new EmbedBuilder(); builder.WithTitle("Несколько результатов найдено"); builder.WithDescription("Попробуйте указать более точное название"); int counter = 1; int advancedResults = 0; foreach (var file in files) { if (counter < EmbedBuilder.MaxFieldCount - 1) { builder.AddField(counter.ToString() + ".", System.IO.Path.GetFileNameWithoutExtension(file)); } else { ++advancedResults; } ++counter; } if (advancedResults > 0) { builder.AddField($"Ещё результаты ({advancedResults})", "..."); } builder.WithColor(Color.LightGrey); e.Channel.SendMessageAsync(null, false, builder.Build()).RunSync(); return; } if (e.Instigator.VoiceChannel is null) { e.Channel.SendMessageAsync("Вам требуется зайти в какой-либо голосовой канал").RunSync(); return; } string source = musicSearchService.GetOrCreateMusicSources(commandArgs).First(); musicPlayer.Play(e.Instigator.VoiceChannel, e.Channel, e.GuildId, source); builder = new EmbedBuilder(); builder.AddField(Path.GetFileNameWithoutExtension(source), "Now playing"); builder.WithColor(Color.Green); e.Channel.SendMessageAsync(null, false, builder.Build()).RunSync(); }
void PerformPlayerDied() { playerTile.SetPosition(startingPoint); var lastLive = heartTiles.FirstOrDefault(); if (lastLive != null) { heartTiles.Remove(lastLive); lastLive.Parent.RemoveChild(lastLive); } gameOverSound.Play(); }
public void NowPlayingShouldNotChangeIfSongIsAlreadyPlaying(string songTitle1, string songTitle2) { player = new MusicPlayer(mediaDb, soundDb); mediaDb.OpenConnection(); player.LoadSongs(songTitle1); player.LoadSongs(songTitle2); mediaDb.CloseConnection(); // Spelar Stairway to heaven player.Play(); var playing = player.NowPlaying(); StringAssert.Contains(songTitle1, player.NowPlaying(), "Den borde ju spelas"); player.Play(); playing = player.NowPlaying(); StringAssert.Contains(songTitle1, player.NowPlaying(), "Den borde ju spelas"); player.Stop(); }
public void IfNoSongIsPlayingStartNext(string search) { musicPlayer = new MusicPlayer(mediaDb, soundMaker); mediaDb.OpenConnection(); musicPlayer.LoadSongs("Disturbed"); mediaDb.CloseConnection(); int presentSongsInQueue = musicPlayer.NumSongsInQueue; string newActual = ""; StringAssert.Contains("Tystnad Råder", musicPlayer.NowPlaying(), "Det spelades visst en låt!"); musicPlayer.Play(); newActual = musicPlayer.NowPlaying(); //} Assert.Greater(presentSongsInQueue, 0, "No more songs in Playlist"); }
private void PlayBeatmap(Beatmap map) { var audioLocation = ((BeatmapExtension)map).FullAudioFileLocation(); if (audioLocation != string.Empty) { RunAsWorker(() => { resetEvent.WaitOne(250); if (map.Equals(_model.CurrentBeatmap)) { musicPlayer.Play(audioLocation, _view.IsMusicPlayerMode ? 0 : Convert.ToInt32(Math.Round(map.PreviewTime / 1000f))); } }); } }
public void NowPlayingShouldBeCurrentSong() { player = new MusicPlayer(mediaDb, soundDb); mediaDb.OpenConnection(); player.LoadSongs("to"); mediaDb.CloseConnection(); player.Play(); //Jag hade tänkt att hämta defaultSong från musicplayer, men det gick ej då det strider mot Interfacet. //Antog att det inte var okej att lägga till en property där, därav upprepningen. string actual = player.NowPlaying(); player.Stop(); Assert.AreNotEqual(defaultSong, actual, "Tystnad ska ej råda"); }
public GameWindow(Rectangle rect) : base(rect) { Resizable = false; //we get the default basic view converters from the current loaded toolkit var converters = FigmaSharp.AppContext.Current.GetFigmaConverters(); //in this case we want use a remote file provider (figma url from our document) var fileProvider = new FigmaRemoteFileProvider(); fileProvider.Load("Jv8kwhoRsrmtJDsSHcTgWGYu"); //we initialize our renderer service, this uses all the converters passed //and generate a collection of NodesProcessed which is basically contains <FigmaModel, IView, FigmaParentModel> var rendererService = new FigmaViewRendererService(fileProvider, converters); //play background music backgroundMusic = new MusicPlayer("Background", "mp3"); backgroundMusic.Play(-1); coinSound = new MusicPlayer("Coin", "mp3"); gameOverSound = new MusicPlayer("GameOver", "mp3"); //we want load the entire level 1 IView view = rendererService.RenderByName <IView>("Level1"); Content = view; playerTile = rendererService.FindViewStartsWith <IImageView>("Player"); startingPoint = playerTile.Allocation.Origin; pointsLabel = rendererService.FindViewByName <ILabel>("Points"); gemsTiles = rendererService.FindViewsStartsWith <IImageView>("Gem") .ToList(); wallTiles = rendererService.FindViewsStartsWith <IImageView>("Tile") .ToArray(); spikesTiles = rendererService.FindViewsStartsWith <IImageView>("Spikes") .ToArray(); heartTiles = rendererService.FindViewsStartsWith <IImageView>("Heart") .OrderBy(s => s.Allocation.X) .ToList(); WorldUpdate(); }
public void ManualUpdate() { if (fadeDelayCountdown > 0) { fadeDelayCountdown -= Time.unscaledDeltaTime; } else { if (isPlaying && !player.isPlaying) { player.Play(); } if (!isPlaying && player.isPlaying && player.volume <= 0) { player.Stop(); } float volumeDelta = fadeSpeed.HasValue ? Time.unscaledDeltaTime * fadeSpeed.Value : 1000f; player.volume = Mathf.MoveTowards(player.volume, destinationVolume, volumeDelta); } }
public void StopThePlayingOfSongButKeepSongList(string search) { musicPlayer = new MusicPlayer(mediaDb, soundMaker); mediaDb.OpenConnection(); musicPlayer.LoadSongs("Mustasch"); mediaDb.CloseConnection(); int presentSongsInQueue = musicPlayer.NumSongsInQueue; musicPlayer.Play(); string actual = musicPlayer.NowPlaying(); musicPlayer.Stop(); Assert.AreNotEqual(defaultSong, actual, "Tystnad ska inte råda"); string newActual = musicPlayer.NowPlaying(); //} Assert.Greater(presentSongsInQueue, 0, "No more songs in Playlist"); }
private void OnLoaded(object @object, RoutedEventArgs routedEventArgs) { Loaded -= OnLoaded; ClientSettings.Current.Saved += (s, e) => CheckFullScreenSettings(); ClientSettings.Current.Loaded += (s, e) => CheckFullScreenSettings(); _eventAggregator.GetEvent <ViewActivatingEvent>().Subscribe(OnViewActivating, ThreadOption.PublisherThread); _audioEngine.Volume = (float)ClientSettings.Current.MasterVolume; _musicPlayer.Volume = (float)ClientSettings.Current.MusicVolume; _soundPlayer.Volume = (float)ClientSettings.Current.FXVolume; ClientSettings.Current.MasterVolumeChanged += (s, e) => _audioEngine.Volume = (float)e.NewValue; ClientSettings.Current.MusicVolumeChanged += (s, e) => _musicPlayer.Volume = (float)e.NewValue; ClientSettings.Current.FXVolumeChanged += (s, e) => _soundPlayer.Volume = (float)e.NewValue; _audioEngine.Start(); _musicPlayer.PlayMode = PlaybackMode.Sequential | PlaybackMode.Fade; _musicPlayer.SwitchMusic("DefaultMusic"); _musicPlayer.Play(); }
/// <summary> /// Play the next track in the queue. /// </summary> /// <returns>The track that will be played.</returns> /// <exception cref="InvalidTrackException">Thrown if the track is not of the correct type for the player.</exception> public async Task <IPlayable> PlayNext() { IPlayable track; try { track = _queue.Dequeue(_guild); } catch (InvalidOperationException) { await Leave(_player.VoiceChannel); return(null); } if (!_player.IsConnected) { await _player.Join(track.Requester.VoiceChannel); } await _player.Play(track); return(track); }
public virtual void Play(SongInformation song) { _player.Play(song); }
private void PlayPeriodStart() { _musicPlayer.Load(_settings.PeriodStartSound); _musicPlayer.Play(volume: _engineSettings.Volume); }
public void Play(string audioFile, int startTime) { musicPlayer.Play(audioFile, startTime); }