/// <summary> /// When a media file is begin to play, it decides the player engine to use by the parameter a: /// </summary> /// <param name="Query"></param> /// public static void PlayItem(String Query) { /// <summary> /// Stop the current player to play the media, but first /// be sure that there is a current instance of a class witihn the IMediaEngine /// </summary> if(currentPlayer!=null){ currentPlayer.Stop(); foreach(Control d in Program.Host.Playboard.Controls) { if(d.GetType() == currentPlayer.MediaControl.GetType()) { d.Hide(); } } } /// <summary> /// Get the engine namespace from the query passed /// </summary> string engine = Query.Split(':')[0]; IPlayEngine D = null; if(Query.StartsWith("music:")) { Song _Song = new Song(); Uri d = new System.Uri(Query); _Song.Title=d.Segments[3]; _Song.Artist=d.Segments[1]; _Song.Album=d.Segments[2]; foreach(IPlayEngine Engine in Program.MediaEngines.Values) { if((currentTrack.Path=Engine.RawFind(currentTrack))!=null) { break; } } return; } else { /// <summary> /// Get the player from the list /// </summary> /// if(Program.MediaEngines.ContainsKey(engine)) { D = Program.MediaEngines[engine]; } } if(D!=null) { D.MediaControl.Dock = DockStyle.Fill; D.MediaControl.Show(); D.MediaControl.Enabled=true; /// <summary> /// Remove the engine specification of the Query URI /// </summary> String Path = Query.Replace(engine+":",""); /// <summary> /// Send it to the media player /// </summary> D.Load((Path)); /// <summary> /// Play the media /// </summary> D.Play(); currentPlayer=D; } else { MessageBox.Show("There is no media handler for the media"); } }
public static ListViewItem SongToItem(Song I) { ListViewItem D = new ListViewItem(I.Title); D.SubItems.Add(""); D.SubItems.Add(I.Artist); D.SubItems.Add(I.Album); D.SubItems.Add(I.Store); D.SubItems.Add(I.Engine); D.Tag=(object)I; return D; }
public void SongImport(Song[] query) { }
public void AddToPlaylist(string playlistID, Song _Song, int pos) { try { String Path = MainForm.GetURIFromSong(_Song); if (File.Exists(MainForm.DownloadDir + "\\" + playlistID)) { List<String> Strings = new List<string>(); using (StreamReader SR = new StreamReader(MainForm.DownloadDir + "\\" + playlistID)) { String Line = ""; while ((Line = SR.ReadLine()) != null) { Strings.Add(Line.Replace(" ","%20")); } SR.Close(); } Strings.Insert(pos, Path.Replace(" ","%20")); using (StreamWriter SW = new StreamWriter(MainForm.DownloadDir + "\\" + playlistID)) { foreach (String d in Strings) { SW.WriteLine(d); } SW.Close(); } } } catch { } }
public MediaChrome.Views.Playlist ViewPlaylist(string Name,string PlsID) { if (PlsID == ""|| PlsID == null) { return new MediaChrome.Views.Playlist(this, "",PlsID, this.Host); } List<Song> Songs = new List<Song>(); MediaChrome.Views.Playlist PList = new MediaChrome.Views.Playlist(this, "", PlsID, this.Host); Spotify.Playlist List = Spotify.Playlist.Create(SpotifySession,Link.Create(PlsID.Replace("playlist:sp:",""))); foreach(Track _Track in List.CurrentTracks) { try { Song D = new Song(); D.Title = _Track.Name; D.Album = _Track.Album.Name; D.Artist = _Track.Artists[0].Name; D.Path = "sp:" + _Track.LinkString; Songs.Add(D); } catch { } } PList.Songs = Songs; PList.Title = List.Name; return PList; }
public List<Song> Find(String Query) { List<Song> Songs = new List<Song>(); SQLiteConnection Conn = MainForm.MakeConnection(); Conn.Open(); SQLiteCommand Command = new SQLiteCommand("SELECT name,artist,album,path,store,engine FROM song WHERE name LIKE '%"+Query+"%' OR artist LIKE '%"+Query+"%' OR album LIKE '%"+Query+"%' ",Conn); SQLiteDataReader DR = Command.ExecuteReader(); while(DR.Read()) { Song D = new Song(); try{ D.Title = DR.GetString(0); D.Artist = DR.GetString(1); D.Album = DR.GetString(2); D.Path=DR.GetString(3); D.Store=DR.GetString(4); D.Engine=DR.GetString(5); }catch{} Songs.Add(D); } return Songs; }
public static String GetURIFromSong(Song _Song) { String Version = MainForm.findVersion(_Song.Title); String Commit = MainForm.findCommit(_Song.Title); String Path = "music://t/" + _Song.Artist + "/" + _Song.Title.Replace("(" + Version + ")", "").Replace("[" + Commit + "]", "") + "/" + _Song.Album + (Version != "" ? "/" + Version : " ") + (Commit != "" ? "/" + Commit : "") + "?a=b" + (_Song.Engine != null || _Song.Engine != "" ? "&service=" + _Song.Engine : "") + ( _Song.ID != null ? "&id="+_Song.ID : ""); Path = Path.Replace("'", "").Replace("[", "").Replace("]", "").Replace("(", "").Replace(")", ""); return Path; }
public List<Song> Find(String Query) { List<Song> Songs = new List<Song>(); Search D = SpotifySession.SearchSync(Query,0,100,0,100,0,100,new TimeSpan(4200000)); try { foreach (Track Df in D.Tracks) { Song A = new MediaChrome.Song(); A.Title = Df.Name; A.Artist = Df.Artists[0].Name; A.Album = Df.Album.Name; A.Path = "sp:" + Df.LinkString; A.Store = "Spotify"; A.Popularity = 0.5f; A.Engine = "sp"; Songs.Add(A); } } catch { } return Songs; }
public static String GetSongByEngine(Song _Song,String _Engine) { String Query = _Song.Path; /* Uri d = new System.Uri(Query.Replace("music:", "http:").Replace("song:", "http:")); _Song.Title = d.Segments[2].Replace("%20", " ").Replace("/", ""); _Song.Artist = d.Segments[1].Replace("%20", " ").Replace("/", ""); _Song.Album = d.Segments[3].Replace("%20", " ").Replace("/","");*/ try { IPlayEngine Engine = Program.MediaEngines[_Engine]; { Song f = Engine.RawFind(_Song); if ((f) != null) { return f.Path; } } } catch { } return null; }
public static Song GetSongFromURI(String D) { Song P = new Song(); P.Version = MainForm.findVersion(D); P.Contributing = MainForm.findCommit(D); Uri Url = new System.Uri(D.Replace("(" + P.Version + ")", "").Replace("[" + P.Contributing + "]", "").Replace("{", "").Replace("}", "")); P.Artist = Url.Segments[1].Replace("/", "").Replace("%20", " ");//Url.Host.Replace("_"," "); P.Title = Url.Segments[2].Replace("/", "").Replace("%20", " "); P.Album = Url.Segments[3].Replace("/", "").Replace("%20", " "); try { P.ProposedEngine = UriHelper.Querystrings(Url)["service"]; } catch { } P.Path = D; try { P.ID = UriHelper.Querystrings(Url)["id"]; }catch{ } return P; }
static void _ResolveSong(Object dr) { resolvingSong = true; Song _Song = (Song)dr; if(Querys != null) if (Querys.ContainsKey("service")) { if (Program.MediaEngines.ContainsKey(Querys["service"])) { IPlayEngine Engine = Program.MediaEngines[Querys["service"]]; MainForm.Engine = Engine; MainForm.watchSong = Engine.RawFind(_Song); resolvingSong = false; return; /* */ } } /** * Elsewhere, iterate through installed music services * and check if there is a matching track to play the song on * */ foreach (IPlayEngine Engine in Program.MediaEngines.Values) { Song f = Engine.RawFind(_Song); if (f != null) { MainForm.Engine = Engine; resolvingSong = false; MainForm.watchSong = f; return; } /* currentTrack = f; currentPlayer = Engine; Engine.Load((currentTrack.Path)); currentTrack = _Song; Engine.Play(); */ } resolvingSong = false; MainForm.ResolvingSongThread = null; ShowMessage("There was no service found for the song"); }
public List<Song> ViewPlaylist(string PlsID) { if (PlsID == ""|| PlsID == null) { return new List<Song>(); } List<Song> Songs = new List<Song>(); Spotify.Playlist List = Spotify.Playlist.Create(SpotifySession,Link.Create(PlsID.Replace("playlist:sp:",""))); foreach(Track _Track in List.CurrentTracks) { try { Song D = new Song(); D.Title = _Track.Name; D.Album = _Track.Album.Name; D.Artist = _Track.Artists[0].Name; D.Path = "sp:" + _Track.LinkString; Songs.Add(D); } catch { } } return Songs; }
public Song RawFind(Song D) { SQLiteConnection Conn = MainForm.MakeConnection(); Conn.Open(); SQLiteCommand Command = new SQLiteCommand("SELECT * FROM song WHERE name LIKE '%"+D.Title+"%' AND artist LIKE '%"+D.Artist+"%' AND ( engine = 'mp3' OR store ='mp3')",Conn); SQLiteDataReader Reader = Command.ExecuteReader(); if(Reader.HasRows) { Song result = MainForm.GetSongFromQury(Reader); return result; //("mp3:"+Reader.GetString(0)); } else { return null; } return null; Conn.Close(); }
void CListView1DoubleClick(object sender, EventArgs e) { foreach(ListViewItem D in cListView1.Items) { if(D.ForeColor == Color.LightGreen) { D.BackColor=PlaylistBackground(); D.ForeColor=PlaylistForeColor(); } } Song _Song = (Song)cListView1.SelectedItems[0].Tag; cListView1.SelectedItems[0].BackColor=Color.Black; cListView1.SelectedItems[0].ForeColor=Color.LightGreen; PlayItem(_Song.Path); currentTrack=_Song; }
/// <summary> /// When a media file is begin to play, it decides the player engine to use by the parameter a: /// </summary> /// <param name="Query"></param> /// public static bool PlayItem(String Query) { /* if (ResolvingSongThread != null) return false;*/ /// <summary> /// Stop the current player to play the media, but first /// be sure that there is a current instance of a class witihn the IMediaEngine /// </summary> if(currentPlayer!=null){ currentPlayer.Stop(); foreach(Control d in Program.Host.Playboard.Controls) { if(d.GetType() == currentPlayer.MediaControl.GetType()) { d.Hide(); } } } /// <summary> /// Get the engine namespace from the query passed /// </summary> string engine = Query.Split(':')[0]; try { Song _Song = GetSongFromURI(Query); if(_Song.ID != null && _Song.ID != "" && _Song.ProposedEngine != "" && _Song.ProposedEngine != null) { try { IPlayEngine Df = Program.MediaEngines[_Song.ProposedEngine]; MainForm.currentPlayer = Df; MainForm.currentPlayer.Load(Df.Namespace+":"+_Song.ID); MainForm.currentTrack = _Song; return true; } catch { } } } catch { } IPlayEngine D = null; if(Query.StartsWith("music:")||Query.StartsWith("song:")) { Song _Song = GetSongFromURI(Query); Uri d = new System.Uri(Query.Replace("music:","http:").Replace("song:","http:")); if(_Song.ID != null && _Song.ID != "" && _Song.ProposedEngine != "" && _Song.ProposedEngine != null) { try { IPlayEngine Df = Program.MediaEngines[_Song.ProposedEngine]; MainForm.currentPlayer = Df; MainForm.currentPlayer.Load(Df.Namespace+":"+_Song.ID); MainForm.currentTrack = _Song; return true; } catch { } } ResolvingSongThread = new Thread(MainForm._ResolveSong); ResolvingSongThread.Start((object)_Song); /*** * If a default service is assigned, try the service * before attempting to find it on other service * */ Querys = UriHelper.Querystrings(d); return true; } else { /// <summary> /// Get the player from the list /// </summary> /// if(Program.MediaEngines.ContainsKey(engine)) { D = Program.MediaEngines[engine]; } } if(D!=null) { D.MediaControl.Dock = DockStyle.Fill; D.MediaControl.Show(); D.MediaControl.Enabled=true; /// <summary> /// Remove the engine specification of the Query URI /// </summary> String Path = Query.Replace(engine+":",""); /// <summary> /// Send it to the media player /// </summary> D.Load((Path)); /// <summary> /// Play the media /// </summary> D.Play(); currentPlayer=D; } else { MessageBox.Show("There is no media handler for the media"); } return true; }
public void AddToPlaylist(string playlistID, Song _Song, int pos) { Spotify.Playlist List = Spotify.Playlist.Create(SpotifySession,Link.Create(playlistID)); if(List.Owner == SpotifySession.User) { Spotify.Track D = Track.CreateFromLink(Link.Create(_Song.Path.Replace("sp:",""))); List.AddTracks(new Track[]{D},pos); } }
public static bool Song_Exists(Song _Song) { if (Querys != null) if (Querys.ContainsKey("service")) { if (Program.MediaEngines.ContainsKey(Querys["service"])) { IPlayEngine Engine = Program.MediaEngines[Querys["service"]]; MainForm.Engine = Engine; MainForm.watchSong = Engine.RawFind(_Song); _Song.Checked = true; return true; /* */ } } /** * Elsewhere, iterate through installed music services * and check if there is a matching track to play the song on * */ foreach (IPlayEngine Engine in Program.MediaEngines.Values) { Song f = Engine.RawFind(_Song); if (f != null) { MainForm.Engine = Engine; _Song.Checked = true; MainForm.watchSong = f; return true; } /* currentTrack = f; currentPlayer = Engine; Engine.Load((currentTrack.Path)); currentTrack = _Song; Engine.Play(); */ } return false; }
public Song RawFind(Song _Song) { // TODO: Add handler later return null; }
public static Song GetSongFromQury(SQLiteDataReader D) { Song _Song = new Song(); _Song.Title=(String)D["name"]; _Song.Artist = (String)D["artist"]; _Song.Album = (String)D["album"]; _Song.Composer =(String)D["composer"]; _Song.Path =(String)D["path"]; _Song.Store = (String)D["store"]; _Song.Feature = (String)D["feature"]; _Song.Version = (String)D["version_"]; _Song.Contributing = (String)D["coartist"]; return _Song; }
public void AddToPlaylist(string playlistID, Song _Song, int pos) { throw new NotImplementedException(); }
public void AddToPlaylist(string playlistID, Song _Song, int pos) { }
public String RawFind(Song D) { SQLiteConnection Conn = MainForm.MakeConnection(); SQLiteCommand Command = new SQLiteCommand("SELECT path FROM song WHERE name = '"+D.Title+"' AND artist = '"+D.Artist+"'",Conn); SQLiteDataReader Reader = Command.ExecuteReader(); if(Reader.HasRows) { Reader.Read(); return ("mp3:"+Reader.GetString(0)); } else { return null; } }
public System.Collections.Generic.List<MediaChrome.Song> Find(string Query) { WebClient CN = new WebClient(); List<Song> songs = new List<Song>(); XmlDocument D = new XmlDocument(); D.Load("http://gdata.youtube.com/feeds/api/videos?q="+Query.Replace(" ","+")+"&v=1"); var Items = D.GetElementsByTagName("entry"); foreach(XmlElement Item in Items) { MediaChrome.Song _Song = new MediaChrome.Song(); String Name = Item.GetElementsByTagName("title")[0].InnerText; _Song.Title=Name; _Song.Artist="Youtube"; if(Name.Contains("-")) { String[] markup = Name.Split('-'); _Song.Title = markup[1].Trim(' '); _Song.Artist = markup[0].Trim(' '); } _Song.Path="youtube:"+((XmlElement)Item.GetElementsByTagName("link")[0]).GetAttribute("href"); _Song.Engine="youtube"; _Song.Store="Youtube"; songs.Add(_Song); } return songs; }
public static void UpdateListItem(Song R,ref ListViewItem item) { item.SubItems.Clear(); item.Text = R.Title; item.SubItems.Add(R.Version); item.SubItems.Add(R.Artist); item.SubItems.Add(R.Album); item.SubItems.Add(R.Feature); item.SubItems.Add(R.Contributing); item.SubItems.Add(R.Store); item.SubItems.Add(R.Composer); }
public Song RawFind(MediaChrome.Song _Song2) { WebClient CN = new WebClient(); List<Song> songs = new List<Song>(); XmlDocument D = new XmlDocument(); D.Load("http://gdata.youtube.com/feeds/api/videos?q=" + (_Song2.Title+" "+_Song2.Artist).Replace(" ", "+") + "&v=1"); var Items = D.GetElementsByTagName("entry"); foreach (XmlElement Item in Items) { MediaChrome.Song _Song = new MediaChrome.Song(); String Name = Item.GetElementsByTagName("title")[0].InnerText; _Song.Title = Name; _Song.Artist = "Youtube"; if (Name.Contains("-")) { String[] markup = Name.Split('-'); _Song.Title = markup[1].Trim(' '); _Song.Artist = markup[0].Trim(' '); } // http://www.youtube.com/apiplayer?enablejsapi=1&version=3 _Song.Path="youtube:"+((XmlElement)Item.GetElementsByTagName("link")[3]).GetAttribute("href").Replace("http://gdata.youtube.com/feeds/api/videos/","").Replace("?v=1",""); // _Song.Path = "youtube:" + ((XmlElement)Item.GetElementsByTagName("link")[0]).GetAttribute("href"); _Song.Engine = "youtube"; _Song.Store = "Youtube"; if (_Song.Title.Contains(_Song2.Title) && _Song.Title.Contains(_Song2.Artist)) return _Song; } return null; }