/// <summary> /// Play from the file path. /// </summary> /// <param name="path">The path of music file</param> private bool Play(string path) { Player.Stop(); if (File.Exists(path)) { Player.Source = new Uri(path); Player.Play(); State = PlayState.PLAY; timer.Start(); PlayIcon.Kind = MaterialDesignThemes.Wpf.PackIconKind.Pause; return(true); } else { // Path doesn't exist, find from List and remove it. var index = Musics.ToList().FindIndex(a => a.Path.Equals(path)); if (index != -1) { Musics.RemoveAt(index); SaveMusicList(); } return(false); } }
async void custom_MusicNameClick(object sender, EventArgs e) { //TODO: implement play music here //preparing data this.Playing = (sender as CustomMusicItem).Music; this.Cursor = Cursors.WaitCursor; await Task.Run(() => this.GetMusicURLData(ref Playing)); await Task.Run(() => CheckMusicInDB()); this.Cursor = Cursors.Arrow; //streaming KillPlayProcess(); SeekTimeTimer.Enabled = true; SeekTime = 0; ffmpeg.StartInfo.FileName = @"./ffmpeg/ffplay.exe"; ffmpeg.StartInfo.Arguments = "-noborder -nodisp -ss 0 " + this.Playing.URLData; ffmpeg.StartInfo.CreateNoWindow = true; ffmpeg.StartInfo.RedirectStandardOutput = true; ffmpeg.StartInfo.UseShellExecute = false; ffmpeg.EnableRaisingEvents = true; ffmpeg.Start(); Thread.Sleep(500); }
void Start() { mu = GameObject.Find("Musicas").GetComponent <Musics>(); faseAtual = Global.faseAtual; for (int i = 0; i < fases.Length; i++) { if (i != faseAtual) { fases[i].interactable = false; } } for (int i = 0; i < Global.faseStar.Length; i++) { if (Global.faseStar[i] == 1) { Instantiate(star, fases[i].transform.position + s1, new Quaternion(0, 0, 0, 0), fases[i].transform); } if (Global.faseStar[i] == 2) { Instantiate(star, fases[i].transform.position + s1, new Quaternion(0, 0, 0, 0), fases[i].transform); Instantiate(star, fases[i].transform.position + s2, new Quaternion(0, 0, 0, 0), fases[i].transform); } if (Global.faseStar[i] == 3) { Instantiate(star, fases[i].transform.position + s1, new Quaternion(0, 0, 0, 0), fases[i].transform); Instantiate(star, fases[i].transform.position + s2, new Quaternion(0, 0, 0, 0), fases[i].transform); Instantiate(star, fases[i].transform.position + s3, new Quaternion(0, 0, 0, 0), fases[i].transform); } } if (Global.faseAtual >= 4) { fim.SetActive(true); } }
public static void Play(Musics Index, bool Loop = false) { string Directory = Directories.Musics.FullName + (byte)Index + Format; // Apenas se necessário if (Device != null) { return; } if (!Lists.Options.Musics) { return; } if (!File.Exists(Directory)) { return; } // Carrega o áudio Device = new SFML.Audio.Music(Directory); Device.Loop = true; Device.Volume = 20; Device.Loop = Loop; // Reproduz Device.Play(); Current = (byte)Index; }
private void StringReformat(ref Musics music, string StringToReformat) { List <String> split = StringToReformat.Split(' ').ToList(); //List<string> singers = new List<string>(); split.RemoveAll(t => t == ""); //apply listen value to music then remove from list music.Listens = int.Parse(split.Last(), System.Globalization.NumberStyles.AllowThousands); split.RemoveAt(split.Count - 1); string singer = ""; for (int i = 0; i < split.Count; i++) { if (i == split.Count - 1 || split[i][split[i].Length - 1] == ',') //if í last index in array { singer += split[i][split[i].Length - 1] == ',' ? " " + split[i].Substring(0, split[i].Length - 1) : " " + split[i]; //singer += " " + split[i]; singer = singer.Substring(1); music.Singers.Add(singer); singer = ""; } else //if lát character in current is , add to list { singer += " " + split[i]; } } //music.Singers.AddRange(singers); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Url,AuthorId,SingerId,AlbumId,ReleaseDate")] Musics musics) { if (id != musics.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(musics); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MusicsExists(musics.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AlbumId"] = new SelectList(_context.Albums, "Id", "AlbumName", musics.AlbumId); ViewData["AuthorId"] = new SelectList(_context.Authors, "Id", "AuthorName", musics.AuthorId); ViewData["SingerId"] = new SelectList(_context.Singers, "Id", "DescriptionSinger", musics.SingerId); return(View(musics)); }
public ActionResult Create() { GetCode(); var model = new Musics(); return(View(model)); }
public override void _Ready() { animationPlayer = GetNode <AnimationPlayer>("AnimationPlayer"); animationPlayer.Play("ZoomIn", -1, -0.1f, true); file = GetNode <SaveFile>("/root/SaveFile"); musics = GetNode <Musics>("/root/Music"); if (!file.isPlayingBGM) { GetNode <CheckButton>("Settings/VBoxContainer/Music/MusicToggle").Pressed = false; GetNode <Sprite>("Settings/VBoxContainer/Music/MusicToggle/Border/Off").Show(); GetNode <Sprite>("Settings/VBoxContainer/Music/MusicToggle/Border/On").Hide(); } else { GetNode <CheckButton>("Settings/VBoxContainer/Music/MusicToggle").Pressed = true; GetNode <Sprite>("Settings/VBoxContainer/Music/MusicToggle/Border/Off").Hide(); GetNode <Sprite>("Settings/VBoxContainer/Music/MusicToggle/Border/On").Show(); } if (!file.isPlayingSFX) { GetNode <CheckButton>("Settings/VBoxContainer/SFX/SFXToggle").Pressed = false; GetNode <Sprite>("Settings/VBoxContainer/SFX/SFXToggle/Border/Off").Show(); GetNode <Sprite>("Settings/VBoxContainer/SFX/SFXToggle/Border/On").Hide(); } else { GetNode <CheckButton>("Settings/VBoxContainer/SFX/SFXToggle").Pressed = true; GetNode <Sprite>("Settings/VBoxContainer/SFX/SFXToggle/Border/Off").Hide(); GetNode <Sprite>("Settings/VBoxContainer/SFX/SFXToggle/Border/On").Show(); } }
/// <summary> /// 在当前播放歌曲后插入 /// </summary> /// <param name="music"></param> public static void Insert(IMusic music, bool play = true) { Musics.Insert(index, music); if (play) { index++; } }
/// <summary> /// 在当前播放列表加入 /// </summary> /// <param name="music"></param> public static void Add(IMusic music, bool play = true) { Musics.Add(music); if (play) { index = Musics.Count - 1; } }
protected void Page_Load(object sender, EventArgs e) { String _conn = ConfigurationManager.ConnectionStrings["TopRockConnection"].ConnectionString; Musics _mus = new Musics(_conn); CustomProfile _profile = (CustomProfile)HttpContext.Current.Profile; String _path = ConfigurationManager.AppSettings["MusicFilePath"].Replace("../", ""); DisplayResult(_mus.GetMusicsByCategory(Convert.ToInt32(_profile.MusicCategory), _path)); //Response.Write(_profile.MusicCategory); }
public void GetMusicDataURL(ref Musics music) { this.htmlDoc = web.Load(music.URLWeb.ToString()); HtmlNode node = this.htmlDoc.DocumentNode.SelectSingleNode("//*[@id='fullPlayer']/div"); MatchCollection match = Regex.Matches(node.OuterHtml, @"(www.+|http.+)([\s]|$)"); music.URLData = match[0].Value.Split('\"')[0]; music.Quality = this.htmlDoc.DocumentNode.SelectSingleNode("/html/body/div[8]/p/span[1]").InnerText.Substring(1); }
public IActionResult OnPost(int musicId, string returnUrl) { Musics musics = repository.Musics.FirstOrDefault(p => p.Id == musicId); Playlist = HttpContext.Session.GetJson <Playlist>("playlist") ?? new Playlist(); HttpContext.Session.SetJson("playlist", Playlist); return(RedirectToPage(new { returnUrl = returnUrl })); }
//------------------------------------------------- #region Constructors Region private wotoMusic(Musics music) { InitializeComponent(); Music = music; Path = ThereIsConstants.Path.Datas_Path + ThereIsConstants.Path.DoubleSlash + MyRes.GetString(Music.ToString()); }
/// <summary> /// Save updates into the file. /// </summary> private void PreviousFile() { int currentIndex = Musics.IndexOf(SelectedMusic) - 1; if (currentIndex < 0) { currentIndex = Musics.Count - 1; } SelectedMusic = Musics[currentIndex]; }
/// <summary> /// Save updates into the file. /// </summary> private void NextFile() { int currentIndex = Musics.IndexOf(SelectedMusic) + 1; if (currentIndex >= Musics.Count) { currentIndex = 0; } SelectedMusic = Musics[currentIndex]; }
public Model.Music Next() { if (Musics.Count() == 0) { return(null); } ++_CurrentIndex; _CurrentIndex %= Musics.Count(); return(Musics[_CurrentIndex]); }
public async Task <IActionResult> Create([Bind("Id,Name,Url,AuthorId,SingerId,AlbumId,ReleaseDate")] Musics musics) { if (ModelState.IsValid) { _context.Add(musics); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["AlbumId"] = new SelectList(_context.Albums, "Id", "AlbumName", musics.AlbumId); ViewData["AuthorId"] = new SelectList(_context.Authors, "Id", "AuthorName", musics.AuthorId); ViewData["SingerId"] = new SelectList(_context.Singers, "Id", "DescriptionSinger", musics.SingerId); return(View(musics)); }
public static void PlayMusic(Musics music) { // Stop if already playing any music if (currentlyPlayingMusic != Musics.None) { musics[(int)currentlyPlayingMusic - 1].Stop(); } // Start playing new music int id = (int)music - 1; musics[id].Play(); currentlyPlayingMusic = music; }
/// <summary> /// Read musics from json file. /// </summary> private void ReadMusics() { if (File.Exists(SavePath)) { try { // Read musics from json file. using (var file = new StreamReader(SavePath)) { string musics = file.ReadToEnd(); Musics = JsonConvert.DeserializeObject <ObservableCollection <Music> >(musics); } } catch (Exception e) { Console.WriteLine(e.Message); } for (var i = 0; i < Musics.Count; i++) { if (File.Exists(Musics[i].Path)) { try { // Read ID3Tag from mp3 file. var tag = new Mp3File(Musics[i].Path).TagHandler; Musics[i].AlbumImage = BitmapToBitmapImage(new Bitmap(tag.Picture)); } catch (Exception e) { Console.WriteLine(e.Message); Musics[i].AlbumImage = null; } } else { // Remove the music of which path doesn't exist. Musics.RemoveAt(i); i--; } } MusicList.DataContext = Musics; SaveMusicList(); } else if (!Directory.Exists("./Data")) { Directory.CreateDirectory("./Data"); File.Create(SavePath); } }
protected void Music_OnRowCommand(Object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("Update")) { Response.Redirect("EditMusic.aspx?musId=" + e.CommandArgument.ToString()); } else if (e.CommandName.Equals("Download")) { Musics _mus = new Musics(this.ConnectionString); _mus.LitePopulate(e.CommandArgument, false); String _path = String.Format(ConfigurationManager.AppSettings["MusicFilePath"], _mus.ID.ToString(), _mus.FileType); Response.Redirect(_path); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { HtmlGenericControl _nc = (HtmlGenericControl)Master.FindControl("navHistory"); _nc.Attributes.Add("class", "active"); MusicCategoriesCollection<MusicCategories> _cat = new MusicCategoriesCollection<MusicCategories>(this.ConnectionString); _cat.LitePopulate(new CoreLibrary.ArgumentsList()); dd_Category.DataSource = _cat; dd_Category.DataTextField = "Description"; dd_Category.DataValueField = "ID"; dd_Category.DataBind(); dd_Status.DataSource = this.LogedInUser.GetAllStatuses(); dd_Status.DataTextField = "Description"; dd_Status.DataValueField = "ID"; dd_Status.DataBind(); dd_Status.Items.FindByValue("3").Selected = true; String _musId = Request.QueryString["musId"]; if (!String.IsNullOrEmpty(_musId)) { ViewState.Add("musId", _musId); Musics _music = new Musics(this.ConnectionString); _music.LitePopulate(_musId, false); if (dd_Category.Items.FindByValue(_music.CategoryId.ToString()) != null) { dd_Category.ClearSelection(); dd_Category.Items.FindByValue(_music.CategoryId.ToString()).Selected = true; } txt_Title.Text = HttpUtility.HtmlDecode(_music.Title); if (dd_Status.Items.FindByValue(_music.Status.ToString()) != null) { dd_Status.ClearSelection(); dd_Status.Items.FindByValue(_music.Status.ToString()).Selected = true; } val_File.Enabled = false; reg_File.Enabled = false; } } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); Musics musics = target as Musics; if (GUILayout.Button("AutoSearch")) { musics.musicDatas = Search(musics); //保存 EditorUtility.SetDirty(musics); AssetDatabase.SaveAssets(); } }
public void AddMusic(Model.Music music) { XML.MediaXML mediaXML = new XML.MediaXML(); mediaXML.Load("musics.xml"); if (!mediaXML.HasMedia(music.Path)) { mediaXML.Add(music.Path, music.Stream); mediaXML.WriteInFile("musics.xml"); if (music.Name.Contains(this._SearchInput)) { Musics.Add(music); } MusicsTmp.Add(music); } }
public IHttpActionResult PostMusic(Musics music) { if (ModelState.IsValid) { context.Musics.Add(music); context.SaveChanges(); var uri = new Uri( Url.Link("DefaultApi", new { id = music.ID }) ); return(Created(uri, music)); } else { return(BadRequest(ModelState)); } }
private IEnumerable <Musics> ParseToMusicsObjects() { List <Musics> ret = new List <Musics>(); HtmlNodeCollection MusicItems = this.htmlDoc.DocumentNode.SelectNodes(@"//div[contains(@class,'bgmusic')]"); foreach (HtmlNode node in MusicItems) { Musics MusicItem = new Musics(); MusicItem.SongName = node.SelectSingleNode(@".//h3/a").InnerText; MusicItem.URLWeb = node.SelectSingleNode(@".//h3/a").Attributes["href"].Value; MusicItem.URLId = MusicItem.URLWeb.ToString().Split('.').Reverse().ToArray()[1]; MusicItem.Singers = new MongoDB.Bson.BsonArray(); StringReformat(ref MusicItem, node.SelectSingleNode(@".//p").InnerText); ret.Add(MusicItem); } return(ret.AsEnumerable()); }
private void buildLocalPlaylistModels() { foreach (var list in Service.Library.Playlists) { var playlist = new LocalPlaylistModel { Playlist = Service.Library.Playlists.Where(p => p.Id == list.Id).FirstOrDefault(), }; Playlists.Add(playlist); } foreach (var pair in Service.Library.MInP) { var playlist = Playlists.Where(p => p.Playlist.Id == pair.PlaylistId).FirstOrDefault(); var music = Musics.Where(m => m.Music.Id == pair.MusicId).FirstOrDefault(); playlist.Musics.Add(music); } }
public Model.Music Prev() { if (Musics.Count() == 0) { return(null); } if (_CurrentIndex > 0) { --_CurrentIndex; } else { _CurrentIndex = Musics.Count() - 1; } return(Musics[_CurrentIndex]); }
void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); audioS = gameObject.GetComponent <AudioSource>(); s = SceneManager.GetActiveScene(); audioS.loop = true; audioS.clip = musiMenu; audioS.Play(); }
public static void Play(Musics Index, bool Loop = false) { System.IO.FileInfo File = new System.IO.FileInfo(Directories.Musics.FullName + (byte)Index + Format); // Apenas se necessário if (Device != null) return; if (Editor_Maps.Objects.Visible && !Editor_Maps.Objects.butAudio.Checked) return; if (!File.Exists) return; // Carrega o áudio Device = new SFML.Audio.Music(Directories.Musics.FullName + (byte)Index + Format); Device.Loop = true; Device.Volume = 20; Device.Loop = Loop; // Reproduz Device.Play(); Current = (byte)Index; }
public JsonResult Upload() { try { if (Request.Form["weibo"] == null) { throw new Exception(); } string cookie = Request.Form["weibo"].ToString(); string uid = cookie.Split('&')[0].Replace("UID=", ""); string pwd = Utils.UrlDecode(cookie.Split('&')[1].Replace("PWD=", "")); User CurrentUser = Users.GetUserByID(TypeConverter.StrToLong(uid, -1)); if (CurrentUser == null) { throw new Exception(); } if (CurrentUser.Password != pwd) { throw new Exception(); } Music music = Musics.UploadMusic(CurrentUser); if (music != null) { Entity.Url url = new Url(); url.MediaID = music.ID; url.ShortLink = UrlShort.ShortUrl(music.MusicUrl)[0]; url.OriginalUrl = music.MusicUrl; url.Type = TypeConfigs.GetUrlMusic; url.ID = Urls.CreateUrl(url); if (url.ID > 0) { string shortlink = BaseConfigs.GetShortLinkDomainName + url.ShortLink; return(Json(new JsonModel(CodeStruct.UploadSuccess, shortlink + " " + music.Title))); } } return(Json(new JsonModel(CodeStruct.Error, "-1"))); } catch (Exception ex) { return(Json(new JsonModel(CodeStruct.Error, "-1"))); } }
public void RemoveMusic(Model.Music music) { XML.MediaXML mediaXML = new XML.MediaXML(); mediaXML.Load("musics.xml"); mediaXML.Remove(music.Path); mediaXML.WriteInFile("musics.xml"); String namePathFile = music.Path; Musics.Remove(music); var medias = from media in MusicsTmp where media.Path.Contains(namePathFile) select media; var selected = music; foreach (var media in medias) { selected = media; } MusicsTmp.Remove(selected); }
public IHttpActionResult PutMusic(Guid id, Musics music) { if (ModelState.IsValid && id == music.ID) { context.Entry(music).State = System.Data.Entity.EntityState.Modified; try { context.SaveChanges(); } catch (DbUpdateConcurrencyException) { return(NotFound()); } return(Ok(music)); } else { return(BadRequest(ModelState)); } }
protected void Save_Click(object sender, EventArgs e) { if (IsValid) { Musics _mus = new Musics(this.ConnectionString); if (ViewState["musId"] != null) { _mus.LitePopulate(ViewState["musId"], false); } _mus.Title = HttpUtility.HtmlEncode(txt_Title.Text); _mus.Status = Convert.ToInt32(dd_Status.SelectedValue); _mus.CategoryId = Convert.ToInt32(dd_Category.SelectedValue); String _imgType = ""; if (fu_File.HasFile) { _imgType = fu_File.FileName.Split('.')[1]; _mus.FileType = _imgType; } if (_mus.Save()) { if (fu_File.HasFile) { String _path = Server.MapPath(String.Format(ConfigurationManager.AppSettings["MusicFilePath"], _mus.ID.ToString(), _imgType)); fu_File.SaveAs(_path); } this.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", "alert('Record has been updated successfully.');self.location = 'MusicList.aspx';", true); } else { lbl_Error.Text = "An unexpected error has occurred. Please try again."; lbl_Error.Visible = true; } } }
private IEnumerator DoCrossFade(Musics music, float crossTime) { while(isCrossFading) yield return null; isCrossFading = true; Debug.Log(string.Format("Crossfading music from {0} to {1}",currentMusic,music)); AudioSource sourceFrom = null; if(currentMusic == Musics.MainMenuTheme) sourceFrom = audioSourceMusic; else if(currentMusic == Musics.GameTheme) sourceFrom = audioSourceMusic2; else if(currentMusic == Musics.BossTheme) sourceFrom = audioSourceMusic3; AudioSource sourceTo = null; if(music == Musics.MainMenuTheme) sourceTo = audioSourceMusic; else if(music == Musics.GameTheme) { sourceTo = audioSourceMusic2; sourceTo.Stop(); sourceTo.Play(); } else if(music == Musics.BossTheme) { sourceTo = audioSourceMusic3; sourceTo.Stop(); sourceTo.Play(); } sourceFrom.mute = false; sourceTo.mute = false; float maxTimeFrom = sourceFrom.volume; float maxTimeTo = sourceTo.volume; sourceTo.volume = 0; while(sourceFrom.volume > 0) { sourceFrom.volume -= maxTimeFrom * Time.deltaTime / crossTime; sourceTo.volume += maxTimeTo * Time.deltaTime / crossTime; yield return null; } sourceFrom.volume = maxTimeFrom; sourceTo.volume = maxTimeTo; sourceFrom.mute = true; currentMusic = music; isCrossFading = false; Debug.Log(string.Format("current music is now {0}", currentMusic)); }
public void PlayMusic(Musics music, bool loop) { if(musicMute) return; if(music == currentMusic) return; audioSourceMusic.mute = true; audioSourceMusic2.mute = true; audioSourceMusic3.mute = true; AudioSource source = null; if(music == Musics.MainMenuTheme) source = audioSourceMusic; else if(music == Musics.GameTheme) { source = audioSourceMusic2; source.Stop(); source.Play(); } else if(music == Musics.BossTheme) { source = audioSourceMusic3; source.Stop(); source.Play(); } //source.loop = loop; source.mute = false; currentMusic = music; }
public void PlayMusic(Musics music) { PlayMusic (music, true); }
protected void Publish_Click(Object sender, EventArgs e) { Musics _st = null; foreach (GridViewRow I in dgMusics.Rows) { Label _id = (Label)I.FindControl("lbl_MusId"); if (_id != null) { DropDownList _ddst = (DropDownList)I.FindControl("dd_Status"); TextBox _sort = (TextBox)I.FindControl("txt_Sort"); _st = new Musics(this.ConnectionString); _st.LitePopulate(_id.Text, false); if (!_st.Status.ToString().Equals(_ddst.SelectedValue)) { _st.Status = Convert.ToInt32(_ddst.SelectedValue); } if (Regex.IsMatch(_sort.Text, @"^\d+$")) { _st.Sort = Convert.ToInt32(_sort.Text); } _st.Save(); } } this.DataBind(); }
void Awake() { if(instance != null && instance != this) { Destroy(gameObject); return; } instance = this; transform.parent = null; DontDestroyOnLoad (gameObject); AudioSource[] sources = GetComponents<AudioSource>(); audioSourceMusic = sources[0]; audioSourceMusic.clip = mainMenuTheme; audioSourceMusic2 = sources[1]; audioSourceMusic2.clip = gameTheme; audioSourceMusic3 = sources[2]; audioSourceMusic3.clip = bossTheme; audioSourceSoundFX = sources[3]; currentMusic = Musics.MainMenuTheme; }
public void CrossFadeMusic(Musics music, float crossTime) { if(musicMute) return; StartCoroutine(DoCrossFade(music, crossTime)); }
private IEnumerator DoFadeOut(float fadeTime) { AudioSource sourceFrom = null; if(currentMusic == Musics.MainMenuTheme) sourceFrom = audioSourceMusic; else if(currentMusic == Musics.GameTheme) sourceFrom = audioSourceMusic2; else if(currentMusic == Musics.BossTheme) sourceFrom = audioSourceMusic3; sourceFrom.mute = false; float maxTimeFrom = sourceFrom.volume; while(sourceFrom.volume > 0) { sourceFrom.volume -= maxTimeFrom * Time.deltaTime / fadeTime; yield return null; } sourceFrom.volume = maxTimeFrom; sourceFrom.mute = true; currentMusic = Musics.None; }