[xiph-commits] r7102 - in trunk/oggdsf/src:

illiminable at dactyl.lonelymoon.com illiminable
Mon Jul 12 11:40:15 PDT 2004


lib/player/libDSPlayDotNET tools/DNPlay
Message-ID: <20040712184015.C38269AAAB at dactyl.lonelymoon.com>

Author: illiminable
Date: Mon Jul 12 11:40:15 2004
New Revision: 7102

Modified:
trunk/oggdsf/src/lib/player/libDSPlayDotNET/DSPlay.cpp
trunk/oggdsf/src/lib/player/libDSPlayDotNET/DSPlay.h
trunk/oggdsf/src/lib/player/libDSPlayDotNET/IDNMediaEvent.h
trunk/oggdsf/src/tools/DNPlay/frmDNPlay.cs
trunk/oggdsf/src/tools/DNPlay/frmDNPlay.resx
Log:
* Tidied up the player and fixed a few bugs, mostly cosmetic.
* Added seeking to the player.
* Getting ready to upgrade all projects to VS2003 project format because of a bug in VS2002 compiler which is preventing on of the interfaces compiling correctly.

Modified: trunk/oggdsf/src/lib/player/libDSPlayDotNET/DSPlay.cpp
===================================================================
--- trunk/oggdsf/src/lib/player/libDSPlayDotNET/DSPlay.cpp	2004-07-12 15:54:14 UTC (rev 7101)
+++ trunk/oggdsf/src/lib/player/libDSPlayDotNET/DSPlay.cpp	2004-07-12 18:40:07 UTC (rev 7102)
@@ -27,7 +27,7 @@
}

bool DSPlay::checkEvents() {
-	const DWORD TIMEOUT_WAIT = 50;  //Wait this many ms for handle
+	const DWORD TIMEOUT_WAIT = 0;  //Wait this many ms for handle
long locEventCode = 0;
long locParam1 = 0;
long locParam2 = 0;
@@ -232,9 +232,24 @@
}

Int64 DSPlay::seek(Int64 inTime) {
-	/*if (mIsLoaded && (mMediaSeeking != NULL) {
-		HRESULT locHR = mMediaSeeking->SetPositions(
-	}*/
+	if (mIsLoaded && (mMediaSeeking != NULL)) {
+		LONGLONG locCurrent = inTime;
+		LONGLONG locStop = 0;
+		HRESULT locHR = mMediaSeeking->SetPositions(&locCurrent, AM_SEEKING_AbsolutePositioning | AM_SEEKING_ReturnTime,
+													&locStop, AM_SEEKING_NoPositioning);
+
+		if (SUCCEEDED(locHR)) {
+			return locCurrent;
+		} else {
+			return -1;
+		}
+	} else {
+		return -1;
+	}
+
+}
+
+Int64 DSPlay::seekStart() {
return 0;
}


Modified: trunk/oggdsf/src/lib/player/libDSPlayDotNET/DSPlay.h
===================================================================
--- trunk/oggdsf/src/lib/player/libDSPlayDotNET/DSPlay.h	2004-07-12 15:54:14 UTC (rev 7101)
+++ trunk/oggdsf/src/lib/player/libDSPlayDotNET/DSPlay.h	2004-07-12 18:40:07 UTC (rev 7102)
@@ -30,6 +30,7 @@
bool pause();
bool stop();
Int64 seek(Int64 inTime);
+		Int64 seekStart();
Int64 queryPosition();

bool isLoaded();

Modified: trunk/oggdsf/src/lib/player/libDSPlayDotNET/IDNMediaEvent.h
===================================================================
--- trunk/oggdsf/src/lib/player/libDSPlayDotNET/IDNMediaEvent.h	2004-07-12 15:54:14 UTC (rev 7101)
+++ trunk/oggdsf/src/lib/player/libDSPlayDotNET/IDNMediaEvent.h	2004-07-12 18:40:07 UTC (rev 7102)
@@ -8,12 +8,11 @@
namespace illiminable {
namespace libDSPlayDotNET {

-public __gc interface IDNMediaEvent {
+public __gc __interface IDNMediaEvent {

public:
virtual bool eventNotification(Int32 inEventCode, Int32 inParam1, Int32 inParam2) = 0;
-
-
+
};

}

Modified: trunk/oggdsf/src/tools/DNPlay/frmDNPlay.cs
===================================================================
--- trunk/oggdsf/src/tools/DNPlay/frmDNPlay.cs	2004-07-12 15:54:14 UTC (rev 7101)
+++ trunk/oggdsf/src/tools/DNPlay/frmDNPlay.cs	2004-07-12 18:40:07 UTC (rev 7102)
@@ -11,7 +11,7 @@
/// <summary>
/// Summary description for Form1.
/// </summary>
-	public class frmDNPlay : System.Windows.Forms.Form
+	public class frmDNPlay : System.Windows.Forms.Form, IDNMediaEvent
{
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
@@ -36,7 +36,13 @@
protected DSPlay mPlayer;
protected Int64 mFileDuration;
protected Int64 mLastSync;
+		private System.Windows.Forms.Timer tmrEventCheck;
protected Int64 mNumTicks;
+
+		enum eEventCodes
+		{
+			EC_COMPLETE = 1
+		};
//

//My member functions
@@ -45,7 +51,8 @@
lblDuration.Text = "";
Int64 locSeconds = inDuration / 10000000;
Int64 locMinutes = locSeconds / 60;
-			Int64 locHours = locSeconds / 3600;
+			Int64 locHours = locMinutes / 60;
+			locMinutes = locMinutes % 60;
locSeconds = locSeconds % 60;
if (locHours != 0)
{
@@ -77,6 +84,15 @@
Int32 locProgWidth = Convert.ToInt32(locProgRatio * lblProgressBkgd.Width);
lblProgressFgnd.Width = locProgWidth;
}
+		public bool eventNotification(Int32 inEventCode, Int32 inParam1, Int32 inParam2)
+		{
+			if (inEventCode == (long)eEventCodes.EC_COMPLETE)
+			{
+				tmrUpdateDuration.Enabled = false;
+				mPlayer.stop();
+			}
+			return true;
+		}
//

public frmDNPlay()
@@ -91,6 +107,9 @@
//
mPlayer = new DSPlay();
lblProgressFgnd.Width = 0;
+			cmdStop.Enabled = false;
+			cmdPlay.Enabled = false;
+			cmdPause.Enabled = false;
}

/// <summary>
@@ -133,6 +152,7 @@
this.tmrUpdateDuration = new System.Windows.Forms.Timer(this.components);
this.lblProgressBkgd = new System.Windows.Forms.Label();
this.lblProgressFgnd = new System.Windows.Forms.Label();
+			this.tmrEventCheck = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
//
// mainMenu1
@@ -241,11 +261,14 @@
//
// lblProgressBkgd
//
+			this.lblProgressBkgd.BackColor = System.Drawing.SystemColors.ControlDark;
this.lblProgressBkgd.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.lblProgressBkgd.Location = new System.Drawing.Point(8, 32);
this.lblProgressBkgd.Name = "lblProgressBkgd";
this.lblProgressBkgd.Size = new System.Drawing.Size(400, 16);
this.lblProgressBkgd.TabIndex = 8;
+			this.lblProgressBkgd.Click += new System.EventHandler(this.lblProgressBkgd_Click);
+			this.lblProgressBkgd.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lblProgressBkgd_MouseDown);
//
// lblProgressFgnd
//
@@ -255,11 +278,17 @@
this.lblProgressFgnd.Name = "lblProgressFgnd";
this.lblProgressFgnd.Size = new System.Drawing.Size(232, 16);
this.lblProgressFgnd.TabIndex = 9;
+			this.lblProgressFgnd.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lblProgressBkgd_MouseDown);
//
+			// tmrEventCheck
+			//
+			this.tmrEventCheck.Interval = 250;
+			this.tmrEventCheck.Tick += new System.EventHandler(this.tmrEventCheck_Tick);
+			//
// frmDNPlay
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
-			this.ClientSize = new System.Drawing.Size(416, 89);
+			this.ClientSize = new System.Drawing.Size(416, 87);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.lblProgressFgnd,
this.lblProgressBkgd,
@@ -268,6 +297,8 @@
this.cmdStop,
this.lblFileLocation,
this.cmdPlay});
+			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
+			this.MaximizeBox = false;
this.Menu = this.mainMenu1;
this.Name = "frmDNPlay";
this.Text = "DNPlay";
@@ -286,11 +317,7 @@
Application.Run(new frmDNPlay());
}

-		private void cmdPlay_Click(object sender, System.EventArgs e)
-		{
-			mPlayer.play();
-			tmrUpdateDuration.Enabled = true;
-		}
+


private void menuItem3_Click(object sender, System.EventArgs e)
@@ -300,6 +327,7 @@
DialogResult locResult = dlgOpenFile.ShowDialog();
if (locResult == DialogResult.OK)
{
+				tmrUpdateDuration.Enabled = false;
lblFileLocation.Text = dlgOpenFile.FileName;
bool locRes = mPlayer.loadFile(dlgOpenFile.FileName);
//Error check
@@ -309,20 +337,48 @@

mNumTicks = 0;
mLastSync = 0;
+				updateProgressBar();
+
+				mPlayer.setMediaEventCallback(this);
+
+				cmdPlay.Enabled = true;
}

}

+		private void cmdPlay_Click(object sender, System.EventArgs e)
+		{
+			mPlayer.play();
+			tmrUpdateDuration.Enabled = true;
+			tmrEventCheck.Enabled = true;
+			cmdPlay.Enabled = false;
+			cmdPause.Enabled = true;
+			cmdStop.Enabled = true;
+		}
+
private void cmdStop_Click(object sender, System.EventArgs e)
{
tmrUpdateDuration.Enabled = false;
+			tmrEventCheck.Enabled = false;
mPlayer.stop();
+			//Need to seek to start here !
+			mPlayer.seek(0);
+			mNumTicks = 0;
+			mLastSync = 0;
+			updateProgressBar();
+			cmdPause.Enabled = true;
+			cmdStop.Enabled = false;
+			cmdPlay.Enabled = true;
}

private void cmdPause_Click(object sender, System.EventArgs e)
{
+			tmrEventCheck.Enabled = false;
tmrUpdateDuration.Enabled = false;
mPlayer.pause();
+			cmdPause.Enabled = false;
+			cmdPlay.Enabled = true;
+			cmdStop.Enabled = true;
}

private void frmDNPlay_Load(object sender, System.EventArgs e)
@@ -340,5 +396,36 @@
{
this.Close();
}
+
+		private void tmrEventCheck_Tick(object sender, System.EventArgs e)
+		{
+			mPlayer.checkEvents();
+		}
+
+		private void lblProgressBkgd_Click(object sender, System.EventArgs e)
+		{
+
+		}
+
+		private void lblProgressBkgd_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
+		{
+			//This is the event for both the foreground and the background label.
+
+
+			if (e.Button == MouseButtons.Left)
+			{
+				double locSeekRatio = ((double)e.X) / (double)lblProgressBkgd.Width;
+				Int64 locSeekPoint = (Int64)(mFileDuration * locSeekRatio);
+				locSeekPoint = mPlayer.seek(locSeekPoint);
+				if (locSeekPoint != -1)
+				{
+					mLastSync = locSeekPoint;
+					mNumTicks = 0;
+					updateProgressBar();
+				}
+
+			}
+		}
+
}
}

Modified: trunk/oggdsf/src/tools/DNPlay/frmDNPlay.resx
===================================================================
--- trunk/oggdsf/src/tools/DNPlay/frmDNPlay.resx	2004-07-12 15:54:14 UTC (rev 7101)
+++ trunk/oggdsf/src/tools/DNPlay/frmDNPlay.resx	2004-07-12 18:40:07 UTC (rev 7102)
@@ -105,6 +105,9 @@
<data name="tmrUpdateDuration.Location" type="System.Drawing.Point, System.Drawing, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>236, 17</value>
</data>
+  <data name="tmrEventCheck.Location" type="System.Drawing.Point, System.Drawing, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>383, 17</value>
+  </data>
<data name="$this.Name">
<value>frmDNPlay</value>
</data>



More information about the commits mailing list