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;
            }
        }
Beispiel #2
0
        //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();
        }
 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);
 }
        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;
            }
        }