frmDNPlay.cs

Go to the documentation of this file.
00001 using System;
00002 using System.Drawing;
00003 using System.Collections;
00004 using System.ComponentModel;
00005 using System.Windows.Forms;
00006 using System.Data;
00007 using illiminable.libDSPlayDotNET;
00008 using illiminable.libCMMLTagsDotNET;
00009 
00010 
00011 namespace DNPlay
00012 {
00016         public class frmDNPlay : System.Windows.Forms.Form, IDNMediaEvent, IDNCMMLCallbacks
00017         {
00018                 private System.Windows.Forms.MainMenu mainMenu1;
00019                 private System.Windows.Forms.MenuItem menuItem1;
00020                 private System.Windows.Forms.MenuItem menuItem2;
00021                 private System.Windows.Forms.MenuItem menuItem3;
00022                 private System.Windows.Forms.MenuItem menuItem4;
00023                 private System.Windows.Forms.MenuItem menuItem5;
00024                 private System.Windows.Forms.MenuItem menuItem6;
00025                 private System.Windows.Forms.MenuItem menuItem7;
00026                 private System.Windows.Forms.Button cmdPlay;
00027                 private System.ComponentModel.IContainer components;
00028                 private System.Windows.Forms.Label lblFileLocation;
00029                 private System.Windows.Forms.OpenFileDialog dlgOpenFile;
00030                 private System.Windows.Forms.Button cmdStop;
00031                 private System.Windows.Forms.Button cmdPause;
00032                 private System.Windows.Forms.Label lblDuration;
00033                 private System.Windows.Forms.Timer tmrUpdateDuration;
00034                 private System.Windows.Forms.Label lblProgressBkgd;
00035                 private System.Windows.Forms.Label lblProgressFgnd;
00036 
00037                 //My Variables...
00038                 protected DSPlay mPlayer;
00039                 protected Int64 mFileDuration;
00040                 protected Int64 mLastSync;
00041                 private System.Windows.Forms.Timer tmrEventCheck;
00042                 protected Int64 mNumTicks;
00043                 protected ClipTag mCurrentClip;
00044                 private System.Windows.Forms.Label lblClipDesc;
00045                 private System.Windows.Forms.Button cmdFollowLink;
00046                 private System.Windows.Forms.Label lblAnchorLink;
00047                 private System.Windows.Forms.Label lblTitle;
00048                 protected HeadTag mHeadTag;
00049                 //private Int64 evCount;
00050                 private Uri mBaseURI; 
00051                 private String mFileName;
00052 
00053                 enum eEventCodes 
00054                 {
00055                         EC_COMPLETE = 1
00056                 };
00057                 //
00058 
00059                 //My member functions
00060                 protected void setDurationText(Int64 inDuration) 
00061                 {
00062                         lblDuration.Text = "";
00063                         Int64 locSeconds = inDuration / 10000000;
00064                         Int64 locMinutes = locSeconds / 60;
00065                         Int64 locHours = locMinutes / 60;
00066                         locMinutes = locMinutes % 60;
00067                         locSeconds = locSeconds % 60;
00068                         if (locHours != 0) 
00069                         {
00070                                 lblDuration.Text = locHours.ToString() + ":";
00071                                 if (locMinutes < 10) 
00072                                 {
00073                                         lblDuration.Text += "0";
00074                                 }
00075                         } 
00076                         
00077                         lblDuration.Text += locMinutes.ToString() + ":";
00078                         
00079                         if (locSeconds < 10) 
00080                         {
00081                                 lblDuration.Text += "0";
00082                         }
00083                         lblDuration.Text += locSeconds.ToString();
00084                 }
00085 
00086                 protected void updateProgressBar() 
00087                 {
00088                         double locProgRatio = 0;
00089                         Int32 locProgWidth = 0;
00090                         if (mFileDuration > 0) 
00091                         {
00092                                 try 
00093                                 {
00094                                         locProgRatio =  Convert.ToDouble(mLastSync + (mNumTicks * 10000000)) / mFileDuration;
00095                                         locProgWidth = Convert.ToInt32(locProgRatio * lblProgressBkgd.Width);
00096                                 } 
00097                                 catch (System.OverflowException)
00098                                 {
00099                                         //MessageBox.Show(mFileDuration.ToString());
00100                                         
00101                                     locProgWidth = 0;
00102                                 }
00103                         }
00104                         
00105                         lblProgressFgnd.Width = locProgWidth;
00106                 }
00107                 public bool eventNotification(Int32 inEventCode, Int32 inParam1, Int32 inParam2) 
00108                 {
00109                         //evCount++;
00110                         //label1.Text = evCount.ToString();
00111                         if (inEventCode == (long)eEventCodes.EC_COMPLETE) 
00112                         {
00113                                 tmrUpdateDuration.Enabled = false;
00114                                 mPlayer.stop();
00115                         }
00116                         return true;
00117                 }
00118 
00119                 //Implementing IDNCMMLCallbacks
00120                 public bool clipCallback(ClipTag inClipTag) 
00121                 {
00122                         //MessageBox.Show("Clip Callback");
00123                         cmdFollowLink.Enabled = true;
00124                         mCurrentClip = inClipTag;
00125                         lblClipDesc.Text = inClipTag.desc().text();
00126                         lblAnchorLink.Text = inClipTag.anchor().href();
00127                         return true;
00128                 }
00129                 public bool headCallback(HeadTag inHeadTag) 
00130                 {
00131                         MessageBox.Show("Head callback");
00132                         mHeadTag = inHeadTag;
00133                         if (mHeadTag != null) 
00134                         {
00135                                 //MessageBox.Show("Head tag not null");
00136                         }
00137                         else 
00138                         {
00139                                 //MessageBox.Show("Head tag is null");
00140                         }
00141                         lblTitle.Text = mHeadTag.title().text();
00142                         //MessageBox.Show(mHeadTag.title().text());
00143                         Uri locBaseURI = null;
00144                         try 
00145                         {
00146                                 if (mHeadTag.@base() != null) 
00147                                 {
00148                                         //MessageBox.Show("Href = "+mHeadTag.@base().href());
00149                                         locBaseURI = new Uri(mHeadTag.@base().href());
00150                                 }
00151                         } 
00152                         catch(System.UriFormatException) 
00153                         {
00154                                 locBaseURI = null;      
00155                                         
00156                         }
00157 
00158                         if (locBaseURI != null) 
00159                         {
00160                                 mBaseURI = locBaseURI;
00161                         }
00162                 
00163                         //MessageBox.Show("Bug not here !!");
00164                         return true;
00165                 }
00166                 //
00167 
00168                 public frmDNPlay()
00169                 {
00170                         //
00171                         // Required for Windows Form Designer support
00172                         //
00173                         InitializeComponent();
00174 
00175                         //
00176                         // TODO: Add any constructor code after InitializeComponent call
00177                         //
00178                         mPlayer = new DSPlay();
00179                         lblProgressFgnd.Width = 0;
00180                         cmdStop.Enabled = false;
00181                         cmdPlay.Enabled = false;
00182                         cmdPause.Enabled = false;
00183 
00184                         //evCount = 0;
00185                 }
00186 
00190                 protected override void Dispose( bool disposing )
00191                 {
00192                         if( disposing )
00193                         {
00194                                 if (components != null) 
00195                                 {
00196                                         components.Dispose();
00197                                 }
00198                         }
00199                         base.Dispose( disposing );
00200                 }
00201 
00202                 #region Windows Form Designer generated code
00207                 private void InitializeComponent()
00208                 {
00209                         this.components = new System.ComponentModel.Container();
00210                         this.mainMenu1 = new System.Windows.Forms.MainMenu();
00211                         this.menuItem1 = new System.Windows.Forms.MenuItem();
00212                         this.menuItem3 = new System.Windows.Forms.MenuItem();
00213                         this.menuItem4 = new System.Windows.Forms.MenuItem();
00214                         this.menuItem5 = new System.Windows.Forms.MenuItem();
00215                         this.menuItem6 = new System.Windows.Forms.MenuItem();
00216                         this.menuItem2 = new System.Windows.Forms.MenuItem();
00217                         this.menuItem7 = new System.Windows.Forms.MenuItem();
00218                         this.cmdPlay = new System.Windows.Forms.Button();
00219                         this.lblFileLocation = new System.Windows.Forms.Label();
00220                         this.dlgOpenFile = new System.Windows.Forms.OpenFileDialog();
00221                         this.cmdStop = new System.Windows.Forms.Button();
00222                         this.cmdPause = new System.Windows.Forms.Button();
00223                         this.lblDuration = new System.Windows.Forms.Label();
00224                         this.tmrUpdateDuration = new System.Windows.Forms.Timer(this.components);
00225                         this.lblProgressBkgd = new System.Windows.Forms.Label();
00226                         this.lblProgressFgnd = new System.Windows.Forms.Label();
00227                         this.tmrEventCheck = new System.Windows.Forms.Timer(this.components);
00228                         this.lblClipDesc = new System.Windows.Forms.Label();
00229                         this.cmdFollowLink = new System.Windows.Forms.Button();
00230                         this.lblAnchorLink = new System.Windows.Forms.Label();
00231                         this.lblTitle = new System.Windows.Forms.Label();
00232                         this.SuspendLayout();
00233                         // 
00234                         // mainMenu1
00235                         // 
00236                         this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00237                                                                                                                                                                           this.menuItem1,
00238                                                                                                                                                                           this.menuItem2});
00239                         // 
00240                         // menuItem1
00241                         // 
00242                         this.menuItem1.Index = 0;
00243                         this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00244                                                                                                                                                                           this.menuItem3,
00245                                                                                                                                                                           this.menuItem4,
00246                                                                                                                                                                           this.menuItem5,
00247                                                                                                                                                                           this.menuItem6});
00248                         this.menuItem1.Text = "&File";
00249                         // 
00250                         // menuItem3
00251                         // 
00252                         this.menuItem3.Index = 0;
00253                         this.menuItem3.Text = "&Open...";
00254                         this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
00255                         // 
00256                         // menuItem4
00257                         // 
00258                         this.menuItem4.Index = 1;
00259                         this.menuItem4.Text = "Open &URL...";
00260                         this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
00261                         // 
00262                         // menuItem5
00263                         // 
00264                         this.menuItem5.Index = 2;
00265                         this.menuItem5.Text = "-";
00266                         // 
00267                         // menuItem6
00268                         // 
00269                         this.menuItem6.Index = 3;
00270                         this.menuItem6.Text = "E&xit";
00271                         this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
00272                         // 
00273                         // menuItem2
00274                         // 
00275                         this.menuItem2.Index = 1;
00276                         this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00277                                                                                                                                                                           this.menuItem7});
00278                         this.menuItem2.Text = "Help";
00279                         // 
00280                         // menuItem7
00281                         // 
00282                         this.menuItem7.Index = 0;
00283                         this.menuItem7.Text = "&About";
00284                         // 
00285                         // cmdPlay
00286                         // 
00287                         this.cmdPlay.Location = new System.Drawing.Point(8, 80);
00288                         this.cmdPlay.Name = "cmdPlay";
00289                         this.cmdPlay.Size = new System.Drawing.Size(56, 24);
00290                         this.cmdPlay.TabIndex = 0;
00291                         this.cmdPlay.Text = "&Play";
00292                         this.cmdPlay.Click += new System.EventHandler(this.cmdPlay_Click);
00293                         // 
00294                         // lblFileLocation
00295                         // 
00296                         this.lblFileLocation.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
00297                         this.lblFileLocation.Location = new System.Drawing.Point(8, 8);
00298                         this.lblFileLocation.Name = "lblFileLocation";
00299                         this.lblFileLocation.Size = new System.Drawing.Size(400, 16);
00300                         this.lblFileLocation.TabIndex = 3;
00301                         // 
00302                         // dlgOpenFile
00303                         // 
00304                         this.dlgOpenFile.Title = "Select a file to play...";
00305                         // 
00306                         // cmdStop
00307                         // 
00308                         this.cmdStop.Location = new System.Drawing.Point(72, 80);
00309                         this.cmdStop.Name = "cmdStop";
00310                         this.cmdStop.Size = new System.Drawing.Size(56, 24);
00311                         this.cmdStop.TabIndex = 5;
00312                         this.cmdStop.Text = "&Stop";
00313                         this.cmdStop.Click += new System.EventHandler(this.cmdStop_Click);
00314                         // 
00315                         // cmdPause
00316                         // 
00317                         this.cmdPause.Location = new System.Drawing.Point(136, 80);
00318                         this.cmdPause.Name = "cmdPause";
00319                         this.cmdPause.Size = new System.Drawing.Size(56, 24);
00320                         this.cmdPause.TabIndex = 6;
00321                         this.cmdPause.Text = "Pa&use";
00322                         this.cmdPause.Click += new System.EventHandler(this.cmdPause_Click);
00323                         // 
00324                         // lblDuration
00325                         // 
00326                         this.lblDuration.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
00327                         this.lblDuration.Font = new System.Drawing.Font("Comic Sans MS", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
00328                         this.lblDuration.Location = new System.Drawing.Point(240, 80);
00329                         this.lblDuration.Name = "lblDuration";
00330                         this.lblDuration.Size = new System.Drawing.Size(168, 24);
00331                         this.lblDuration.TabIndex = 7;
00332                         this.lblDuration.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
00333                         // 
00334                         // tmrUpdateDuration
00335                         // 
00336                         this.tmrUpdateDuration.Interval = 1000;
00337                         this.tmrUpdateDuration.Tick += new System.EventHandler(this.tmrUpdateDuration_Tick);
00338                         // 
00339                         // lblProgressBkgd
00340                         // 
00341                         this.lblProgressBkgd.BackColor = System.Drawing.SystemColors.ControlDark;
00342                         this.lblProgressBkgd.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
00343                         this.lblProgressBkgd.Location = new System.Drawing.Point(8, 56);
00344                         this.lblProgressBkgd.Name = "lblProgressBkgd";
00345                         this.lblProgressBkgd.Size = new System.Drawing.Size(400, 16);
00346                         this.lblProgressBkgd.TabIndex = 8;
00347                         this.lblProgressBkgd.Click += new System.EventHandler(this.lblProgressBkgd_Click);
00348                         this.lblProgressBkgd.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lblProgressBkgd_MouseDown);
00349                         // 
00350                         // lblProgressFgnd
00351                         // 
00352                         this.lblProgressFgnd.BackColor = System.Drawing.Color.SeaGreen;
00353                         this.lblProgressFgnd.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
00354                         this.lblProgressFgnd.Location = new System.Drawing.Point(8, 56);
00355                         this.lblProgressFgnd.Name = "lblProgressFgnd";
00356                         this.lblProgressFgnd.Size = new System.Drawing.Size(232, 16);
00357                         this.lblProgressFgnd.TabIndex = 9;
00358                         this.lblProgressFgnd.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lblProgressBkgd_MouseDown);
00359                         // 
00360                         // tmrEventCheck
00361                         // 
00362                         this.tmrEventCheck.Interval = 250;
00363                         this.tmrEventCheck.Tick += new System.EventHandler(this.tmrEventCheck_Tick);
00364                         // 
00365                         // lblClipDesc
00366                         // 
00367                         this.lblClipDesc.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
00368                         this.lblClipDesc.Location = new System.Drawing.Point(8, 120);
00369                         this.lblClipDesc.Name = "lblClipDesc";
00370                         this.lblClipDesc.Size = new System.Drawing.Size(400, 104);
00371                         this.lblClipDesc.TabIndex = 10;
00372                         // 
00373                         // cmdFollowLink
00374                         // 
00375                         this.cmdFollowLink.Enabled = false;
00376                         this.cmdFollowLink.Location = new System.Drawing.Point(312, 232);
00377                         this.cmdFollowLink.Name = "cmdFollowLink";
00378                         this.cmdFollowLink.Size = new System.Drawing.Size(96, 24);
00379                         this.cmdFollowLink.TabIndex = 11;
00380                         this.cmdFollowLink.Text = "Follow Link";
00381                         this.cmdFollowLink.Click += new System.EventHandler(this.cmdFollowLink_Click);
00382                         // 
00383                         // lblAnchorLink
00384                         // 
00385                         this.lblAnchorLink.Location = new System.Drawing.Point(16, 232);
00386                         this.lblAnchorLink.Name = "lblAnchorLink";
00387                         this.lblAnchorLink.Size = new System.Drawing.Size(288, 24);
00388                         this.lblAnchorLink.TabIndex = 12;
00389                         this.lblAnchorLink.Click += new System.EventHandler(this.lblAnchorLink_Click);
00390                         // 
00391                         // lblTitle
00392                         // 
00393                         this.lblTitle.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
00394                         this.lblTitle.Location = new System.Drawing.Point(8, 32);
00395                         this.lblTitle.Name = "lblTitle";
00396                         this.lblTitle.Size = new System.Drawing.Size(400, 16);
00397                         this.lblTitle.TabIndex = 13;
00398                         // 
00399                         // frmDNPlay
00400                         // 
00401                         this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
00402                         this.ClientSize = new System.Drawing.Size(416, 271);
00403                         this.Controls.Add(this.lblTitle);
00404                         this.Controls.Add(this.lblAnchorLink);
00405                         this.Controls.Add(this.cmdFollowLink);
00406                         this.Controls.Add(this.lblClipDesc);
00407                         this.Controls.Add(this.lblProgressFgnd);
00408                         this.Controls.Add(this.lblProgressBkgd);
00409                         this.Controls.Add(this.lblDuration);
00410                         this.Controls.Add(this.cmdPause);
00411                         this.Controls.Add(this.cmdStop);
00412                         this.Controls.Add(this.lblFileLocation);
00413                         this.Controls.Add(this.cmdPlay);
00414                         this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
00415                         this.MaximizeBox = false;
00416                         this.Menu = this.mainMenu1;
00417                         this.Name = "frmDNPlay";
00418                         this.Text = "DNPlay";
00419                         this.Load += new System.EventHandler(this.frmDNPlay_Load);
00420                         this.ResumeLayout(false);
00421 
00422                 }
00423                 #endregion
00424 
00428                 [STAThread]
00429                 static void Main() 
00430                 {
00431                         Application.Run(new frmDNPlay());
00432                 }
00433 
00434                 
00435                 private void OpenFile() 
00436                 {
00437                         //File->Open
00438                         dlgOpenFile.CheckFileExists = true;
00439                         DialogResult locResult = dlgOpenFile.ShowDialog();
00440                         if (locResult == DialogResult.OK) 
00441                         {
00442                                 LoadFile(dlgOpenFile.FileName);
00443 //                              tmrUpdateDuration.Enabled = false;
00444 //                              lblFileLocation.Text = dlgOpenFile.FileName;
00445 //                              bool locRes = mPlayer.loadFile(dlgOpenFile.FileName);
00446 //                              //Error check
00447 //                              mFileDuration = mPlayer.fileDuration();
00448 //                              setDurationText(mFileDuration);
00449 //                              //lblDuration.Text = mFileDuration.ToString();
00450 //
00451 //                              mNumTicks = 0;
00452 //                              mLastSync = 0;
00453 //                              updateProgressBar();
00454 //
00455 //                              mPlayer.setMediaEventCallback(this);
00456 //                              mPlayer.setCMMLCallbacks(this);
00457 //                              cmdPlay.Enabled = true;
00458                         }
00459 
00460                 }
00461 
00462                 private void LoadFile(String inFileName) 
00463                 {
00464                         tmrUpdateDuration.Enabled = false;
00465 
00466                         bool locRes = mPlayer.loadFile(inFileName);
00467 
00468                         if (locRes) 
00469                         {
00470                                 mFileName = inFileName;
00471                                 lblFileLocation.Text = inFileName;
00472                                 lblAnchorLink.Text = "";
00473                                 lblClipDesc.Text = "";
00474                                 lblTitle.Text = "";
00475                                 cmdFollowLink.Enabled = false;
00476 
00477 
00478                                 
00479                                 //Set the base URI from the current file.
00480                                 setBaseURIFromFullPath(inFileName);
00481                                         
00482                                 
00483                                 //Error check
00484                                 mFileDuration = mPlayer.fileDuration();
00485                                 setDurationText(mFileDuration);
00486                                 //lblDuration.Text = mFileDuration.ToString();
00487 
00488                                 mNumTicks = 0;
00489                                 mLastSync = 0;
00490                                 updateProgressBar();
00491 
00492                                 mPlayer.setMediaEventCallback(this);
00493                                 mPlayer.setCMMLCallbacks(this);
00494                                 cmdPlay.Enabled = true;
00495                         } 
00496                         else 
00497                         {
00498                                 //MessageBox.Show("File type is unrecognised, or media file does not exist", "Media Open Failed.", MessageBoxButtons.OK, MessageBoxIcon.Stop);
00499                         
00500                         }
00501                 }
00502                 
00503                 private void menuItem3_Click(object sender, System.EventArgs e)
00504                 {
00505                         OpenFile();
00506                         
00507                 }
00508 
00509                 private void StartPlayback() 
00510                 {
00511                         mPlayer.play();
00512                         tmrUpdateDuration.Enabled = true;
00513                         tmrEventCheck.Enabled = true;
00514                         cmdPlay.Enabled = false;
00515                         cmdPause.Enabled = true;
00516                         cmdStop.Enabled = true;
00517                 }
00518                 private void cmdPlay_Click(object sender, System.EventArgs e)
00519                 {
00520                         StartPlayback();
00521                 }
00522 
00523                 private void StopPlayback() 
00524                 {
00525                         tmrUpdateDuration.Enabled = false;
00526                         tmrEventCheck.Enabled = false;
00527                         mPlayer.stop();
00528                         //Need to seek to start here !
00529                         mPlayer.seek(0);
00530                         mNumTicks = 0;
00531                         mLastSync = 0;
00532                         updateProgressBar();
00533                         cmdPause.Enabled = true;
00534                         cmdStop.Enabled = false;
00535                         cmdPlay.Enabled = true;
00536                 }
00537                 private void cmdStop_Click(object sender, System.EventArgs e)
00538                 {
00539                         StopPlayback();
00540                 }
00541 
00542                 private void PausePlayback() 
00543                 {
00544                         tmrEventCheck.Enabled = false;
00545                         tmrUpdateDuration.Enabled = false;
00546                         mPlayer.pause();
00547                         cmdPause.Enabled = false;
00548                         cmdPlay.Enabled = true;
00549                         cmdStop.Enabled = true;
00550                 }
00551                 private void cmdPause_Click(object sender, System.EventArgs e)
00552                 {
00553                         PausePlayback();
00554                 }
00555 
00556                 private void frmDNPlay_Load(object sender, System.EventArgs e)
00557                 {
00558                 
00559                 }
00560 
00561                 private void tmrUpdateDuration_Tick(object sender, System.EventArgs e)
00562                 {
00563                         mNumTicks++;
00564                         updateProgressBar();
00565                 }
00566 
00567                 private void menuItem6_Click(object sender, System.EventArgs e)
00568                 {
00569                         this.Close();
00570                 }
00571 
00572                 private void tmrEventCheck_Tick(object sender, System.EventArgs e)
00573                 {
00574                         mPlayer.checkEvents();
00575                 }
00576 
00577                 private void lblProgressBkgd_Click(object sender, System.EventArgs e)
00578                 {
00579                 
00580                 }
00581 
00582                 private void lblProgressBkgd_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) 
00583                 {
00584                         //This is the event for both the foreground and the background label.
00585                         
00586 
00587                         if (e.Button == MouseButtons.Left)
00588                         {
00589                                 double locSeekRatio = ((double)e.X) / (double)lblProgressBkgd.Width;
00590                                 Int64 locSeekPoint = (Int64)(mFileDuration * locSeekRatio);
00591                                 locSeekPoint = mPlayer.seek(locSeekPoint);
00592                                 if (locSeekPoint != -1) 
00593                                 {
00594                                         mLastSync = locSeekPoint;
00595                                         mNumTicks = 0;
00596                                         updateProgressBar();
00597                                 }
00598                                 
00599                         }
00600                 }
00601 
00602                 private bool setBaseURIFromFullPath(String inFullPath) 
00603                 {
00604                         MessageBox.Show(inFullPath);
00605 //                      Uri locURI = null;
00606 //                      Uri locBaseURI = null;
00607 //                      try 
00608 //                      {
00609 //                              //Turn the full path into a URI
00610 //                              locURI = new Uri(inFullPath);
00611 //                      }
00612 //                      catch (System.UriFormatException) 
00613 //                      {
00614 //                              //This is not a URI !
00615 //                              locURI = null;
00616 //                      }
00617 //
00618 //                      if (locURI != null) 
00619 //                      {
00620 //                              MessageBox.Show(locURI.ToString());
00621 //                              MessageBox.Show(locURI.GetLeftPart(UriPartial.Authority));
00622 //                              String locPartial = locURI.GetLeftPart(UriPartial.Authority);
00623 //
00624 //                              if (locPartial.Equals("")) 
00625 //                              {
00626 //
00627 //                                      //Must be a file with a : 'd path in it
00628 //                                      locPartial = locURI.GetLeftPart(UriPartial.Path);
00629 //
00630 //                                      //Find out where the lat slash is
00631 //                                      int locDelimPos = locPartial.LastIndexOf("/");
00632 //                                      if (locDelimPos != -1) 
00633 //                                      {
00634 //                                              //Strip off the filename part at the end
00635 //                                              locPartial = locPartial.Substring(0, locDelimPos + 1);
00636 //                                              MessageBox.Show("Parital : " + locPartial);
00637 //                                      } 
00638 //                                      else 
00639 //                                      {
00640 //                                              locPartial = "";
00641 //                                      }
00642 //                              }
00643 //                              //Get the URI base which excludes the filename part.
00644 //                              
00645 //                              if (!locPartial.Equals("")) 
00646 //                              {
00647 //                                      locBaseURI = new Uri(locPartial);
00648 //                                      MessageBox.Show(locBaseURI.ToString());
00649 //                              }
00650 //                              
00651 //                      } 
00652 
00653                         Uri locBaseURI = null;
00654                         try 
00655                         {
00656                                 locBaseURI = new Uri(inFullPath);
00657                         }
00658                         catch (System.UriFormatException) 
00659                         {
00660                                 //Do nothing...
00661                         }
00662 
00663                         
00664                         mBaseURI = locBaseURI;
00665 
00666                         return (locBaseURI != null);
00667 
00668 
00669                 }
00670                 private void cmdFollowLink_Click(object sender, System.EventArgs e)
00671                 {
00672                         
00673                         if (mBaseURI != null) 
00674                         {
00675                                 //Try to do relative to the base URI
00676                                 Uri locURI = null;
00677                                 try 
00678                                 {
00679                                         MessageBox.Show("Base is "+mBaseURI.ToString());
00680                                         //try and make a URI using the base and the href from the clip (relative)
00681                                         locURI = new Uri(mBaseURI, mCurrentClip.anchor().href());       
00682                                         MessageBox.Show("New URI is "+locURI.ToString());
00683                                 } 
00684                                 catch(System.UriFormatException) 
00685                                 {
00686                                         try 
00687                                         {
00688                                                 //If that failed, try to make one with just the clip tag (absolute)
00689                                                 locURI = new Uri(mCurrentClip.anchor().href());
00690                                         }
00691                                         catch (System.UriFormatException) 
00692                                         {
00693                                                 locURI = null;
00694                                                 
00695 
00696                                         }
00697                                 }
00698 
00699                                 if (locURI == null) 
00700                                 {
00701                                         MessageBox.Show("The link is an invalid URI", "Invalid URI", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
00702                                 } 
00703                                 else
00704                                 {
00705                                         //MessageBox.Show("Opening "+locURI.ToString());
00706                                         if (locURI.IsFile) 
00707                                         {
00708                                                 //If it's a file change it to a local path.
00709                                                 LoadFile(locURI.LocalPath);
00710                                                 StartPlayback();
00711 
00712                                         } 
00713                                         else 
00714                                         {
00715                                                 //Otherwise just load the URI
00716                                                 LoadFile(locURI.ToString());
00717                                                 StartPlayback();
00718                                         }
00719                                 }
00720                         } 
00721                         
00722                         
00723 //                      tmrUpdateDuration.Enabled = false;
00724 //                      lblFileLocation.Text = locFilename;
00725 //                      bool locRes = mPlayer.loadFile("G:\\downloads\\firefox\\manufacturing_surveys.anx");
00726 //                      //Error check
00727 //                      mFileDuration = mPlayer.fileDuration();
00728 //                      setDurationText(mFileDuration);
00729 //                      //lblDuration.Text = mFileDuration.ToString();
00730 //
00731 //                      mNumTicks = 0;
00732 //                      mLastSync = 0;
00733 //                      updateProgressBar();
00734 //
00735 //                      mPlayer.setMediaEventCallback(this);
00736 //                      mPlayer.setCMMLCallbacks(this);
00737 //                      cmdPlay.Enabled = true;
00738 //                      StartPlayback();
00739                 }
00740 
00741                 private void menuItem4_Click(object sender, System.EventArgs e)
00742                 {
00743                         frmOpenURL locOpenDialog = new frmOpenURL();
00744                         locOpenDialog.ShowDialog(this);
00745                         if (locOpenDialog.wasOK) 
00746                         {
00747                                 MessageBox.Show(locOpenDialog.URLToOpen);
00748                                 LoadFile(locOpenDialog.URLToOpen);
00749                                 
00750                                 
00751                                 
00752                         }
00753                 }
00754 
00755                 private void lblAnchorLink_Click(object sender, System.EventArgs e)
00756                 {
00757                 
00758                 }
00759 
00760         }
00761 }

Generated on Tue Feb 15 14:54:23 2005 for oggdsf by  doxygen 1.3.9