예제 #1
0
파일: frmMain.cs 프로젝트: CarverLab/Oyster
        //ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/wmplay/mmp_sdk/asx_elementsintro.htm
        //ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/wmplay/mmp_sdk/metafileplaylists.htm
        // describes how metafiles (playlists) minimize buffering when stored in a playlist file
        private void playbackControls1_PlayClick(object sender, System.EventArgs e)
        {
            if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsPlaying)
            {
                this.playbackControls1.SwitchToPauseButton();
                axWindowsMediaPlayer1.Ctlcontrols.pause();
                return;
            }
            //WMPLib.IWMPMedia3 media;
            OCL.Recording recording;
            CarverLab.Utility.ASX asxfile = new CarverLab.Utility.ASX();
            asxfile.ENTRY = new CarverLab.Utility.ENTRY[lvPlayList.Items.Count];
            int i = 0;

            foreach (ListViewItem lvi in lvPlayList.Items)
            {
                //media = (WMPLib.IWMPMedia3)lvi.Tag;
                if(lvi.Tag != null)
                {
                    recording = (OCL.Recording)lvi.Tag;
                    CarverLab.Utility.ENTRY entry = new CarverLab.Utility.ENTRY();
                    //				asxfile.ENTRY[i] = new CarverLab.Utility.ENTRY;
                    entry.TITLE = lvi.Text;
                    entry.STARTTIME = new CarverLab.Utility.STARTTIME();
                    entry.STARTTIME.VALUE = lvi.SubItems[1].Text;//(object)(lvi.Tag).starttime;
                    TimeSpan st = TimeSpan.Parse(lvi.SubItems[1].Text),
                        et = TimeSpan.Parse(lvi.SubItems[2].Text);
                    TimeSpan dn = et - st;
                    entry.DURATION = new CarverLab.Utility.DURATION();
                    entry.DURATION.VALUE = dn.TotalSeconds.ToString();//(object)(lvi.Tag).duration;
                    entry.REF = new CarverLab.Utility.REF();
                    entry.REF.HREF = RecordingURL(recording);
                    entry.PARAM = new CarverLab.Utility.PARAM[1];
                    entry.PARAM[0] = new CarverLab.Utility.PARAM();
                    entry.PARAM[0].NAME = "RecordingId";
                    entry.PARAM[0].VALUE = recording.ID.ToString();
                    asxfile.ENTRY[i++] = entry;
                }
            }
            string TempFile = System.IO.Path.GetTempFileName();
            asxfile.Write(TempFile);

            System.IO.FileInfo fi = new System.IO.FileInfo(TempFile);
            // create a file that WMP recognizes without errors and warnings
            TempFile += ".wvx";

            System.IO.File.Move(fi.FullName,TempFile);
            m_tempfile = TempFile;

            axWindowsMediaPlayer1.URL = TempFile;
        }
예제 #2
0
파일: frmMain.cs 프로젝트: CarverLab/Oyster
        private void lklSavePlayList_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            if (lvPlayList.Items.Count == 0)
            {
                return;
            }
            frmSavePlayList frm = new frmSavePlayList();
            if (frm.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                OCL.Recording recording;
                CarverLab.Utility.ASX asxfile = new CarverLab.Utility.ASX();
                asxfile.ENTRY = new CarverLab.Utility.ENTRY[lvPlayList.Items.Count];
                int i = 0;

                foreach (ListViewItem lvi in lvPlayList.Items)
                {
                    if(lvi.Tag is OCL.Recording)
                    {
                        recording = (OCL.Recording)lvi.Tag;
                        CarverLab.Utility.ENTRY entry = new CarverLab.Utility.ENTRY();
                        entry.TITLE = lvi.Text;
                        entry.STARTTIME = new CarverLab.Utility.STARTTIME();
                        entry.STARTTIME.VALUE = lvi.SubItems[1].Text;//(object)(lvi.Tag).starttime;
                        TimeSpan st = TimeSpan.Parse(lvi.SubItems[1].Text),
                            et = TimeSpan.Parse(lvi.SubItems[2].Text);
                        TimeSpan dn = et - st;
                        entry.DURATION = new CarverLab.Utility.DURATION();
                        entry.DURATION.VALUE = dn.TotalSeconds.ToString();//(object)(lvi.Tag).duration;
                        entry.REF = new CarverLab.Utility.REF();
                        entry.REF.HREF = RecordingURL(recording);
                        entry.PARAM = new CarverLab.Utility.PARAM[1];
                        entry.PARAM[0] = new CarverLab.Utility.PARAM();
                        entry.PARAM[0].NAME = "RecordingId";
                        entry.PARAM[0].VALUE = recording.ID.ToString();
                        asxfile.ENTRY[i++] = entry;
                    }
                }

                string TempFile = System.IO.Path.GetTempFileName();
                asxfile.Write(TempFile);

                System.IO.TextReader tr = System.IO.File.OpenText(TempFile);
                if (frm.ResavePlayList)
                {
                    PlayList.Update(tr.ReadToEnd());
                }
                else
                {
                    LUser.CreateNewPlayList(frm.PlayListName,tr.ReadToEnd());
                }
                tr.Close();
                System.IO.File.Delete(TempFile);
            }
        }