ajit Posted December 21, 2012 Posted December 21, 2012 (edited) Hi, I am using windows media player object for my audio player. I need my player to remember the last set volume on the player if possible. I can use an INI file to store the last audio volume but i do not know how to get the current volume to store it on exiting the window. Any help would be appreciated. Regards Ajit expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ;*** Build GUI: Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form=C:\WinSpr\AutoIt\_Eigenes\COMStati.kxf $Form1 = GUICreate("Media Player", 600, 400, -1, -1, $WS_SYSMENU) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") $File_Path = GUICtrlCreateInput("", 10, 100, 300) $Browse_Btn = GUICtrlCreateButton("...", 315, 100, 20, 20) GUIctrlSetOnEvent($Browse_Btn, "browse") Global $oRP $oRP = ObjCreate("MediaPlayer.MediaPlayer.1") If Not IsObj($oRP) Then MsgBox(48, "ERROR...", "object failed") Exit EndIf $GUIActiveX = GUICtrlCreateObj($oRP, 10, -220, 280, 285) $oRPEvt = ObjEvent($oRP, "MediaPlayer_") With $oRP; Object tag pool .Rate = 10 .AutoStart = False .playcount = 0; 0,1,2,3 .displaysize = True .windowlessVideo = True .showControls = True .EnableContextMenu = True .ShowPositionControls = True ;~ .ShowStatusBar = True .ShowTracker = True .EnableTracker = True .showaudiocontrols = True .EnablePositionControls = True .Enabled = True .ShowDisplay = False .ShowGotoBar = False .Mute = False .Filename = "" ;~ .play ;.Play; .stop .pause ConsoleWrite(.openState & @CRLF); 0 Not ready, 6 Playing ConsoleWrite(.currentPosition) ConsoleWrite(.duration & @CRLF) ConsoleWrite(.PlayState & @CRLF); 0 Stopped, 1 Pause, 2 playing ;~ .SendKeyboardEvents = true .ClickToPlay = False .AutoRewind = False .CurrentPosition = 0 ;.volume = 0; -10000 ;~ .volume = -9000; -10000 ;~ .balance = -10000; -10000 ;~ .AboutBox EndWith GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $oRP.ShowPositionControls = True Consolewrite($oRP.volume & @CRLF) Sleep(100) WEnd Func Form1Close() Exit EndFunc Func browse() $var = FileOpenDialog("Select file to play", @DesktopDir& "\", "Images (*.mp3;*.wav)");, 1 + 4 ) GUICtrlSetData($File_Path, $var ) $oRP.Filename = $var EndFunc Edited December 21, 2012 by ajit
careca Posted December 22, 2012 Posted December 22, 2012 (edited) Ill show u what i got on mine: Start of script $Vol2 = IniRead($iFile, 'Volume', 'Vol', '') If $Vol2 = '' Then $Vol = 100 Else $Vol = $Vol2 EndIf GUICtrlSetData($Slider2, $Vol) On a continuous loop ;============================================================================= $Vol2 = IniRead($iFile, 'Volume', 'Vol', 'default') $Vol = GUICtrlRead($Slider2, 1) SoundSetWaveVolume($Vol) GUICtrlSetData($InfoVol, $Vol & '%') ;============================================================================= If $Vol <> $Vol2 Then IniWrite($iFile, 'Volume', 'Vol', $Vol) EndIf ;============================================================================= get it? greetz Edited December 22, 2012 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
ajit Posted December 22, 2012 Author Posted December 22, 2012 @careca, Thanks for your reply. But I don't see any way to write data to an INI file unless I have the current volume of the player to be able to use to write the INI data. My problem is I cannot obtain the current volume in any readable form. Thanks and regards Ajit
careca Posted December 23, 2012 Posted December 23, 2012 hmmm, and i guess you don't understand the code. $Vol2 = IniRead($iFile, 'Volume', 'Vol', 'default') ;<<<<< Read the value from the ini file 0-100 $Vol = GUICtrlRead($Slider2, 1) ;<<<<< Read slider position, and retrieve value 0-100 SoundSetWaveVolume($Vol) ;<<<<< Use the previous value to set volume If $Vol <> $Vol2 Then ;<<<<If vol is different from vol2, means the value written on file is different, from the one on the slider IniWrite($iFile, 'Volume', 'Vol', $Vol) ;<<<< so we write the correct/updated value EndIf Get it? Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
ajit Posted December 23, 2012 Author Posted December 23, 2012 @carecaThanks for your response.Would you mind integrating your code into mine.My problem is I have NO slider (nor do i intend to use one) so question of GUICtrlRead does not arise.I want to use slider of 'Media Player Object' whose reading i cannot get.Thanks and regards,Ajit
careca Posted December 23, 2012 Posted December 23, 2012 Hi, im sorry, i don't understand anything about objects, your code here only shows a black box and a fileopen dialog... Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
ajit Posted December 23, 2012 Author Posted December 23, 2012 @careca,I guess problem with OS. I am on XP Professional, Service Pack 3RegardsAjit
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