Exemplo n.º 1
0
        public void AddVideoToRandomPlaylist(string youtubeLink)
        {
            TVideo video = new TVideo();
            string vidID = TPlaylist.parseYTurl(youtubeLink);

            video = new TVideo {
                videoID = vidID
            };
            //if (!GetVideoInfo(video))
            //    randomPlaylist.playlist.Add();
        }
Exemplo n.º 2
0
        private void newPlaylistMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult resSave = MessageBox.Show("Save", "Save current playlist " + currentTPlaylist.name + "?", MessageBoxButtons.YesNoCancel);

            switch (resSave)
            {
            case DialogResult.Yes: currentTPlaylist.saveToFile(); break;

            case DialogResult.Cancel: return;
            }
            currentTPlaylist = new TPlaylist();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Queues a song for playing
        /// </summary>
        /// <param name="youtubeLink"></param>
        /// <returns>
        /// 0 - Success
        /// 1 - Invalid File
        /// 2 - Song too long
        /// </returns>
        public int QueueOrPlaySong(string youtubeLink, out TVideo video)
        {
            video = null;
            // InvokeRequired required compares the thread ID of the
            // calling thread to the thread ID of the creating thread.
            // If these threads are different, it returns true.
            if (this.textBox1.InvokeRequired)
            {
                PlaySongCallback d    = new PlaySongCallback(QueueOrPlaySong);
                object[]         args = new object[] { youtubeLink, video };
                int retVal            = (int)this.Invoke(d, args);
                video = (TVideo)args[1];
                return(retVal);
            }
            else
            {
                string vidID = TPlaylist.parseYTurl(youtubeLink);
                if (!string.IsNullOrWhiteSpace(vidID))
                {
                    video = new TVideo {
                        videoID = vidID
                    };
                    if (!GetVideoInfo(video))
                    {
                        return(1);
                    }

                    if (video.duration > 8 * 60)
                    {
                        return(2);
                    }
                    ;
                    currentTPlaylist.playlist.Add(video);
                    if (!currentTPlaylist.isPlaying)
                    {
                        currentTPlaylist.current = currentTPlaylist.playlist.Count - 1;
                        mediaLoadVideo(vidID);
                    }
                }
                else
                {
                    return(1);
                }
                return(0);
            }
        }
Exemplo n.º 4
0
        private void inserUrlMenuItem_Click(object sender, EventArgs e)
        {
            string value = "";

            if (InputBox.Show("Load video id", "&Enter youtube vidId:", ref value) == DialogResult.OK)
            {
                string vidId = TPlaylist.parseYTurl(value);
                if (!string.IsNullOrWhiteSpace(vidId))
                {
                    Console.Write("loadUrl: " + vidId);
                    mediaLoadVideo(vidId);
                }
                else
                {
                    MessageBox.Show("invalid Video Id \"" + vidId + "\"");
                }
            }
        }
Exemplo n.º 5
0
        private void urlToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string value = "";

            if (InputBox.Show("Load video id", "&Enter youtube vidId:", ref value) == DialogResult.OK)
            {
                Console.Write("loadUrl: " + value);
                string vidID = TPlaylist.parseYTurl(value);
                if (string.IsNullOrWhiteSpace(vidID))
                {
                    MessageBox.Show("invalid URL or vidId");
                }
                else
                {
                    currentTPlaylist.playlist.Add(new TVideo {
                        videoID = vidID
                    });
                }
            }
        }