コード例 #1
0
        /// <summary>
        /// load a playlist from a M3U file
        /// </summary>
        private void LoadPlaylistFromFile()
        {
            string lblAudioFileType = rm.GetString("plAudioFilterType");

            using (var ofd = new OpenFileDialog {
                Filter = lblAudioFileType + " (*.m3u)|*.m3u", Title = rm.GetString("openPlDlgTitle")
            })
            {
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    _m3uFile = null;

                    try
                    {
                        _m3uFile = new M3UFile();
                        _m3uFile.Load(ofd.FileName);
                        //parent.IsPlaylistRunning = true;
                    }
                    catch (Exception)
                    {
                        //parent.IsPlaylistRunning = false;
                        MessageBox.Show("Error loading playlist from file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    PopulateEntries();
                    if (l.Items.Count > 0)
                    {
                        parent.IsPlaylistRunning = true;
                        lastFileIdx = -1;

                        lblPlistInfo.Text = string.Format("{0} files.",
                                                          l.Items.Count);
                        lblPlistInfo.Visible  = true;
                        this.btnClear.Enabled = true;
                        this.btnSave.Enabled  = true;

                        //PlaylistLoaded(this, null);
                        //lblPlistInfo.Text += string.Format(", Total Time: {0}:{1}",
                        //    (int)totPlaylistTime / 60, (int)totPlaylistTime % 60);
                        //StartPlaying(l.Items[0].Text, 0);
                    }
                    else
                    {
                        lblPlistInfo.Text = string.Format("{0} files.", 0);
                    }
                    PlaylistLoaded(this, null);
                }
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: andeerson/M3U.NET
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            using (var ofd = new OpenFileDialog {
                Filter = "M3U File (*.m3u)|*.m3u", Title = "Open Playlist"
            })
            {
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    _m3uFile = null;

                    try
                    {
                        _m3uFile = new M3UFile();
                        _m3uFile.Load(ofd.FileName);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    PopulateEntries();
                }
            }
        }