Didonet Posted November 4, 2007 Share Posted November 4, 2007 (edited) Hello again. I have problem with the while 1 that is for the main functions and actions. How can I create a loop in that loop, but when I start the loop I don't want the program to "freeze" and action only the thing in this loop. I want to work everything else when the loop is started. Is it possible? In other words: I'm creating a mp3 player. When I start the song I use that to show me the time: While 1 GUICtrlSetData($currentTime, _SoundPos($sound, 1)) If _SoundPos($sound, 2) = _SoundLength($sound, 2) Then ExitLoop Sleep(950) WEnd but when it's in the main loop everything else freeze and i can't do anything... Edited November 4, 2007 by Didonet Link to comment Share on other sites More sharing options...
Nahuel Posted November 4, 2007 Share Posted November 4, 2007 Well.. of course, you can't do that. But you can do it in different ways... for example, use only one main loop where you call a function that does what you want While 1 Myfunc() Sleep(950) ;Rest of the script.. WEnd Func Myfunc() GUICtrlSetData($currentTime, _SoundPos($sound, 1)) If _SoundPos($sound, 2) = _SoundLength($sound, 2) Then ExitLoop EndFunc ;==>Myfunc Maybe you can also take a look at AdlibEnable() Link to comment Share on other sites More sharing options...
Didonet Posted November 4, 2007 Author Share Posted November 4, 2007 (edited) That's the part of the main while: While 1 $msg = GUIGetMsg() ; Some code If $msg = $playButton Then Play($file) While 1 GUICtrlSetData($currentTime, _SoundPos($sound, 1)) If _SoundPos($sound, 2) = _SoundLength($sound, 2) Then ExitLoop Sleep(950) WEnd EndIf ; Some code Wend Where what to put? :blush: Edited November 4, 2007 by Didonet Link to comment Share on other sites More sharing options...
Nahuel Posted November 4, 2007 Share Posted November 4, 2007 Something like this.. While 1 $msg = GUIGetMsg() ; Some code If $msg = $playButton Then Play($file) Myfunc() Sleep(950) EndIf ; Some code Wend Func Myfunc() GUICtrlSetData($currentTime, _SoundPos($sound, 1)) EndFunc ;==>Myfunc But you adapt it to your needs, that might now work for you. It was just an idea. Link to comment Share on other sites More sharing options...
Didonet Posted November 4, 2007 Author Share Posted November 4, 2007 Yea, this works, but it refresh the time only once. If i put a loop everything "freezes" again... Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted November 5, 2007 Share Posted November 5, 2007 Maybe like this?? While 1 $msg = GUIGetMsg() ; Some code If $msg = $playButton Then Play($file) $Play = 1 EndIf If $Play = 1 GUICtrlSetData($currentTime, _SoundPos($sound, 1)) EndIf ; Some code Wend .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...
Didonet Posted November 5, 2007 Author Share Posted November 5, 2007 Yes! That's great! But when Play = 1 the GuiCtrlSetData is very fast and the process of the player is 50%> If I set a sleep after the GuiCtrlSetData something goes wrong... Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted November 5, 2007 Share Posted November 5, 2007 Yes! That's great! But when Play = 1 the GuiCtrlSetData is very fast and the process of the player is 50%> If I set a sleep after the GuiCtrlSetData something goes wrong...Maybe this is better then?? $SlowerPositions = 1 While 1 $msg = GUIGetMsg() ; Some code If $msg = $playButton Then Play($file) $Play = 1 EndIf If $Play = 1 And $SlowerPositions > 50 Then GUICtrlSetData($currentTime, _SoundPos($sound, 1)) $SlowerPositions = 1 EndIf $SlowerPositions = $SlowerPositions + 1 ; Some code Wend (If you want it go slower you increase 50) But then the updatingspeed would be dependent on the CPU.... Maybe you should think about using an Adlib instead?? .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...
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