Skizmata Posted August 2, 2007 Share Posted August 2, 2007 Please change Const $FileLocation to some mp3 on your HD for testing. I'm fairly new so please be easy on me. Basically all I'm looking for is a GUI with a nice seek bar that allows you to drag it forward in the file and back. Below is what I have and its not working at all. Thank you kindly forum goers for your assistance. #include <GUIConstants.au3> #include <Sound.au3> #include <Sound_Addendum.au3> Const $FileLocation = ""D:\mp3\10.000 days5 the pot.mp3"" Global $LastPosValue _SoundOpen($FileLocation, "FileHandle") $TotalMilliSeconds = _SoundLength("FileHandle", 2) _SoundPlay("FileHandle") $Form1 = GUICreate("Test", 324, 113, 324, 440, -1, BitOR($WS_EX_APPWINDOW, $WS_EX_WINDOWEDGE)) $PosSlider = GUICtrlCreateSlider(16, 55, 300, 20) GUICtrlSetLimit($PosSlider, $TotalMilliSeconds, 0) GUICtrlSetData($PosSlider, 0) GUISetState(@SW_SHOW) While 1 Sleep(10) $PosValue = GUICtrlRead($PosSlider) If GUICtrlRead($PosSlider) < _SoundPos("FileHandle",2) + 250 Or GUICtrlRead($PosSlider) > _SoundPos("FileHandle",2) + 250 Then Else _SoundSeek_MS("FileHandle", GUICtrlRead($PosSlider)) EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEndoÝ÷ ØýË«{*.bqçjºbÉnuémJ§t]zwn«·Ú®¢Ø+Þ²g䨺wRyéJ+jvÞ~§vêå AutoIt changed my life. Link to comment Share on other sites More sharing options...
qazwsx Posted August 2, 2007 Share Posted August 2, 2007 (edited) Take a look in the example script forums there haver recently been a lot of media players. There code should send you in the right direction.Edit: heres one http://www.autoitscript.com/forum/index.php?showtopic=48542 Edited August 2, 2007 by sccrstvn93 Link to comment Share on other sites More sharing options...
sandman Posted August 2, 2007 Share Posted August 2, 2007 (edited) Put something like this: While 1 $msg = GUIGetMsg() Switch $msg Case $PosSlider $read = GUICtrlRead($PosSlider) $len = _SoundLength($Sound, 2) $seek = Round($read / $len, 0) _SoundSeek_MS($Sound, $seek) EndSwitch WEnd$PosSlider will always return a percentage of 100% (100% being at the far right of the slider). For an example of what I am doing here: The user sets the slider to 25%. The program finds 25% of the total song length, then seeks to there. NOTE: To get this to work you'll have to assign the variable $Sound to the _SoundPlay function you've got in there. What your original script did was try to seek to a percent value, which would have just (silently) errored out. Hope this helps. Edited August 2, 2007 by sandman [center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center] Link to comment Share on other sites More sharing options...
ronriel Posted August 2, 2007 Share Posted August 2, 2007 (edited) Here's a quick example: expandcollapse popup#include <GUIConstants.au3> #include <Sound.au3> #include <Date.au3> Const $FileLocation ="D:\mp3\10.000 days5 the pot.mp3" Dim $var, $hour, $min, $sec $Form1 = GUICreate("Test", 324, 113, 324, 440, -1, BitOR($WS_EX_APPWINDOW, $WS_EX_WINDOWEDGE)) $PosSlider = GUICtrlCreateSlider(16, 55, 300, 20) GUISetState(@SW_SHOW) _SoundOpen($FileLocation, "FileHandle") $TotalMilliSeconds = _SoundLength("FileHandle", 2) _SoundPlay("FileHandle") While 1 Sleep(10) $ci = GUIGetCursorInfo($Form1) If $ci[2] = 1 And $ci[4] = $PosSlider Then;user presses on the slider _TicksToTime(GUICtrlRead($PosSlider) / 100 * $TotalMilliSeconds, $hour, $min, $sec) ToolTip($hour & ":" & $min & ":" & $sec) $var = 1 ContinueLoop EndIf If $var = 1 And $ci[2] = 0 Then;only seek after user releases the slider _SoundSeek("FileHandle", $hour, $min, $sec) _SoundPlay("FileHandle") ToolTip('') $var = 0 EndIf $Pos = _SoundPos("FileHandle", 2) GUICtrlSetData($PosSlider, $Pos / $TotalMilliSeconds * 100); move the slider as the song progresses If $Pos = $TotalMilliSeconds Then _SoundClose("FileHandle") If GUIGetMsg() = $GUI_EVENT_CLOSE Then _SoundClose("FileHandle") Exit EndIf WEnd I hope that helps! note: you don't need "Sound_Addendum.au3" anymore. You can also use AdlibEnable in place of the While - Wend loop. That way, the script uses less memory and CPU. Edited August 2, 2007 by ronriel [font="Comic Sans MS"]-ronriel[/font][topic="48542"]r4r media player[/topic][topic="80836"]OCR & Paste[/topic] Link to comment Share on other sites More sharing options...
Skizmata Posted August 2, 2007 Author Share Posted August 2, 2007 (edited) Thank you all very much problem solved, and solved well. Funny how the example sccrstvn93 pointed me to was from ronriel who ended up delivering a fantastic solution in person. Thank you both! @Sandman I didn't understand that it was dealing with a % thank you this is much more logical now. Since it wasn't giving me any errors I wasn't getting what the problem was. This forum is great! I asked a question and got 3 actual helpful responses in 2 hours. Without someone telling me I'm a noob and my code sucks! Thanks again. Edited August 2, 2007 by Skizmata AutoIt changed my life. Link to comment Share on other sites More sharing options...
ronriel Posted August 3, 2007 Share Posted August 3, 2007 (edited) You're welcome! This forum is great! I asked a question and got 3 actual helpful responses in 2 hours. Without someone telling me I'm a noob and my code sucks!...because comments like that are uncalled-for. After all, we all started out as noobs. How else? Edited August 3, 2007 by ronriel [font="Comic Sans MS"]-ronriel[/font][topic="48542"]r4r media player[/topic][topic="80836"]OCR & Paste[/topic] Link to comment Share on other sites More sharing options...
sandman Posted August 3, 2007 Share Posted August 3, 2007 (edited) Without someone telling me I'm a noob and my code sucks!No problem. We only say that to the game bot makers; we despise them. Cute baby btw. Edited August 3, 2007 by sandman [center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center] 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