public void AcceptChange()
        {
            if (MainTabs != null && MainTabs.SelectedTab != null)
            {
                MainTabs.SelectedTab.Text = Text;
            }
            else if (SubItemIndex >= 0)
            {
                var tab = Item.ListView.Parent as MusicTab;
                if (tab == null)
                {
                    return;
                }

                foreach (int Index in PlaylistView.SelectedIndices)
                {
                    var Item = PlaylistView.Items[Index];
                    Item.SubItems[SubItemIndex].Text = Text;
                    tab.AfterSubItemEdit(Item);
                }
            }

            KillTextBox();
            MainWindow.SavePlaylists();
        }
示例#2
0
        private void PlaylistView_DragDrop(object sender, DragEventArgs e)
        {
            List <Track> tracksList = new List <Track>();

            if (e.Data.GetDataPresent(typeof(List <ListViewItem>)))
            {
                List <ListViewItem> ItemsList = e.Data.GetData(typeof(List <ListViewItem>)) as List <ListViewItem>;
                tracksList = MakeTracksList(ItemsList);
            }
            else if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] FilesArray = e.Data.GetData(DataFormats.FileDrop, false) as string[];
                tracksList = MakeTracksList(FilesArray);
            }
            else if (e.Data.GetDataPresent(DataFormats.Text))
            {
                string Html = e.Data.GetData(DataFormats.Text) as string;
                tracksList = MakeTracksList(Html);
            }
            else
            {
                Debug.WriteLine(e.Data.ToString());
            }

            AddTrack(tracksList, DropIndex);
            Refresh();
            MainWindow.SavePlaylists();
        }
        private void PlaylistView_DragDrop(object sender, DragEventArgs e)
        {
            var tracksList = new List <Track>();

            if (e.Data.GetDataPresent(typeof(List <ListViewItem>)))
            {
                var ItemsList = e.Data.GetData(typeof(List <ListViewItem>)) as List <ListViewItem>;
                tracksList = MakeTracksList(ItemsList);
            }
            else if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                var FilesArray = e.Data.GetData(DataFormats.FileDrop, false) as string[];
                tracksList = MakeTracksList(FilesArray);
            }
            else if (e.Data.GetDataPresent(DataFormats.Text))
            {
                var Html = e.Data.GetData(DataFormats.Text) as string;
                tracksList = MakeTracksList(Html);
            }
            else if (e.Data.GetDataPresent(typeof(List <Thumbnail>)))
            {
                var thumbnails = e.Data.GetData(typeof(List <Thumbnail>)) as List <Thumbnail>;
                tracksList = DropThumbnail(thumbnails);
                MainWindow.Instance.ResultsPage.DeselectAll();
            }

            AddTrack(tracksList, DropIndex);
            Refresh();
            MainWindow.SavePlaylists();
        }
示例#4
0
 public override void Refresh()
 {
     base.Refresh();
     RefreshPlaylistView();
     if (Application.OpenForms.Count == 0)
     {
         return;
     }
     MainWindow.SavePlaylists();
 }
示例#5
0
        public void RemoveSelectedTracks()
        {
            List <int> SelectedIndices = new List <int>();

            foreach (int n in PlaylistView.SelectedIndices)
            {
                SelectedIndices.Add(n);
            }
            RemoveTrack(SelectedIndices);
            MainWindow.SavePlaylists();
        }
示例#6
0
        private void addYoutubePlaylistToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddPlaylistForm form = new AddPlaylistForm();

            form.ShowDialog();
            List <Track> Tracks      = form.Tracks;
            MusicPage    currentPage = MainTabs.SelectedTab as MusicPage;

            currentPage.musicTab.AddTrack(Tracks);
            MainWindow.SavePlaylists();
        }
示例#7
0
 private void AcceptChange()
 {
     if (MainTabs != null && MainTabs.SelectedTab != null)
     {
         MainTabs.SelectedTab.Text = this.Text;
     }
     else if (subItem != null)
     {
         subItem.Text = this.Text;
         if (Item != null)
         {
             MusicTab tab = Item.ListView.Parent as MusicTab;
             tab?.AfterSubItemEdit(Item);
         }
     }
     KillTextBox();
     MainWindow.SavePlaylists();
 }
示例#8
0
        public async Task Play(Track track)
        {
            if (track == null)
            {
                MainWindow.Instance.SetDefaultTitle();
            }
#if DEBUG
            DownloadTrack(track);
#else
            await DownloadTrack(track);
#endif
            MainWindow.SavePlaylists();

            musicPlayer.CurrentTab   = this;
            musicPlayer.CurrentTrack = track;
            musicPlayer.Stop();
            musicPlayer.Load(track);

            musicPlayer.Play();
        }
示例#9
0
        public void Play(int Index)
        {
            if (Index >= Tracks.Count || Index < 0)
            {
                return;
            }
            Track track = Tracks[Index];

            if (track.IsOnline || track.IsOffline)
            {
                track.Download();
                PlaylistView.Items[Index] = track.GetListViewItem(PlaylistView);
                MainWindow.SavePlaylists();
            }
            musicPlayer.CurrentTab   = this;
            musicPlayer.CurrentTrack = track;
            musicPlayer.Stop();
            musicPlayer.Load(track, this);
            musicPlayer.Play();
            //RemoveTrack(Index);
        }
示例#10
0
        private void addDirectoryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
            folderBrowserDialog.RootFolder = Environment.SpecialFolder.MyComputer;
            folderBrowserDialog.ShowNewFolderButton = false;
            DialogResult result = folderBrowserDialog.ShowDialog();
            if (result != DialogResult.OK) return;
            //{
            MusicPage CurrentTab = MainTabs.SelectedTab as MusicPage;

            string[] FileNames = new string[] { folderBrowserDialog.SelectedPath };

            //    Debug.WriteLine(folderBrowserDialog.SelectedPath);

            //    CurrentTab.musicTab.AddTrack(FileNames);
            //}
            //SavePlaylists();


            List<Track> trackList = MusicTab.MakeTracksList(FileNames);
            CurrentTab?.musicTab?.AddTrack(trackList);
            MainWindow.SavePlaylists();
        }
示例#11
0
        public static async Task ConvertToMp3(Track track)
#endif
        {
            CheckBinary();

            if (string.IsNullOrWhiteSpace(track.filePath))
            {
                return;
            }
            if (!File.Exists(track.filePath))
            {
                return;
            }
            if (!string.Equals(Path.GetExtension(track.filePath), ".m4a", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }
            var f             = TagLib.File.Create(track.filePath);
            var TotalDuration = f.Properties.Duration.TotalSeconds;

            var TemporaryOutput = Path.GetTempFileName();

            TemporaryOutput = Path.ChangeExtension(TemporaryOutput, ".mp3");

            var progressBar = YoutubeDL.CreateProgressBar(track);

            var process   = new Process();
            var startInfo = new ProcessStartInfo();

            startInfo.WindowStyle                    = ProcessWindowStyle.Hidden;
            startInfo.FileName                       = ffmpegDir;
            startInfo.Arguments                      = "-i \"" + track.filePath + "\"";
            startInfo.Arguments                     += " -acodec libmp3lame -ab 128k -y ";
            startInfo.Arguments                     += "\"" + TemporaryOutput + "\"";
            process.StartInfo                        = startInfo;
            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError  = true;
            process.StartInfo.WindowStyle            = ProcessWindowStyle.Hidden;
            process.StartInfo.CreateNoWindow         = true;
            process.Start();

            var reader = process.StandardError;

            while (!process.HasExited)
            {
#if DEBUG
                String str = reader.ReadLine();
#else
                var str = await reader.ReadLineAsync();
#endif
                if (string.IsNullOrWhiteSpace(str))
                {
                    continue;
                }
                var match = Regex.Match(str, @"time=(\d\d):(\d\d):(\d\d)");
                if (match.Success && match.Groups.Count == 4)
                {
                    var Hours   = match.Groups[1].ToString();
                    var Minutes = match.Groups[2].ToString();
                    var Seconds = match.Groups[3].ToString();

                    var Duration = int.Parse(Hours) * 3600 + int.Parse(Minutes) * 60 + int.Parse(Seconds);
                    Debug.WriteLine(Duration + " " + TotalDuration);
                    var Percent = (int)(Duration * 100 / TotalDuration);
                    //YoutubeDL.UpdateProgressBar(track, Percent);
                    Debug.WriteLine("{0} {1} {2}", Hours, Minutes, Seconds);
                }
            }
            YoutubeDL.RemoveProgressBar(track);
            if (File.Exists(TemporaryOutput))
            {
                var finalOutput = Path.GetDirectoryName(track.filePath) + "\\" +
                                  Path.GetFileNameWithoutExtension(track.filePath) + ".mp3";
                if (File.Exists(finalOutput))
                {
                    File.Delete(finalOutput);
                }
                File.Move(TemporaryOutput, finalOutput);
                if (File.Exists(finalOutput))
                {
                    track.filePath = finalOutput;
                    track.UpdateItem();
                }
            }

            MainWindow.SavePlaylists();
        }
示例#12
0
        public static async Task DownloadTrack(Track track)
#endif
        {
            if (track == null)
            {
                return;
            }
            if (!track.IsOnline)
            {
                return;
            }

#if !DEBUG
            DownloadManager.Counter++;
#endif

            CreateProgressBar(track);

            if (File.Exists(TemporaryPath(track)))
            {
                File.Delete(TemporaryPath(track));
            }
            ProcessStart(track, "-o " + TemporaryPath(track), out var process);
            var reader = process.StandardOutput;
            while (!process.HasExited)
            {
#if DEBUG
                String output = reader.ReadLine();
#else
                var output = await reader.ReadLineAsync();
#endif
                if (string.IsNullOrWhiteSpace(output))
                {
                    continue;
                }
                Debug.WriteLine(output);
                var r = new Regex(@"\[download]\s*([0-9.]*)%", RegexOptions.IgnoreCase);
                var m = r.Match(output);
                if (m.Success)
                {
                    var  g    = m.Groups[1].ToString();
                    bool flag = double.TryParse(g, out double result);
                    if (flag)
                    {
                        UpdateProgressBar(track, Convert.ToInt32(result));
                    }
                }
            }

            ProcessStart(track, "--get-filename", out var process2);

            string name;
            reader = process2.StandardOutput;
            {
#if DEBUG
                String output = reader.ReadToEnd();
#else
                var output = await reader.ReadToEndAsync();
#endif
                var str = output.Split('\n');
                name = str[0];
            }

            RemoveProgressBar(track);

            if (File.Exists(TemporaryPath(track)))
            {
                track.filePath = TemporaryPath(track);
                var outputDir = MainWindow.Instance.Options.DefaultDirectory + "\\" + name;
                if (File.Exists(outputDir))
                {
                    try
                    {
                        File.Delete(outputDir);
                    }
                    catch
                    {
                        // ignored
                    }
                }
                File.Move(TemporaryPath(track), outputDir);
                if (File.Exists(outputDir))
                {
                    track.filePath = outputDir;
                }
                track.OfflineToLocalData();
                track.UpdateItem();
            }
            else
            {
                track.MusicTab.PlaylistView.Items.Remove(track.Item);
                track.MusicTab.Tracks.Remove(track);
            }

#if !DEBUG
            DownloadManager.Counter--;
#endif
            MainWindow.SavePlaylists();
        }
示例#13
0
 public override void Refresh()
 {
     base.Refresh();
     RefreshPlaylistView();
     MainWindow.SavePlaylists();
 }
示例#14
0
 private void Button1_Click(object sender, EventArgs e)
 {
     PlaylistURL = textBox1.Text;
     GetPlaylist(PlaylistURL);
     MainWindow.SavePlaylists();
 }