473,799 Members | 3,310 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to suspend and resume in playing a WAV file

I am using winmm.dll and I found that I can't just suspend it and
resume it?

What should I do? Any better idea?

Should I use thread? and thread.suspend will work?

Thanks

Mar 11 '07 #1
4 4613
VJ
If you are on 2.0 Framework try the soundplayer class. I have not used it,
but I assume you might need to use thread to paly/suspend/resume, or maybe
not. Check it out.

VJ

"fAnSKyer/C# newbie" <fa******@gmail .comwrote in message
news:11******** **************@ 8g2000cwh.googl egroups.com...
>I am using winmm.dll and I found that I can't just suspend it and
resume it?

What should I do? Any better idea?

Should I use thread? and thread.suspend will work?

Thanks

Mar 11 '07 #2
On Sun, 11 Mar 2007 10:45:19 +0800, fAnSKyer/C# newbie
<fa******@gmail .comwrote:
I am using winmm.dll and I found that I can't just suspend it and
resume it?

What should I do? Any better idea?

Should I use thread? and thread.suspend will work?
It's unlikely that you can simply suspend a thread playing a sound.
First, the thread that calls the API to play the sound is unlikely to have
anything to do with the thread actually playing the sound. Second, the
thread actually playing the sound is likely to be feeding audio samples to
the audio hardware; suspending that thread will just result in the
hardware repeating the same sample over and over.

Fortunately, there is an easier way. :) Look at the AudioVideoPlayb ack
DirectX component. I am pretty sure that it includes pause/resume
functionality, unlike the basic .NET media SoundPlayer class.

Of course, that said...if you are using winmm.dll (via p/invoke
presumably), the wav/mci API has pause/resume as well, if I recall
correctly. IMHO using the AVP component is easier, since it doesn't
require p/invoke in your application, but you ought to be able to pause
and resume audio playback using the same playback mechanism you're using
now.

Pete
Mar 11 '07 #3
VJ
Ahh the part of hardware, thanks for the update. Yes DirectX is a better
choice.

VJ

"fAnSKyer/C# newbie" <fa******@gmail .comwrote in message
news:11******** **************@ 8g2000cwh.googl egroups.com...
>I am using winmm.dll and I found that I can't just suspend it and
resume it?

What should I do? Any better idea?

Should I use thread? and thread.suspend will work?

Thanks

Mar 11 '07 #4
MBR
It's been a while, but if you're using the MCI interface win WINMM (either
the mciSendString version or the command version) you should be able to
pause without a problem.

For example, using mciSendString, if you send:
"play c:\foo.wav alias a"
then you can follow up with:
"pause a"
and
"resume a"

Of course you can also do:
"set a timeformat milliseconds"
"play a from 0 to 23323"
etc...

Hope that helps -
thanks,
m

"fAnSKyer/C# newbie" <fa******@gmail .comwrote in message
news:11******** **************@ 8g2000cwh.googl egroups.com...
>I am using winmm.dll and I found that I can't just suspend it and
resume it?

What should I do? Any better idea?

Should I use thread? and thread.suspend will work?

Thanks


--
Posted via a free Usenet account from http://www.teranews.com

Mar 11 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
2778
by: Keith Langer | last post by:
I have an application which consists of a main work thread and multiple threads which each maintain a TCP socket. When a configuration change occurs, all activity on the socket threads must be halted. If a socket is no longer in the configuration, that thread must be aborted and the socket must be closed. After the configuration is complete, the remaining threads must be resumed. I currently have the following architecture:
14
2326
by: Jiri Kripac | last post by:
Languages such as Simula 67 contain a general concept of coroutines that allow the execution of a method to be suspended without rolling back the stack and then later resumed at the same place as it has been suspended. The C# iterators seem to be a special case of this general suspend/resume concept. The "yield" statement suspends the execution of the current method and calling MoveNext() resumes it. I think it would be cleaner to...
2
4479
by: Dave | last post by:
Hi, I am writing a c# application that using a directshow to play file and display it on my C# gui, its work just fine but when i try to open another thread in my c# application the file stop playing and i get black image!!! Why? What i should considre when i open a new thread in c# application?? Thanks
2
4316
by: juky | last post by:
Hi all, I have a loop in the thread checking for a particular service status, whenever the status changes to "stopped" a RaiseEvent is generated by thread and another function runs. At the same time the thread is suspended. When I try to resume it from the another function I have some problems. Thank you. Juky
4
3202
by: wanwan | last post by:
I'm using Microsoft Visual Studio 2005 in multithreading, I want to be able to pause and resume a thread. I see that suspend and resume are deprecated. So what can I use instead.
3
6061
by: =?Utf-8?B?TWFyayBDaGFubmluZw==?= | last post by:
I have a code which registers all threads with a thread dump class. At intervals this thread dump class will dump the stack trace of all threads. As calling StackTrace(threadtoDump) from a different thread other than the treadToDump the threadToDump must be suspended otherwise a ThreadStateException gets thrown. However under .NET 2.0 System.Threading.Thread.Suspend/Resume have been marked as obsolete with reference to better methods of...
1
4096
by: scsoce | last post by:
A child thread has a long-time executions, how to suspend it and resume back the orignial place ? I know it' nature to use singal, but child thread cannot get signal as Python Manual say. And i dnt like to check status variable as the long-time executions can not or be dirty to stop to do check.
0
1327
by: M.-A. Lemburg | last post by:
On 2008-11-13 02:57, scsoce wrote: I'm not sure I understand... the OS will take care of all this for you. If you want to suspend the execution of a thread you have to explicitly code for this in the code running in that thread and use e.g. a semaphore or thread lock. --
0
1002
by: NitinSawant | last post by:
How to add resume supported file downloads feature to asp.net web application? e.g. I have a large file on web server, While downloading I pause it But when I click on resume then the file download starts from beginning.
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10485
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10231
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9073
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4141
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.