stopping a wave file

  • Thread starter Thread starter Mark Arteaga
  • Start date Start date
M

Mark Arteaga

I am trying to stop a wave file after I start playing it
using the Multimedia API. I succesfully P/Invoke the
following:

waveOutOpen - Open the wave file
waveOutPause - Pause the playing
waveOutRestart - Restart after pausing
waveOutWrite - Start the wave file

For some reason when I P/Invoke waveOutReset nothing
happens.

Here is the P/Invoke:
[DllImport ("coredll.dll", EntryPoint="waveOutReset",
SetLastError=true)]
public static extern int waveOutReset
(IntPtr hWaveOut);

The return value is 0 which means success but the wave
file does not stop playing. I pass the hWaveOut created
using waveOutOpen.

Does anyone have any ideas?
Mark
 
Are you playing Async or Sync? If you're playing Asyncronously (which is
what you're doing, or playing in another thread), you can play a null value
and it will stop playback... just pass in null instead of the filename to
the playsound method...
 
It should work. One thing to check is that you do not call waveOutClose
before you receive final WOM_DONE
 
Not PlaySound - waveOutXXX

Brian said:
Are you playing Async or Sync? If you're playing Asyncronously (which is
what you're doing, or playing in another thread), you can play a null value
and it will stop playback... just pass in null instead of the filename to
the playsound method...


Mark Arteaga said:
I am trying to stop a wave file after I start playing it
using the Multimedia API. I succesfully P/Invoke the
following:

waveOutOpen - Open the wave file
waveOutPause - Pause the playing
waveOutRestart - Restart after pausing
waveOutWrite - Start the wave file

For some reason when I P/Invoke waveOutReset nothing
happens.

Here is the P/Invoke:
[DllImport ("coredll.dll", EntryPoint="waveOutReset",
SetLastError=true)]
public static extern int waveOutReset
(IntPtr hWaveOut);

The return value is 0 which means success but the wave
file does not stop playing. I pass the hWaveOut created
using waveOutOpen.

Does anyone have any ideas?
Mark
 
I'm using the OpenNetCF multimedia code. In
OpenNetCF.Multimedia.Audio.Player i have changed the Stop
() from:

/// <summary>
/// Stop Play
/// </summary>
public void Stop()
{
Core.waveOutReset(IntPtr.Zero);
m_playing = false;
}

to:

/// <summary>
/// Stop Play
/// </summary>
public void Stop()
{
try
{
CheckWaveError
(Core.waveOutReset(m_hWaveOut));
m_playing = false;
}
catch(Exception e)
{
throw e;
}

}

Primarly i just changed the waveOutReset param from
IntPtr.Zero to the waveOut handle created in waveOutOpen.
If I leave it as IntPtr.Zero it throws a "Invalid device
Handle" exception. Any ideas? I can send you a sample
project if you like.

Thx...Mark
-----Original Message-----
It should work. One thing to check is that you do not call waveOutClose
before you receive final WOM_DONE

I am trying to stop a wave file after I start playing it
using the Multimedia API. I succesfully P/Invoke the
following:

waveOutOpen - Open the wave file
waveOutPause - Pause the playing
waveOutRestart - Restart after pausing
waveOutWrite - Start the wave file

For some reason when I P/Invoke waveOutReset nothing
happens.

Here is the P/Invoke:
[DllImport ("coredll.dll", EntryPoint="waveOutReset",
SetLastError=true)]
public static extern int waveOutReset
(IntPtr hWaveOut);

The return value is 0 which means success but the wave
file does not stop playing. I pass the hWaveOut created
using waveOutOpen.

Does anyone have any ideas?
Mark


.
 
Please do.

Mark Arteaga said:
I'm using the OpenNetCF multimedia code. In
OpenNetCF.Multimedia.Audio.Player i have changed the Stop
() from:

/// <summary>
/// Stop Play
/// </summary>
public void Stop()
{
Core.waveOutReset(IntPtr.Zero);
m_playing = false;
}

to:

/// <summary>
/// Stop Play
/// </summary>
public void Stop()
{
try
{
CheckWaveError
(Core.waveOutReset(m_hWaveOut));
m_playing = false;
}
catch(Exception e)
{
throw e;
}

}

Primarly i just changed the waveOutReset param from
IntPtr.Zero to the waveOut handle created in waveOutOpen.
If I leave it as IntPtr.Zero it throws a "Invalid device
Handle" exception. Any ideas? I can send you a sample
project if you like.

Thx...Mark
-----Original Message-----
It should work. One thing to check is that you do not call waveOutClose
before you receive final WOM_DONE

I am trying to stop a wave file after I start playing it
using the Multimedia API. I succesfully P/Invoke the
following:

waveOutOpen - Open the wave file
waveOutPause - Pause the playing
waveOutRestart - Restart after pausing
waveOutWrite - Start the wave file

For some reason when I P/Invoke waveOutReset nothing
happens.

Here is the P/Invoke:
[DllImport ("coredll.dll", EntryPoint="waveOutReset",
SetLastError=true)]
public static extern int waveOutReset
(IntPtr hWaveOut);

The return value is 0 which means success but the wave
file does not stop playing. I pass the hWaveOut created
using waveOutOpen.

Does anyone have any ideas?
Mark


.
 
Hi Mark,

Let me know if this is resolved. I just got through writing some sound code
for a P/Invoke library I am working on and waveOutReset works fine for me so
I may be able to help. The only caveat that I am aware of is that you
cannot simply restart it once you reset it, instead you have to call
waveOutWrite again. Stopping should work though.

--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility

This posting is provided "AS IS" with no warranties, and confers no rights.

Alex Feinman said:
Please do.

Mark Arteaga said:
I'm using the OpenNetCF multimedia code. In
OpenNetCF.Multimedia.Audio.Player i have changed the Stop
() from:

/// <summary>
/// Stop Play
/// </summary>
public void Stop()
{
Core.waveOutReset(IntPtr.Zero);
m_playing = false;
}

to:

/// <summary>
/// Stop Play
/// </summary>
public void Stop()
{
try
{
CheckWaveError
(Core.waveOutReset(m_hWaveOut));
m_playing = false;
}
catch(Exception e)
{
throw e;
}

}

Primarly i just changed the waveOutReset param from
IntPtr.Zero to the waveOut handle created in waveOutOpen.
If I leave it as IntPtr.Zero it throws a "Invalid device
Handle" exception. Any ideas? I can send you a sample
project if you like.

Thx...Mark
-----Original Message-----
It should work. One thing to check is that you do not call waveOutClose
before you receive final WOM_DONE

I am trying to stop a wave file after I start playing it
using the Multimedia API. I succesfully P/Invoke the
following:

waveOutOpen - Open the wave file
waveOutPause - Pause the playing
waveOutRestart - Restart after pausing
waveOutWrite - Start the wave file

For some reason when I P/Invoke waveOutReset nothing
happens.

Here is the P/Invoke:
[DllImport ("coredll.dll", EntryPoint="waveOutReset",
SetLastError=true)]
public static extern int waveOutReset
(IntPtr hWaveOut);

The return value is 0 which means success but the wave
file does not stop playing. I pass the hWaveOut created
using waveOutOpen.

Does anyone have any ideas?
Mark


.
 
Can you send me an email address so I can send you a
sample project?
Thx, Mark
-----Original Message-----
Hi Mark,

Let me know if this is resolved. I just got through writing some sound code
for a P/Invoke library I am working on and waveOutReset works fine for me so
I may be able to help. The only caveat that I am aware of is that you
cannot simply restart it once you reset it, instead you have to call
waveOutWrite again. Stopping should work though.

--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility

This posting is provided "AS IS" with no warranties, and confers no rights.

Please do.

I'm using the OpenNetCF multimedia code. In
OpenNetCF.Multimedia.Audio.Player i have changed the Stop
() from:

/// <summary>
/// Stop Play
/// </summary>
public void Stop()
{
Core.waveOutReset(IntPtr.Zero);
m_playing = false;
}

to:

/// <summary>
/// Stop Play
/// </summary>
public void Stop()
{
try
{
CheckWaveError
(Core.waveOutReset(m_hWaveOut));
m_playing = false;
}
catch(Exception e)
{
throw e;
}

}

Primarly i just changed the waveOutReset param from
IntPtr.Zero to the waveOut handle created in waveOutOpen.
If I leave it as IntPtr.Zero it throws a "Invalid device
Handle" exception. Any ideas? I can send you a sample
project if you like.

Thx...Mark
-----Original Message-----
It should work. One thing to check is that you do not
call waveOutClose
before you receive final WOM_DONE

message
I am trying to stop a wave file after I start playing it
using the Multimedia API. I succesfully P/Invoke the
following:

waveOutOpen - Open the wave file
waveOutPause - Pause the playing
waveOutRestart - Restart after pausing
waveOutWrite - Start the wave file

For some reason when I P/Invoke waveOutReset nothing
happens.

Here is the P/Invoke:
[DllImport ("coredll.dll", EntryPoint="waveOutReset",
SetLastError=true)]
public static extern int waveOutReset
(IntPtr hWaveOut);

The return value is 0 which means success but the wave
file does not stop playing. I pass the hWaveOut created
using waveOutOpen.

Does anyone have any ideas?
Mark


.


.
 
Geoff,
Never mind this. It was my code and my bug and I fixed it.

Geoff Schwab said:
Hi Mark,

Let me know if this is resolved. I just got through writing some sound code
for a P/Invoke library I am working on and waveOutReset works fine for me so
I may be able to help. The only caveat that I am aware of is that you
cannot simply restart it once you reset it, instead you have to call
waveOutWrite again. Stopping should work though.

--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility

This posting is provided "AS IS" with no warranties, and confers no rights.

Alex Feinman said:
Please do.

Mark Arteaga said:
I'm using the OpenNetCF multimedia code. In
OpenNetCF.Multimedia.Audio.Player i have changed the Stop
() from:

/// <summary>
/// Stop Play
/// </summary>
public void Stop()
{
Core.waveOutReset(IntPtr.Zero);
m_playing = false;
}

to:

/// <summary>
/// Stop Play
/// </summary>
public void Stop()
{
try
{
CheckWaveError
(Core.waveOutReset(m_hWaveOut));
m_playing = false;
}
catch(Exception e)
{
throw e;
}

}

Primarly i just changed the waveOutReset param from
IntPtr.Zero to the waveOut handle created in waveOutOpen.
If I leave it as IntPtr.Zero it throws a "Invalid device
Handle" exception. Any ideas? I can send you a sample
project if you like.

Thx...Mark
-----Original Message-----
It should work. One thing to check is that you do not
call waveOutClose
before you receive final WOM_DONE

message
I am trying to stop a wave file after I start playing it
using the Multimedia API. I succesfully P/Invoke the
following:

waveOutOpen - Open the wave file
waveOutPause - Pause the playing
waveOutRestart - Restart after pausing
waveOutWrite - Start the wave file

For some reason when I P/Invoke waveOutReset nothing
happens.

Here is the P/Invoke:
[DllImport ("coredll.dll", EntryPoint="waveOutReset",
SetLastError=true)]
public static extern int waveOutReset
(IntPtr hWaveOut);

The return value is 0 which means success but the wave
file does not stop playing. I pass the hWaveOut created
using waveOutOpen.

Does anyone have any ideas?
Mark


.
 
Back
Top