nickston Posted April 17, 2008 Share Posted April 17, 2008 I have some audio player. I suspend thread of this player in my script, but bit of full sound continue playing by loop. How I can flush sound buffer or stop playing sound in that case? Link to comment Share on other sites More sharing options...
Triblade Posted April 17, 2008 Share Posted April 17, 2008 It sounds like it's something only the player can. Could you name the player and post (a bit of) your script? My active project(s): A-maze-ing generator (generates a maze) My archived project(s): Pong3 (Multi-pinger) Link to comment Share on other sites More sharing options...
nickston Posted April 17, 2008 Author Share Posted April 17, 2008 (edited) It sounds like it's something only the player can. Could you name the player and post (a bit of) your script? The name of the player can be anyone, it's does not matter. Func _SuspendExe($PID) Local $THREAD_SUSPEND_RESUME =0x0002 $oWmiService = ObjGet("winmgmts:\\.\root\CIMV2") $ThreadHandle = $oWmiService.Execquery("SELECT Handle FROM Win32_Thread WHERE ProcessHandle='" & $PID & "'") if isobj($threadHandle) then For $TID in $threadHandle ;Getting the handle of thread $hwnd = DllCall($hkernel32Dll,'hwnd',"OpenThread","int",$THREAD_SUSPEND_RESUME,"int",0,'int',$TID.handle) $ret = DllCall($hkernel32Dll,'uint',"SuspendThread",'hwnd',$hwnd[0]) next EndIf EndFunc this is function which suspend thread. It's work good, but sound in buffer... Edited April 17, 2008 by nickston Link to comment Share on other sites More sharing options...
Squirrely1 Posted April 17, 2008 Share Posted April 17, 2008 What happens if you call this function just before you call the one you posted? ; Reduce memory usage ; Author wOuter ( mostly ) ; Usage - ;$pid = WinGetProcess("window title", "") _ReduceMemory($pid) Func _ReduceMemory($i_PID = -1) Local $ai_Handle, $ai_Return, $memory_counter $memory_counter = 1 If $i_PID <> - 1 Then Sleep(150) $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) Sleep(150) $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) Sleep(150) DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) Sleep(150) Else Sleep(150) Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) Sleep(150) EndIf Return $ai_Return[0] EndFunc ;==>_ReduceMemory Das Häschen benutzt Radar Link to comment Share on other sites More sharing options...
nickston Posted April 18, 2008 Author Share Posted April 18, 2008 What happens if you call this function just before you call the one you posted? ; Reduce memory usage ; Author wOuter ( mostly ) ; Usage - ;$pid = WinGetProcess("window title", "") _ReduceMemory($pid) Func _ReduceMemory($i_PID = -1) Local $ai_Handle, $ai_Return, $memory_counter $memory_counter = 1 If $i_PID <> - 1 Then Sleep(150) $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) Sleep(150) $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) Sleep(150) DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) Sleep(150) Else Sleep(150) Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) Sleep(150) EndIf Return $ai_Return[0] EndFunc ;==>_ReduceMemory Nothing. Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 18, 2008 Share Posted April 18, 2008 Flush sound.OK, not very functional, but I couldn't help myself... Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
nickston Posted April 25, 2008 Author Share Posted April 25, 2008 Who can help me? Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted April 25, 2008 Share Posted April 25, 2008 Ever thought about pausing or simply closing the media player?? .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
nickston Posted April 25, 2008 Author Share Posted April 25, 2008 Ever thought about pausing or simply closing the media player??And what about thought pausing?Simply closing is bad idea ie player will continue play after stop Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted April 25, 2008 Share Posted April 25, 2008 And what about thought pausing? Simply closing is bad idea ie player will continue play after stopI am not sure what you mean, if you exit it there shouldn't be any sound?? ProcessClose("wmplayer.exe") .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
nickston Posted April 28, 2008 Author Share Posted April 28, 2008 I am not sure what you mean, if you exit it there shouldn't be any sound?? ProcessClose("wmplayer.exe") I mean what player must be stopped but not closed. Player will continue play sound after some time and start playing at the position in which was stopped. Link to comment Share on other sites More sharing options...
Squirrely1 Posted April 28, 2008 Share Posted April 28, 2008 (edited) I mean what player must be stopped but not closed. Player will continue play sound after some time and start playing at the position in which was stopped.mr. nickston - I do not see how you will get any help on this issue if you cannot provide the name of the media player that is running whilst you are experiencing this phenomenon. As a last resort, open up the Task Manager - by pressing Ctrl-Alt-Del - and look for the name of processes that might be media players.It is simple enough to automate the stopping or pausing of the wmplayer.exe if that is the name of the media player, we could even stop or pause other media players. If there is no real media player running, then other approaches could be reviewed if we had sufficient information on your script. Post some code as a last resort.I have some audio player.I suspend thread of this player in my script, but bit of full sound continue playing by loop.How I can flush sound buffer or stop playing sound in that case?Obvious to many programmers now - judging by your report here - suspending "a" thread of a media player is not a good idea.There are switches for media player instantiation and there are COM object methods, etcetera. Edited April 28, 2008 by Squirrely1 Das Häschen benutzt Radar Link to comment Share on other sites More sharing options...
nickston Posted April 29, 2008 Author Share Posted April 29, 2008 mr. nickston - I do not see how you will get any help on this issue if you cannot provide the name of the media player that is running whilst you are experiencing this phenomenon. As a last resort, open up the Task Manager - by pressing Ctrl-Alt-Del - and look for the name of processes that might be media players.It is simple enough to automate the stopping or pausing of the wmplayer.exe if that is the name of the media player, we could even stop or pause other media players. If there is no real media player running, then other approaches could be reviewed if we had sufficient information on your script. Post some code as a last resort.Obvious to many programmers now - judging by your report here - suspending "a" thread of a media player is not a good idea.There are switches for media player instantiation and there are COM object methods, etcetera.Ok. I attempt to give more info about the situation in which I need stop proccess.1) The "name of media player" (or other programms) obtain from out of my app (for example, from file). According to that names the App must stoping proccesses, ie I don't known that names.2) I test my app on Winamp, and discover problem with sound.3) According to 1) and 2) the name dosn't have matter, proccess must be stoped (don't depend of name), and sound must be stoped. But question is how stop sound. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now