Exemple #1
0
        /// <summary>
        /// Event for watching when videos finish
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MediaPlayer_MediaEnded(object sender, RoutedEventArgs e)
        {
            // Get the current video path
            string file = this.MediaPlayer.Source.LocalPath;

            // Try to stop it and set the source to null
            try
            {
                this.MediaPlayer.Stop();
            }
            catch { }
            this.MediaPlayer.Source = null;
            // Try to dump the file and set the string storing previous song to where we stored this
            try
            {
                if (videofile != null)
                {
                    if (videofile != string.Empty)
                    {
                        if (System.IO.Path.GetFileName(videofile) != System.IO.Path.GetFileName(this.MediaPlayer.Source.AbsoluteUri))
                        {
                            Task.Run(() => FileFunctions.DeleteTmpFile(file));
                        }
                    }
                }
                videofile = this.MediaPlayer.Source.OriginalString;
            }
            catch { }
            // Queue the next song and hit play
            SongFunctions.Queueevent(this, hidb, db, discordclient, conf);
            this.MediaPlayer.Play();
        }
Exemple #2
0
 /// <summary>
 /// Function to manually add a song to play
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void PlayManual_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         // Get the text from the textbox and request it
         var url = this.video.Text;
         Task.Run(() => SongFunctions.ManualRequest(url, this, hidb, db, discordclient, conf));
     }
     catch { }
 }
Exemple #3
0
 /// <summary>
 /// If a username is double clicked on in the UI it will play that song
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void SongDoubleClick(object sender, RoutedEventArgs e)
 {
     // Get the selected item
     if (this.SongList.SelectedItem != null)
     {
         // Trigger the queue to play the next song
         Song item = this.SongList.SelectedItem as Song;
         Task.Run(() => SongFunctions.TriggerqueueAsync(item, this, hidb, db, discordclient, conf));
         try
         {
             // Trigger the queue to be updated in the UI
             Task.Run(() => SongFunctions.UpdateQueueList(db, AllQueue, this));
         }
         catch { }
     }
 }
Exemple #4
0
 /// <summary>
 /// Timer to update preloading and the queue and the slider info
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private async void DispatcherTimer_Tick(object sender, EventArgs e)
 {
     try
     {
         // Update the progress textbox
         if (Util.GetMediaState(this.MediaPlayer) == MediaState.Play)
         {
             await this.Progress.Dispatcher.BeginInvoke((Action)(() => Progress.Content = this.MediaPlayer.Position.Hours.ToString("D2") + ":" + this.MediaPlayer.Position.Minutes.ToString("D2") + ":" + this.MediaPlayer.Position.Seconds.ToString("D2")));
         }
     }
     catch { }
     try
     {
         // Update the queue list
         _ = Task.Run(() => SongFunctions.UpdateQueueList(db, AllQueue, this));
     }
     catch { }
     try
     {
         // Pre download the videos
         _ = Task.Run(() => SongFunctions.PreloadVideos(db));
     }
     catch { }
     try
     {
         // Keep the slider in sync
         _ = Task.Run(() => Sliderticktock());
     }
     catch { }
     try
     {
         _ = Task.Run(() => TotalDurationUpdate());
     }
     catch { }
     try
     {
         _ = Task.Run(() => UpdateFavIconAsync());
     }
     catch { }
 }
Exemple #5
0
 /// <summary>
 /// Function to trigger the next song
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void PlayNext_Click(object sender, RoutedEventArgs e)
 {
     SongFunctions.Queueevent(this, hidb, db, discordclient, conf);
 }
Exemple #6
0
 /// <summary>
 /// Button to trigger to play the last song again
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void PlayPrevious_Click(object sender, RoutedEventArgs e)
 {
     Task.Run(() => SongFunctions.Playprevious(this, hidb, db, discordclient, conf));
 }