Example #1
0
 public void Read(string Filename)
 {
     // now load this bugger up and get rid or all the junk that WMP can't parse
     System.Xml.XmlDocument xmld = new System.Xml.XmlDocument();
     xmld.Load(Filename);
     System.Xml.XmlDeclaration xmldecl = xmld.CreateXmlDeclaration("1.0",null,null);
     xmld.InsertBefore(xmldecl,xmld.DocumentElement);
     string TempFile = System.IO.Path.GetTempFileName();
     xmld.Save(TempFile);
     System.IO.TextReader tw = System.IO.File.OpenText(TempFile);
     m_asx = (CarverLab.Utility.ASX)base.Deserialize(tw);
     tw.Close();
     System.IO.File.Delete(TempFile);
 }
Example #2
0
 public ASXSerializer()
     : base(typeof(CarverLab.Utility.ASX))
 {
     m_asx = new CarverLab.Utility.ASX();
 }
Example #3
0
        //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;
        }
Example #4
0
 public ASXSerializer(CarverLab.Utility.ASX asxObject)
     : base(typeof(CarverLab.Utility.ASX))
 {
     m_asx = asxObject;
 }
Example #5
0
        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);
            }
        }