コード例 #1
0
        public bool addToTempPlaylist(Playlist playlist,ISession session)
        {
            try
            {
                // Prepare and bind statement passing in the relevant fields
                String todo = ("insert into playlist (track_id,playlist_id,track_pos)\n" +
                 "values (:tid, :pid,:tpos) if not exists using ttl 3600;");
                PreparedStatement ps = session.Prepare(todo);

                // Getting Appropriate ID's for query
                Guid pid = playlist.getID();

                List<Song> songs = playlist.getSongs();

                for (int i = 0; i < songs.Count(); i++)
                {
                    Guid tid = songs[i].getSongID();
                    int pos = getListPos(session, tid, pid);
                    BoundStatement bs = ps.Bind(tid, pid, pos);
                    // Execute Query
                    session.Execute(bs);
                }

                return false;
                // Catch exceptions
            }
            catch (Exception ex)
            {
                Console.WriteLine("SOMETHING WENT WRONG add to temp playlist: " + ex.Message);
                return false;
            }
        }
コード例 #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="playlist"></param>
        /// <param name="song"></param>
        /// <returns></returns>
        public bool addSongToPlaylist(Playlist playlist, Song song)
        {
            try
            {
                // Call to initialise cluster connection
                //init();

                // Connect to cluster
                ISession session = cluster.Connect("maltmusic");

                // Prepare and bind statement passing in the relevant fields
                String todo = ("insert into playlist (track_id,playlist_id,track_pos)\n" +
                 "values (:tid, :pid,:tpos) if not exists;");
                PreparedStatement ps = session.Prepare(todo);

                // Getting Appropriate ID's for query
                Guid tid = song.getSongID();
                Guid pid = playlist.getID();

                // Matt - change this
                // done
                int pos = getListPos(session, tid, pid);

                BoundStatement bs = ps.Bind(tid, pid, pos);

                // Execute Query
                session.Execute(bs);

                return true;

                // Catch exceptions
            }
            catch (Exception ex)
            {
                Console.WriteLine("SOMETHING WENT WRONG add to playlist: " + ex.Message);
                return false;
            }
        }
コード例 #3
0
        //Plays the song the user selected
        private void lblPlay_Click(object sender, EventArgs e)
        {
            Song toAdd = new Song();

            //Parse song
            String[] tmp = selectedSong.Split(',');
            int x = int.Parse(tmp[0]);
            int y = int.Parse(tmp[1]);

            String songName = songLabelsName[x][y].Text;

            for (int i = 0; i < songs.Count; i++)
            {
                if (songs[i].getTrackName().Equals(songName))
                {
                    toAdd = songs[i];
                    break;
                }
            }

            if (toAdd.getTrackName() != null && toAdd.getTrackName() != "")
            {
                //Stop currently playing song
                String filePath = toAdd.getFileLocation();
                musicPlayer.stopSong();

                //Load album art
                String imagePath = "../../tracks/" + toAdd.getArtist() + "/" + toAdd.getAlbum() + "/" + toAdd.getAlbum() + ".jpg";

                //Send song to music player
                Playlist toPlay = new Playlist();
                toPlay.addSongs(toAdd);
                musicPlayer.setPlaylist(toPlay, 0);
                musicPlayer.playCurrentSong();

            }
            pnlOptions.Visible = false;
        }
コード例 #4
0
 // NOT SURE ABOUT THIS ONE - Facebook, Twitter, Email?
 public void sharePlaylist(Playlist playlist)
 {
     throw new NotImplementedException();
 }
コード例 #5
0
 public void savePlaylist(Playlist playlist, User newUser)
 {
     // Get details of current playlist
     // Create new playlist, same name different owner
     String newOwner = newUser.getUsername();
     Guid newID = Guid.NewGuid();
     playlist.setOwner(newOwner);
     playlist.setGuid(newID);
     List<Song> tracks = playlist.getSongs();
     createPlaylist(playlist);
     populatePlaylist(playlist, tracks);
 }
コード例 #6
0
        //
        public void renamePlaylist(Playlist playlist, String newName)
        {
            try
            {
                //init();
                // Connect to cluster
                ISession session = cluster.Connect("maltmusic");

                // get playlist id and owner
                Guid play_id = playlist.getID();
                String owner = playlist.getOwner();

                // Delete Playlist with old name
                String todo = "delete from list_playlist WHERE playlist_id = :pid";
                PreparedStatement ps = session.Prepare(todo);
                BoundStatement bs = ps.Bind(play_id);
                session.Execute(bs);

                // Recreate playlist with new name, same old id
                // Slightly hacky way of updating a primary key
                String insert = "insert into list_playlist (\n" +
                      "playlist_id, owner,playlist_name)\n" +
                     "values (:pid,:own,:plnm) if not exists";
                PreparedStatement preps = session.Prepare(insert);
                BoundStatement bounds = preps.Bind(play_id, owner, newName);
                session.Execute(bounds);

            }
            catch (Exception ex)
            {
                Console.WriteLine("Renaming a plist broke " + ex);
            }
        }
コード例 #7
0
 /// <summary>
 /// Sets the playlists of songs
 /// </summary>
 /// <param name="incomingPlaylist">The playlist to be played</param>
 /// <param name="playIndex">The starting position of the playlist (ie. track 3)</param>
 public void setPlaylist(Playlist incomingPlaylist, int playIndex)
 {
     // Sets the incoming playlist parameters
     activePlaylist = incomingPlaylist;
     playlistIndex = playIndex;
 }
コード例 #8
0
        private void lblPlay_Click(object sender, EventArgs e)
        {
            if (selectedSong > -1)
            {
                songLabelsA[selectedSong].BackColor = Color.FromArgb(255, 50, 50);
                songLabelsB[selectedSong].BackColor = Color.FromArgb(255, 50, 50);
                songLabelsC[selectedSong].BackColor = Color.FromArgb(255, 50, 50);
                songLabelsD[selectedSong].BackColor = Color.FromArgb(255, 50, 50);

                String filePath = songList[selectedSong].getFileLocation();
                String imagePath = "../../tracks/" + songList[selectedSong].getArtist() + "/" + songList[selectedSong].getAlbum() + "/" + songList[selectedSong].getAlbum() + ".jpg";
                musicPlayer.stopSong();

                Playlist toPlay = new Playlist();
                toPlay.addSongs(songList[selectedSong]);

                musicPlayer.setPlaylist(toPlay, 0);
                musicPlayer.playCurrentSong();
            }
        }
コード例 #9
0
        public void deletePlaylist(Playlist playlist)
        {
            try
            {
                //init();
                // Connect to cluster
                ISession session = cluster.Connect("maltmusic");

                // get playlist id
                Guid play_id = playlist.getID();

                // First empty the playlist by ID
                //Prepare, bind and execute statement
                String todo = "delete from playlist where playlist_id = :pid";
                PreparedStatement ps = session.Prepare(todo);
                BoundStatement bs = ps.Bind(play_id);
                session.Execute(bs);

                // After emptying the playlist, delete the ID from the list
                // Prepae, bind and execute statement
                String next = "delete from list_playlist where playlist_id = :pid";
                PreparedStatement p = session.Prepare(next);
                BoundStatement b = p.Bind(play_id);
                session.Execute(b);

            }
            catch (Exception ex)
            {
                Console.WriteLine("Deleting a plist broke " + ex);
            }
        }
コード例 #10
0
        /// <summary>
        ///     FUNCTION TO GET A PLAYLIST BASED ON ITS NAME
        /// </summary>
        /// <param name="plname">The name of the playlist</param>
        /// <param name="owner">The owner of the playlist</param>
        /// <returns>A playlist object - the found playlist</returns>
        public Playlist getPlaylist(String plname, String owner)
        {
            try
            {
                // Call to initialise cluster connection
                //init();
                // Connect to cluster
                ISession session = cluster.Connect("maltmusic");

                //plname = plname.ToLower();

                String todo = ("select * from list_playlist where playlist_name = :plnm AND owner = :own ALLOW FILTERING");
                PreparedStatement ps = session.Prepare(todo);
                BoundStatement bs = ps.Bind(plname, owner);
                // Execute Query
                RowSet rows = session.Execute(bs);
                foreach (Row row in rows)
                {
                    Playlist toGet;

                    // Get Things
                    Guid pid = (Guid)row["playlist_id"];
                    String theOwner = row["owner"].ToString();

                    List<Song> songs = new List<Song>();
                    songs = getTracksInPlist(pid, session);
                    //Playlist is name, ID user, songs
                    toGet = new Playlist(plname, pid, theOwner, songs);

                    return toGet;
                }
                return null;
            }
            catch (Exception e){
                Console.WriteLine("Errors Occured In here " + e);
                return null;
            }
        }
コード例 #11
0
        public void createTempPlaylist(Playlist p)
        {
            try
            {
                //init();
                ISession session = cluster.Connect("maltmusic");

                String plName = p.getPlaylistName();
                Guid pid = p.getID();
                String owner = p.getOwner();

                String todo = ("insert into list_playlist (\n" +
                      "playlist_id, owner,playlist_name)\n" +
                     "values (:pid,:own,:plnm) if not exists using TTL 3600");

                PreparedStatement ps = session.Prepare(todo);

                BoundStatement bs = ps.Bind(pid, owner, plName);

                session.Execute(bs);

                addToTempPlaylist(p, session);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception during playlist create" + e);
            }
        }
コード例 #12
0
ファイル: HomePage.cs プロジェクト: andrewdavis1995/MALTMusic
        //Method to open single playlist view
        public void showViewPlaylist(Playlist playlist)
        {
            hideForms();

            viewPlaylist = new ViewPlaylist(playlist, this.musicPlayer, this.currentUser, this);

            viewPlaylist.TopLevel = false;
            viewPlaylist.Parent = this;
            viewPlaylist.setupAlbumCovers(playlist.getSongs());
            viewPlaylist.setupLabels();

            viewPlaylist.FormBorderStyle = FormBorderStyle.None;
            viewPlaylist.Size = new Size(1092, 392);

            picBoxBackground.Hide();
            viewPlaylist.Show();
        }
コード例 #13
0
        public ViewPlaylist(Playlist playlist, frmMusicPlayer music, User currentUser, HomePage parent)
        {
            InitializeComponent();

            picSave.Visible = true;

            //Set player, playlist, user
            this.musicPlayer = music;
            this.currentUser = currentUser;
            this.thePlaylist = playlist;
            lblPlaylistName.Text = thePlaylist.getPlaylistName();
            lblOwner.Text = thePlaylist.getOwner();
            this.parent = parent;

            //Initially hide edit box
            txtPlaylistNameEdit.Hide();

            List<Song> songs = thePlaylist.getSongs();
            int numSongs = thePlaylist.getSongs().Count;

            lblNumSongs.Text = numSongs.ToString();

            if (numSongs == 1) { lblNumSongs.Text += " song"; } else { lblNumSongs.Text += " songs"; }

            //Get total playlist length
            int totalLength = 0;
            for (int i = 0; i < songs.Count; i++)
            {
                totalLength += songs[i].getLength();
            }

            int hours = totalLength / 3600;
            int minutes = (totalLength - hours * 3600) / 60;
            int seconds = totalLength - (hours * 3600) - (minutes * 60);

            //Set up string saying how long the playlist is
            String output = "";
            if(hours > 0)
            {
                output += hours.ToString() + " hours, \n";
            }
            if (minutes > 0)
            {
                output += minutes.ToString() + " minutes, \n";
            }
            if (seconds > 0)
            {
                output += seconds.ToString() + " seconds, \n";
            }

            if (output.Equals(""))
            {
                output = "O seconds";
            }
            else {
                output = output.Substring(0, output.Length - 3);
            }

            //Set length to label
            lblTime.Text = output;

            String currUser = this.currentUser.getUsername();
            String owner = thePlaylist.getOwner();

            String first6 = "";

            if (!(thePlaylist.getPlaylistName().Length < 6))
            {
                first6 = thePlaylist.getPlaylistName().Substring(0, 6);
            }

            if (currUser.Equals(owner) && first6 != "" )
            {
                if (first6.Equals("$temp$"))
                {
                    lblPlaylistName.Text = thePlaylist.getPlaylistName().Substring(6);
                    thePlaylist.setName(thePlaylist.getPlaylistName().Substring(6));
                }
                else {
                    picSave.Visible = false;
                }
                picRecommend.Visible = true;
                picPlay.Left = lblPlaylistName.Left + lblPlaylistName.Width + 10;
            }
            else
            {
                picSave.Left = lblPlaylistName.Left + lblPlaylistName.Width + 10;
                picPlay.Left = lblPlaylistName.Left + lblPlaylistName.Width + 15 + picSave.Width;
                picRecommend.Visible = false;
            }
        }
コード例 #14
0
        private void picPlay_Click(object sender, EventArgs e)
        {
            musicPlayer.stopSong();
            tmrPreview.Start();

            Playlist playlist = new Playlist();
            playlist.addSongs(songList[selectedSong]);

            musicPlayer.setPlaylist(playlist, 0);
            musicPlayer.playCurrentSong();
        }
コード例 #15
0
        public void populatePlaylist(Playlist p, List<Song> s)
        {
            try
            {
                // Call to initialise cluster connection
                //init();
                // Connect to cluster
                ISession session = cluster.Connect("maltmusic");

                Guid pid = p.getID();

                // Prepare and bind statement passing in the relevant fields
                String todo = ("insert into playlist (track_id,playlist_id,track_pos)\n" +
                 "values (:tid, :pid,:tpos) if not exists;");
                PreparedStatement ps = session.Prepare(todo);
                Guid tid = new Guid();
                for (int i = 0; i < s.Count; i++)
                {
                    tid = s[i].getSongID();
                    int pos = getListPos(session, tid, pid);
                    BoundStatement bs = ps.Bind(tid, pid, pos);

                    // Execute Query
                    session.Execute(bs);
                }
                // Catch exceptions
            }
            catch (Exception ex)
            {
                Console.WriteLine("SOMETHING WENT WRONG populate playlist: " + ex.Message);
                //return false;
            }
        }
コード例 #16
0
 public void setSongs(List<Song> songs, Playlist playlist)
 {
     this.songList = songs;
     this.thePlaylist = playlist;
     createLabels(0);
 }
コード例 #17
0
        public void removeSongFromPlaylist(Playlist playlist, Song song)
        {
            try
            {
                //init();
                // Connect to cluster
                ISession session = cluster.Connect("maltmusic");

                // get playlist id
                // get track id
                Guid play_id = playlist.getID();
                Guid track_id = song.getSongID();

                String todo = "delete from playlist where playlist_id = :pid and track_id = :tid";
                PreparedStatement ps = session.Prepare(todo);
                BoundStatement bs = ps.Bind(play_id, track_id);
                session.Execute(bs);
            }
            catch (Exception e)
            {
                Console.WriteLine("Removing from a plist broke " + e);
            }
        }
コード例 #18
0
ファイル: Login.cs プロジェクト: andrewdavis1995/MALTMusic
        private void cmdCreatePlaylist_Click(object sender, EventArgs e)
        {
            String playlist = Microsoft.VisualBasic.Interaction.InputBox("Playlist Name: ", "Playlist Name");
            String owner = Microsoft.VisualBasic.Interaction.InputBox("Owner: ", "Owner");
            Guid id = Guid.NewGuid();
            List<Song> songs = new List<Song>();

            Playlist newPlaylist = new Playlist(playlist, id, owner, songs);

            PlaylistModel playlistModel = new PlaylistModel();
            playlistModel.createPlaylist(newPlaylist);
        }
コード例 #19
0
        private void cmdCreatePlaylist_Click(object sender, EventArgs e)
        {
            String playlist = Microsoft.VisualBasic.Interaction.InputBox("Playlist Name: ", "Playlist Name");
            Guid id = Guid.NewGuid();
            List<Song> songs = new List<Song>();

            Playlist newPlaylist = new Playlist(playlist, id, this.currentUser, songs);

            PlaylistModel playlistModel = new PlaylistModel();
            playlistModel.createPlaylist(newPlaylist);
            playlists.Add(newPlaylist);

            #region createLabel
            int count = playlists.Count - 1;
            Label newLabel = new Label();
            newLabel.Text = newPlaylist.getPlaylistName();
            newLabel.Size = new Size(400, 30);
            newLabel.ForeColor = Color.White;
            newLabel.Tag = count.ToString();
            newLabel.Click += playlistSelected;
            if (count % 2 == 0) { newLabel.BackColor = Color.FromArgb(20, 20, 20); } else { newLabel.BackColor = Color.FromArgb(60, 60, 60); }
            newLabel.Location = new Point(290, 120 + (count * 30));
            newLabel.Font = new System.Drawing.Font("Franklin Gothic Medium", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

            labelList.Add(newLabel);

            this.Controls.Add(labelList[count]);

            #endregion

            #region createLabelRemove
            PictureBox deleteButton = new PictureBox();
            deleteButton.Size = new Size(20, 20);
            deleteButton.Tag = count.ToString();
            deleteButton.Click += deletePlaylist;
            deleteButton.BackgroundImage = Properties.Resources.removeFromPlaylist;
            deleteButton.BackgroundImageLayout = ImageLayout.Stretch;
            deleteButton.Location = new Point(700, 125 + (count * 30));

            deleteLabels.Add(deleteButton);

            this.Controls.Add(deleteLabels[count]);

            #endregion
        }