void PlayRecord_GotFocused(IFocusable sender, FocusEventArgs args) { if (args.FocusObject is LeftMenu lm) { songname.Text = lm.SelectedSongInformation.DirectoryName; songname.Position = new Vector2(750 - songname.Width, songname.Position.Y); selectedSongInformation = lm.SelectedSongInformation; results = PPDFramework.ResultInfo.GetInfoFromSongInformation(lm.SelectedSongInformation); Array.Reverse(results); graphDrawType = GraphDrawType.Score; selectedDifficulty = Difficulty.Extreme; int iter = 0; while (!CheckExist() && iter < 4) { selectedDifficulty++; if (selectedDifficulty >= Difficulty.Other) { selectedDifficulty = Difficulty.Easy; } iter++; } ChangeResultTableDifficulty(); ChangeGraphData(); ChangeResultTable(); } }
public IMovie GetMovie(SongInformation songInformation) { if (songInformation == null) { return(null); } CurrentSong = songInformation; var filename = songInformation.MoviePath; if (PPDSetting.Setting.IsMovie(filename)) { switch (PPDSetting.Setting.MoviePlayType) { /*case MoviePlayType.VMR9: * CurrentPlayerBase = new VMR9Movie(device, ((PPDFramework.DX9.PPDDevice)device).D3D, filename); * break;*/ default: CurrentPlayerBase = new SampleGrabberMovie(device, filename); break; } } else { CurrentPlayerBase = new MusicPlayer(device, filename); } CurrentPlayerBase.UserVolume = songInformation.UserVolume; return(CurrentPlayerBase); }
void MoviePanel_Inputed(IFocusable sender, InputEventArgs args) { if (args.InputInfo.IsPressed(ButtonType.Up)) { CurrentThumbList.CurrentIndex--; if (CurrentThumbList.CurrentIndex < 0) { CurrentThumbList.CurrentIndex = 0; } else { sound.Play(PPDSetting.DefaultSounds[0], -1000); } updateCount = 0; } else if (args.InputInfo.IsPressed(ButtonType.Down)) { CurrentThumbList.CurrentIndex++; if (CurrentThumbList.CurrentIndex >= currentParent.ChildrenCount) { CurrentThumbList.CurrentIndex = currentParent.ChildrenCount - 1; } else { sound.Play(PPDSetting.DefaultSounds[0], -1000); } updateCount = 0; } else if (args.InputInfo.IsPressed(ButtonType.Circle)) { if (currentParent.Children.Length == 0) { return; } if (!PlayMovie()) { SongInformation current = currentParent.Children[CurrentThumbList.CurrentIndex]; sound.Play(PPDSetting.DefaultSounds[1], -1000); AddThumbs(current); } updateCount = 0; } else if (args.InputInfo.IsPressed(ButtonType.Cross)) { if (currentParent.Parent != null) { currentParent = currentParent.Parent; removeList.Add(thumbSprite[thumbSprite.ChildrenCount - 1] as ThumbList); sound.Play(PPDSetting.DefaultSounds[2], -1000); } updateCount = 0; } else if (args.InputInfo.IsPressed(ButtonType.Start)) { if (playing) { FocusManager.Focus(movieController); } } }
private bool PlayMovie() { SongInformation current = currentParent.Children[CurrentThumbList.CurrentIndex]; if (current.IsPPDSong) { if (currentPlaying != current) { StopMovie(); var movie = myGame.GetMovie(current); var moviePlayer = new MoviePlayer(device, movie, current, CurrentThumbList[CurrentThumbList.CurrentIndex] as LoadablePictureComponent); moviePlayer.PlayNext += moviePlayer_PlayNext; movieSprite.AddChild(moviePlayer); playing = true; currentPlaying = current; movieController.MoviePlayer = moviePlayer; if (FocusManager.CurrentFocusObject != movieController) { FocusManager.Focus(movieController); } } return(true); } return(false); }
private void Initialize() { SongInformation.Updated += SongInformation_Updated; currentParent = SongInformation.Root; AddThumbs(currentParent); initialized = true; }
private async void PlayList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args) { var playbackItem = args.NewItem; await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => this.CurrentMediaPlaybackItem = playbackItem); if (playbackItem != null) { await SetCurrentSong(playbackItem.GetDisplayProperties()); } else { await SetCurrentSong(null); } async Task SetCurrentSong(MediaItemDisplayProperties displayPropertys) { if (this.Dispatcher.HasThreadAccess) { if (displayPropertys != null) { this.CurrentSong = await SongInformation.Create(displayPropertys.MusicProperties.AlbumTitle, string.IsNullOrWhiteSpace(displayPropertys.MusicProperties.Artist)?displayPropertys.MusicProperties.AlbumArtist : displayPropertys.MusicProperties.Artist, displayPropertys.MusicProperties.Title, displayPropertys.Thumbnail); } else { this.CurrentSong = null; } } else { await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => await SetCurrentSong(displayPropertys)); } } }
/// <summary> /// 下のディレクトリに進む /// </summary> public void GoDownDirectory() { if (!CanGoDown) { return; } switch (mode) { case Mode.SongInfo: currentRoot = SelectedSongInformation.SongInfo; songSelect.Index = 0; GenerateSelectSongs(); break; case Mode.LogicFolder: currentLogicRoot = (SelectedSongInformation as LogicSelectedSongInfo).LogicFolderInfomation; logicSelect.Index = 0; GenerateSelectLogics(); break; case Mode.Contest: case Mode.ActiveScore: break; case Mode.List: currentList = (SelectedSongInformation as ListInfoSelectedSongInfo).ListInfo; listInfoSelect.Index = 0; GenerateSelectLists(); break; } OnDirectoryChanged(); OnSongChanged(SongChangeMode.Reset); }
/// <summary> /// Play the song. /// </summary> /// <param name="song">The song.</param> public override void Play(SongInformation song) { if (!song.IsInternetLocation) { var filePath = $"{Environment.GetFolderPath(Environment.SpecialFolder.MyMusic)}\\Music player downloaded files\\{song.FileName}"; Directory.CreateDirectory(Path.GetDirectoryName(filePath)); song.Location = filePath; song.DateAdded = DateTime.Now; try { using (var fileStream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None)) { fileStream.Write(song.File, 0, song.File.Length); } } catch (Exception e) { Logger.LogError(e, "Could not write file"); } } song.File = null; base.Play(song); var position = _server.GetCurrentPosition(); if (position > 0) { base.MoveToTime(Convert.ToInt64(position)); } }
/// <summary> /// Play a song from an online location. /// </summary> /// <param name="url">The url.</param> public void Play(string url) { DisposeWaveOut(true); _playStream?.Dispose(); try { var radio = Factory.GetRadioInfo().GetStation(url).Result; _currentSong = radio != null ? new SongInformation(radio) : _sourceList.FirstOrDefault(sl => sl.Location == url); if (_currentSong == null) { throw new ArgumentException("The url must be known"); } Task.Run(() => { _playStream = new MediaFoundationReader(url); _waveOutDevice.Init(_playStream); }).Wait(1000); TogglePlay(pause: false); } catch (Exception e) { Logger.LogError(e, "Could not connect to url: " + url); } }
public void ChangeSongInfo(SongInformation songinfo) { this.songinfo = songinfo; if (!songinfo.IsPPDSong) { return; } exist = new bool[6]; exist[0] = true; exist[1] = (songinfo.Difficulty & SongInformation.AvailableDifficulty.Easy) == SongInformation.AvailableDifficulty.Easy; exist[2] = (songinfo.Difficulty & SongInformation.AvailableDifficulty.Normal) == SongInformation.AvailableDifficulty.Normal; exist[3] = (songinfo.Difficulty & SongInformation.AvailableDifficulty.Hard) == SongInformation.AvailableDifficulty.Hard; exist[4] = (songinfo.Difficulty & SongInformation.AvailableDifficulty.Extreme) == SongInformation.AvailableDifficulty.Extreme; exist[5] = songinfo.IsPPDSong; infos[0].Text = songinfo.BPM.ToString(); infos[5].Text = songinfo.ScoreAuthor; for (int i = 1; i <= 4; i++) { infos[i].Text = songinfo.GetDifficultyString((Difficulty)(i - 1)); if (exist[i]) { difficulties[i - 1].Color = new Color4(1, 1, 1, 1); } else { difficulties[i - 1].Color = new Color4(1, 0.3f, 0.3f, 0.4f); } score[i - 1] = songinfo.GetScore((Difficulty)(i - 1)); } }
public bool Filter(SongInformation info) { if (!info.IsPPDSong) { return(true); } if (Type == ScoreType.None) { return(false); } bool ok = (Type.HasFlag(ScoreType.ACFT) && info.HasACFT); ok |= (Type.HasFlag(ScoreType.AC) && info.HasAC); ok |= (Type.HasFlag(ScoreType.Normal) && info.HasNormal); if (!ok) { return(false); } return(ok |= (Difficulty.HasFlag(PPDFramework.SongInformation.AvailableDifficulty.Easy) && info.Difficulty.HasFlag(PPDFramework.SongInformation.AvailableDifficulty.Easy)) || (Difficulty.HasFlag(PPDFramework.SongInformation.AvailableDifficulty.Normal) && info.Difficulty.HasFlag(PPDFramework.SongInformation.AvailableDifficulty.Normal)) || (Difficulty.HasFlag(PPDFramework.SongInformation.AvailableDifficulty.Hard) && info.Difficulty.HasFlag(PPDFramework.SongInformation.AvailableDifficulty.Hard)) || (Difficulty.HasFlag(PPDFramework.SongInformation.AvailableDifficulty.Extreme) && info.Difficulty.HasFlag(PPDFramework.SongInformation.AvailableDifficulty.Extreme))); }
public ReplayComponent(PPDDevice device, PPDFramework.Resource.ResourceManager resourceManager, ReplayInfo replay, SongInformation songInfo, WebSongInformation webSongInfo, Difficulty difficulty) : base(device) { this.resourceManager = resourceManager; Replay = replay; SongInfo = songInfo; WebSongInfo = webSongInfo; Difficulty = difficulty; var color = songInfo == null ? PPDColors.Gray : PPDColors.White; AddChild(new TextureString(device, String.Format("{0}[{1}]", songInfo == null ? webSongInfo.Title : songInfo.DirectoryName, difficulty), 20, 400, color) { AllowScroll = true }); this.AddChild(new TextureString(device, replay.Nickname, 20, 300, color) { AllowScroll = true, Position = new Vector2(700, 0), Alignment = Alignment.Right }); AddChild(new TextureString(device, String.Format("{0}:{1} C{2} G{3} SF{4} SD{5} W{6} MC{7}", Utility.Language["Score2"], replay.Score, replay.CoolCount, replay.GoodCount, replay.SafeCount, replay.SadCount, replay.WorstCount, replay.MaxCombo), 16, 700, color) { Position = new Vector2(0, 26), AllowScroll = true }); }
private void AddThumbs(SongInformation newParent) { for (int i = removeList.Count - 1; i >= 0; i--) { thumbSprite.RemoveChild(removeList[i]); removeList.RemoveAt(i); } int iter = 0; var temp = new ThumbList(device) { Position = new SharpDX.Vector2(200 * newParent.Depth, 0) }; foreach (SongInformation songInfo in newParent.Children) { var component = new LoadablePictureComponent(device, resourceManager, songInfo) { Position = new SharpDX.Vector2(100, 225 + 100 * iter) }; temp.AddChild(component); iter++; } thumbSprite.AddChild(temp); currentParent = newParent; }
void Instance_ScoreUpdateFailed(int obj, SongInformation songInfo) { lock (this) { updateSucess.Add(false); updateIndex = obj; } }
/// <summary> /// Play a specific song. /// </summary> /// <param name="jsonSong">The json song.</param> public void Play(string jsonSong) { _owner.Dispatcher.Invoke(() => { SongInformation song = JsonConvert.DeserializeObject <SongInformation>(jsonSong); _player?.Play(song); }); }
/// <summary> /// Resoloves the song info. /// </summary> /// <param name="song">The song to resolve.</param> /// <returns>The resolved song.</returns> public static SongInformation Resolve(SongInformation song) { if (song != null && !string.IsNullOrEmpty(song.Location)) { SongInformation found = null; lock (_resolvedSongs) { found = _resolvedSongs.ToList().FirstOrDefault(s => s.Location.ToLower() == song.Location.ToLower()); } if (found != null) { return(found); } try { var file = TagLib.File.Create(song.Location); try { using (var reader = new MediaFoundationReader(song.Location)) { double?time = reader?.TotalTime.TotalSeconds; song.Duration = time == null ? 0 : (long)time; } } catch { } song.Genre = string.Join(", ", file.Tag.Genres); song.Album = file.Tag.Album; song.Band = string.Join(", ", file.Tag.Composers.Union(file.Tag.Artists)); song.DateAdded = new FileInfo(song.Location).CreationTime; if (file.Tag.Year > 0) { song.DateCreated = new DateTime((int)file.Tag.Year, 1, 1); } song.Title = string.IsNullOrEmpty(file.Tag.Title) ? song.Title : file.Tag.Title; song.Image = file.Tag.Pictures?.FirstOrDefault()?.Data?.Data; song.IsResolved = true; lock (_resolvedSongs) { _resolvedSongs.Add(song); } file.Dispose(); } catch { } } return(song); }
void Instance_ScoreUpdated(int obj, SongInformation songInfo) { lock (this) { updateSucess.Add(true); updatedSongInformations.Add(songInfo); updateIndex = obj; } }
public void Stop() { lastSongInformation = currentSongInformation; currentSongInformation = null; if (movie == null) { return; } movie.Dispose(); movie = null; }
/// <summary> /// The current song has changed. /// </summary> /// <param name="song">The song.</param> private void Player_SongChanged(SongInformation song) { if (song.Location != _currentSong?.Location) { _currentSong = song; foreach (var client in _clients.ToList()) { Play(song, client); } } }
public override void Load() { //init int selectnum = 0; string initialdirectory = "songs"; object temp; if (PreviousParam.TryGetValue("PPDGameUtility", out temp)) { PPDGameUtility gameutility = temp as PPDGameUtility; initialdirectory = gameutility.SongInformation.ParentDirectory;// Directory.GetParent(gameutility.SongInformation.DirectoryPath).Name; } ssm = new SelectSongManager(); ssm.SongChanged += new EventHandler(ssm_SongChanged); ssm.DirectoryChanged += new EventHandler(ssm_DirectoryChanged); resource = new Dictionary <string, ImageResource>(); ImageResource ir = new ImageResource("img\\default\\num.png", Device); resource.Add("img\\default\\num.png", ir); pictureobjects = new ArrayList(); mb = new MovieBox(Device); mss = new MenuSelectSong(Device, Sprite, this, ssm.Directory); sic = new SongInfoControl(Device, Sprite); cc = new ConfirmControl(Device, Sprite); if (PPDSetting.Setting.LightMode) { mt = new Moviethumb(Device, Sprite); } mss.DisapperFinish += new EventHandler(cc.Focus); //factory factory(selectnum); if (temp != null) { PPDGameUtility gameutility = temp as PPDGameUtility; Auto = gameutility.Auto; Speedscale = gameutility.SpeedScale; Random = gameutility.Random; changeprofiledisplay(); } ssm.Directory = initialdirectory; if (temp != null) { PPDGameUtility gameutility = temp as PPDGameUtility; SongInformation si = gameutility.SongInformation; selectnum = Array.FindIndex(ssm.SongInformations, (songinfo) => si.DirectoryName == songinfo.DirectoryName); if (selectnum < 0) { selectnum = 0; } } ssm.SelectedIndex = selectnum; }
/// <summary> /// Play a song object. /// </summary> /// <param name="song">The song.</param> public void Play(SongInformation song) { if (song != null) { if (!_sourceList.Any(ct => ct.Location == song.Location)) { _sourceList.Add(song); } this.PlayFromFileLocation(song.Location); } }
/// <summary> /// 動画を変更する /// </summary> private void ChangeMovie() { if (!allowcommand) { PlayGame(); return; } if (ssm.SelectedSongInformation == null || ssm.SelectedSongInformation.IsFolder || ssm.SelectedSongInformation.SongInfo == null) { return; } string moviePath = ssm.SelectedSongInformation.SongInfo.MoviePath; SongInformation songinfo = ssm.SelectedSongInformation.SongInfo; if (!string.IsNullOrEmpty(moviePath)) { if (PPDSetting.Setting.MenuMoviePreviewDisabled) { return; } var index = this.IndexOf(menuMovie); this.RemoveChild(menuMovie); menuMovie.Dispose(); menuMovie = new MenuMovie(device); this.InsertChild(menuMovie, index); // 動画取得 menuMovie.Movie = GameHost.GetMovie(songinfo); // 動画の最大ボリューム設定 menuMovie.MaximumVolume = songinfo.MovieVolume; menuMovie.FileName = moviePath; // 初期化 try { menuMovie.Initialize(); // 動画のカット設定 menuMovie.TrimmingData = songinfo.TrimmingData; // 動画のループ設定 menuMovie.SetLoop(songinfo.ThumbStartTime, songinfo.ThumbEndTime); // 再生、フェードイン menuMovie.Play(); menuMovie.FadeIn(); } catch { GameHost.AddNotify(PPDExceptionContentProvider.Provider.GetContent(PPDExceptionType.CannotOpenMovie)); } } else { MessageBox.Show(PPDExceptionContentProvider.Provider.GetContent(PPDExceptionType.NoMovieFileInDirectory) + "\n@" + songinfo.DirectoryPath); } }
void leftMenu_UpdateScoreDB(object sender, EventArgs e) { focusManager.RemoveFocus(); SongInformation.Update(); if (currentSelectSong != null && currentSelectSong.SongInformation == null) { FindSongData(); } chatComponent.AddSystemMessage(Utility.Language["ClientDBUpdated"]); SendScoreList(); }
public int Compare(SongInformation info1, SongInformation info2) { int ret; if (!info1.IsPPDSong && !info2.IsPPDSong) { ret = StringComparer.InvariantCulture.Compare(info1.DirectoryName, info2.DirectoryName); } else if (!info1.IsPPDSong) { ret = -1; } else if (!info2.IsPPDSong) { ret = 1; } else { switch (Field) { case SortField.Name: ret = StringComparer.InvariantCulture.Compare(info1.DirectoryName, info2.DirectoryName); break; case SortField.Time: ret = Math.Sign(info1.EndTime - info1.StartTime - info2.EndTime + info2.StartTime); break; case SortField.UpdateDate: DateTime date1 = DateTime.Parse(info1.UpdateDate, CultureInfo.InvariantCulture), date2 = DateTime.Parse(info2.UpdateDate, CultureInfo.InvariantCulture); ret = DateTime.Compare(date1, date2); break; case SortField.BPM: ret = Math.Sign(info1.BPM - info2.BPM); break; case SortField.Author: ret = StringComparer.InvariantCulture.Compare(info1.AuthorName, info2.AuthorName); break; default: ret = 0; break; } if (ret == 0) { ret = StringComparer.InvariantCulture.Compare(info1.DirectoryName, info2.DirectoryName); } } return((Desc ? -1 : 1) * ret); }
/// <summary> /// Loads a song /// </summary> /// <param name="song">The song object.</param> private void Load(SongInformation song) { _currentSong = song; if (!song.IsInternetLocation) { this.Load(song.Location); } else { this.Play(song.Location); } }
public void GoDownDirectory() { if (!CanGoDown) { return; } directorystack.Push(new KeyValuePair <string, int>(directory, selectedindex)); selectedindex = 0; directory = songinfos[selectedindex].DirectoryPath; songinfos = SongInformation.GetFromDirectory(directory); FireDirectoryChangeEvent(); FireSongChangeEvent(); }
/// <summary> /// Play from key (path). /// </summary> /// <param name="key"></param> private void PlayFromFileLocation(string key) { SongInformation song = _sourceList.FirstOrDefault(ct => ct.Location == key); if (song != null) { if (!song.IsResolved && !song.IsInternetLocation) { SongInfoController.Resolve(song); } Load(song); } }
/// <summary> /// Play a song object. /// </summary> /// <param name="song">The song.</param> public void Play(SongInformation song) { if (song == null) { return; } if (_sourceList.All(ct => ct.Location != song.Location)) { _sourceList.Add(song); } PlayFromFileLocation(song.Location); }
public void GoUpDirectory() { if (!CanGoUp) { return; } KeyValuePair <string, int> pair = directorystack.Pop(); selectedindex = pair.Value; directory = pair.Key; songinfos = SongInformation.GetFromDirectory(directory); FireDirectoryChangeEvent(); FireSongChangeEvent(); }
/// <summary> /// 難易度の追加を終了したときに使用します。 /// </summary> public void CheckNewOrCanUpdate() { IsNew = true; CanUpdate = false; foreach (WebSongInformationDifficulty difficulty in difficulties) { var songInfo = SongInformation.FindSongInformationByHash(difficulty.HashAsBytes); if (songInfo != null) { IsNew = false; CanUpdate |= difficulty.Revision < Revision; } } }