public void Stop() { StartCoroutine(DiscordRP.UpdateActivity(null, "Default")); StopCoroutine(Loop()); hasStarted = false; isPaused = false; Source.Stop(); }
private void MediaPlayer_MediaOpened(object sender, EventArgs e) { try { mediaPlayer.Play(); GetFavorite(); TextBlock_Info_PlayList.Text = $"Duración total: {suma:dd\\:hh\\:mm\\:ss}"; Music music = ReproductionList[DataGridP.SelectedIndex]; TagLib.File tagLib = TagLib.File.Create(music.Path, "audio/mp3", TagLib.ReadStyle.Average); TextBlock_Author_Name.Text = tagLib.Tag.Artists.Length > 0 ? tagLib.Tag.Artists[0] : ""; Name_Music.Text = music.Name; Title = $"JohMusic: {music.Name}"; CheckFilesStreamerMode(tagLib); // Agregamos la imagen de la música if (tagLib.Tag.Pictures.Length > 0) { try { TagLib.IPicture picture = tagLib.Tag.Pictures[0]; IO.MemoryStream ms = new IO.MemoryStream(picture.Data.Data); BitmapImage bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.StreamSource = ms; bitmap.EndInit(); Image_Song.Source = bitmap; if (Streamer_Picture) { Download_Image(tagLib); } } catch (NotSupportedException) { Image_Song.Source = new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/IMG/no_found_music.jpg")); } Name_Music.ToolTip = new ToolTip() { Content = Name_Music.Text, Background = Brushes.Black, Foreground = Brushes.White }; position = mediaPlayer.NaturalDuration.TimeSpan; Slider_Carga.Minimum = 0; Slider_Carga.Maximum = position.TotalSeconds; Text_MinLength.Text = mediaPlayer.Position.ToString(@"mm\:ss"); Text_MaxLength.Text = mediaPlayer.NaturalDuration.TimeSpan.ToString(@"mm\:ss"); if (Name_Music.Text.Length > 25) { RightToLeftMarquee(); } else { Name_Music.BeginAnimation(Canvas.RightProperty, null); } //Cambia el estado de discord. discordRP.Details = Name_Music.Text; //"Escuchando" discordRP.State = $"{TextBlock_Author_Name.Text}"; discordRP.TimeEnd = position.TotalSeconds; discordRP.UpdateActivity(); if (WindowState == WindowState.Minimized && notify) // Comprueba si está minimizado y envia una notificación { Notification.Show("Escuchando Música", $"Se está escuchando {Name_Music.Text}.\nDuración: {Text_MaxLength.Text}."); } } catch (Exception ms) { MessageBox.Show(ms.Message); } }
void UpdatePanel(string lvl) { StartCoroutine(DiscordRP.UpdateActivity(lvl, null)); Manager.GetComponent <SystemUIManager>().ContentSwap(lvl); }
void Awake() { Physics.autoSimulation = false; Application.targetFrameRate = -1; Application.logMessageReceivedThreaded += Manager.GetComponent <ErrorManager>().Exception; if (File.Exists(FilesDataClass.FilePath + "/Settings.rss")) { byte[] bytes = File.ReadAllBytes(FilesDataClass.FilePath + "/Settings.rss"); string JSON = Encoding.ASCII.GetString(bytes); SettingsClass Settings; try { Settings = JsonUtility.FromJson <SettingsClass>(JSON); } catch (ArgumentException) { File.Delete(FilesDataClass.FilePath + "/Settings.rss"); Manager.GetComponent <ErrorManager>().Error("Corrupt Settings File, Settings have been reset."); } } if (!Directory.Exists(FilesDataClass.FilePath)) { Directory.CreateDirectory(FilesDataClass.FilePath); } if (!Directory.Exists(FilesDataClass.FilePathSaves)) { Directory.CreateDirectory(FilesDataClass.FilePathSaves); } if (!Directory.Exists(FilesDataClass.FilePathLanguage)) { Directory.CreateDirectory(FilesDataClass.FilePathLanguage); } if (!Directory.Exists(FilesDataClass.FilePathCache)) { Directory.CreateDirectory(FilesDataClass.FilePathCache); } if (!Directory.Exists(FilesDataClass.FilePathCacheJson)) { Directory.CreateDirectory(FilesDataClass.FilePathCacheJson); } if (!Directory.Exists(FilesDataClass.FilePathCacheImages)) { Directory.CreateDirectory(FilesDataClass.FilePathCacheImages); } if (!Directory.Exists(FilesDataClass.FilePathPlugins)) { Directory.CreateDirectory(FilesDataClass.FilePathPlugins); } if (!Directory.Exists(FilesDataClass.FilePathNotepad)) { Directory.CreateDirectory(FilesDataClass.FilePathNotepad); } if (!Directory.Exists(FilesDataClass.FilePathMusic)) { Directory.CreateDirectory(FilesDataClass.FilePathMusic); } if (!Directory.Exists(FilesDataClass.FilePathScreenshots)) { Directory.CreateDirectory(FilesDataClass.FilePathScreenshots); } string[] args = Environment.GetCommandLineArgs(); /*if (args.Length > 0) * { * Debug.Log(args[1]); * if (File.Exists(args[1])) * { * if (args[1].EndsWith(".rs")) * { * Manager.GetComponent<ViewManager>().OpenWithRS = true; * ScoutManager.GetComponent<Scout>().OpenWithCheck = true; * ScoutManager.GetComponent<Scout>().OpenWithDirectory = args[1]; * } * else if (args[1].EndsWith(".rse")) * { * Manager.GetComponent<ViewManager>().OpenWithRSE = true; * } * else if (args[1].EndsWith(".rss")) * { * * } * } * }*/ if (Application.isEditor) { DiscordRP.Status2Default = "Developing"; StartCoroutine(DiscordRP.UpdateActivity(null, "Developing")); } else { DiscordRP.Status2Default = ""; } Manager.GetComponent <MethodManager>().StartManaging(); }
IEnumerator GetSong() { Debug.Log("GetSong"); Title.text = "Loading..."; string path = "file://" + FilesDataClass.FilePathMusic + "/" + Songs[CurrentSongInt]; if (!File.Exists(path)) { } Debug.Log(path); if (SongsType[CurrentSongInt] == "mp3") { Debug.Log("mp3"); using var Request = UnityWebRequestMultimedia.GetAudioClip(path, AudioType.MPEG); yield return(Request.SendWebRequest()); if (Request.result != UnityWebRequest.Result.Success) { Debug.LogError(Request.error); yield break; } yield return(null); AudioClip clip = DownloadHandlerAudioClip.GetContent(Request); while (clip.loadState != AudioDataLoadState.Loaded) { yield return(Request); } clip.name = Path.GetFileNameWithoutExtension(path); Title.text = "Playing - " + Path.GetFileNameWithoutExtension(path); Source.clip = clip; Source.Play(); } if (SongsType[CurrentSongInt] == "wav") { Debug.Log("wav"); using var Request = UnityWebRequestMultimedia.GetAudioClip(path, AudioType.WAV); yield return(Request.SendWebRequest()); if (Request.result != UnityWebRequest.Result.Success) { Debug.LogError(Request.error); yield break; } yield return(null); AudioClip clip = DownloadHandlerAudioClip.GetContent(Request); while (clip.loadState != AudioDataLoadState.Loaded) { yield return(Request); } clip.name = Path.GetFileNameWithoutExtension(path); Title.text = "Playing - " + Path.GetFileNameWithoutExtension(path); Source.clip = clip; Source.Play(); } if (SongsType[CurrentSongInt] == "ogg") { Debug.Log("ogg"); using var Request = UnityWebRequestMultimedia.GetAudioClip(path, AudioType.OGGVORBIS); yield return(Request.SendWebRequest()); if (Request.result != UnityWebRequest.Result.Success) { Debug.LogError(Request.error); yield break; } yield return(null); AudioClip clip = DownloadHandlerAudioClip.GetContent(Request); while (clip.loadState != AudioDataLoadState.Loaded) { yield return(Request); } clip.name = Path.GetFileNameWithoutExtension(path); Title.text = "Playing - " + Path.GetFileNameWithoutExtension(path); Source.clip = clip; Source.Play(); } StartCoroutine(DiscordRP.UpdateActivity(null, "Listening to music(" + Path.GetFileNameWithoutExtension(path) + ")")); LoopCheck(); StartCoroutine(Loop()); }
public void Close() { StartCoroutine(DiscordRP.UpdateActivity(null, "Default")); Source.Stop(); GameObject.Destroy(MusicProgram); }