示例#1
0
        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;
        }
示例#2
0
        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;
            }
        }
示例#3
0
        public System.Collections.Generic.List<CDON.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)
            {
                CDON.Song _Song = new CDON.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;
        }
示例#4
0
 public void AddToPlaylist(string playlistID, Song _Song, int pos)
 {
     throw new NotImplementedException();
 }
示例#5
0
 public String RawFind(Song _Song)
 {
     // TODO: Add handler later
     return null;
 }
示例#6
0
 public void AddToPlaylist(string playlistID, Song _Song, int pos)
 {
 }
示例#7
0
 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);
     }
 }
示例#8
0
        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(1200000));

            try{
                foreach(Track Df in D.Tracks)
                {
                    Song A = new CDON.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.Engine="sp";
                    Songs.Add(A);

                }
            }catch{

            }
            return Songs;
        }
示例#9
0
        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;
        }
示例#10
0
 public static ListViewItem SongToItem(Song I)
 {
     ListViewItem D = new ListViewItem(I.Title);
     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;
 }
示例#11
0
        /// <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");
            }
        }
示例#12
0
        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);
        }
示例#13
0
        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;
        }