eagle4life69 Posted December 6, 2006 Share Posted December 6, 2006 Okay here is my Script. What I need help on is the Timer does this flickering and it is annoying can I make it look fluid so it doesn't have a flicker expandcollapse popup#include <Array.au3> #include <File.au3> #include <GuiConstants.au3> #Include <GuiEdit.au3> WinClose("Subsonic 128k", "") If @DesktopDepth > 8 Then $WinImage = @TempDir & "\" & "Sr468.jpg" FileInstall("Sr468.jpg", $WinImage, 1) EndIf $StripeStart = 60 #region Object $oMyError = ObjEvent("AutoIt.Error","Quit") $oMediaplayer = ObjCreate("WMPlayer.OCX.7") If Not IsObj($oMediaplayer) Then Exit $oMediaplayer.Enabled = true $oMediaplayer.WindowlessVideo= true $oMediaPlayer.UImode="invisible" $oMediaPlayer.URL="http://www.arhynes.org/stream/m3u/128k.m3u" $oMediaPlayControl=$oMediaPlayer.Controls $oMediaPlaySettings=$oMediaPlayer.Settings GuiCreate("SubsonicRadio.com", 468, 175, -1, (@DesktopHeight / 2) - (@DesktopHeight / 4.25), -1,$WS_EX_TOPMOST) GUISetBkColor (0x2D3D4C) GUICtrlCreatePic($WinImage, 0, 0, 0, 0) GUICtrlCreateLabel("Now Playing",0,60,468,25,$SS_CENTER) GUICtrlSetColor(-1,0xDDDDDD) GUICtrlSetBkColor(-2,0x004371) GUICtrlSetFont(-3,8, 700) $Bar = GUICtrlCreateLabel("",0,76,468,25) $Nowplaying = GUICtrlCreateLabel("Receiving Song...",4,76,340,25) GUICtrlSetColor(-1,0xDDDDDD) ;~ GUICtrlSetBkColor(-2, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont(-3,8, 700) $Requester = GUICtrlCreateLabel("",352,76,80,15) GUICtrlSetColor(-1,0xDDDDDD) ;~ GUICtrlSetBkColor(-2, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont(-3,8, 700) $Length = GUICtrlCreateLabel("0:00",432,76,40,15) GUICtrlSetColor(-1,0xDDDDDD) GUICtrlSetFont(-3,8, 700) ;~ Volume $Volume = GuiCtrlCreateSlider(130, 120, 180, 20) GuiCtrlCreateLabel("Volume", 130, 105, 40, 20) GUICtrlSetColor(-1,0xDDDDDD) ; Gray GUISetState () GUICtrlSetData($Volume, 50) ; Created By $font="Comic Sans MS" GuiCtrlCreateLabel("Created By Eagle4life69", 0, 150,75, 25 ) GUICtrlSetFont (-1,7, 400,"",$font) GUICtrlSetColor(-2,0xDDDDDD) ; Gray ;~ Version GuiCtrlCreateLabel("Ver. 2.6", 428, 160, 40, 10) GUICtrlSetFont (-1,7, 400,"",$font) GUICtrlSetColor(-2,0xDDDDDD) ; Gray $Play = GuiCtrlCreateButton("Play", 100, 150, 40, 25,$WS_DLGFRAME) GUICtrlSetFont (-1,7, 400,"",$font) $Stop = GuiCtrlCreateButton("Stop", 160, 150, 40, 25,$WS_DLGFRAME) GUICtrlSetFont (-1,7, 400,"",$font) $Exit = GuiCtrlCreateButton("Exit", 220, 150, 40, 25,$WS_DLGFRAME) GUICtrlSetFont (-1,7, 400,"",$font) $Now = GuiCtrlCreateButton("Now Playing", 280, 150, 75, 25,$WS_DLGFRAME) GuiSetState() $VolLevel = 100 ;~ Song info while 1 $file2= "c:\Subsonicradio2.txt" InetGet("http://www.subsonicradio.com/station/current_song.php",$file2,1) $Lineslog = _FileCountLines($file2) If $Lineslog == "26" Then $songnumber = '8' $requestnumber = '7' $songcl = "0x006644" Else $songnumber = '9' $requestnumber = '8' $songcl = "0x6b314d" EndIf $songmath = ($Lineslog-$songnumber) $songline = FileReadLine($file2,$songmath) $song2 = StringStripWS ( $songline, 4 ) $song=StringReplace($song2,">","<") $song1=StringSplit($song,"<") $requestmath = ($Lineslog-$requestnumber) $requestline = FileReadLine($file2,$requestmath) $request=StringReplace($requestline,">","<") $request1=StringSplit($request,"<") If $request1[5] == "" Then $requestedby="*Random Play*" else $Re=$request1[5] $requestedby= $Re EndIf GUICtrlSetData($Nowplaying, $song1[1]) GUICtrlSetData($Requester, $requestedby) GUICtrlSetBkColor($Nowplaying, $songcl) GUICtrlSetBkColor($Bar,$songcl) GUICtrlSetBkColor($Requester, $songcl) GUICtrlSetBkColor($Length, $songcl) $begin = TimerStart() ;~ $begin=1 $mathlog = ($Lineslog-"6") $linelog = FileReadLine($file2,$mathlog) $timer=StringReplace($linelog,">","<") $timer=StringSplit($timer,"<") $amount=$timer[3]; default time $begin = TimerStart() while (TimerStop($begin)/1000)<$amount $time=$amount-int(TimerStop($begin)/1000)/1 if $time>60 then GUICtrlSetData($Length, int($time/60)&":"&$time-int($time/60)*60) else if $time<60 then GUICtrlSetData($Length, "0:" & $time) else if $time<10 then GUICtrlSetData($Length, "0" & $time) endif endif endif $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit ExitLoop Case $msg = $Play $oMediaPlayControl.Play Case $msg = $Stop $oMediaPlayControl.Stop Case $msg = $Exit $oMediaPlayControl.Stop Exit Case Else If GUICtrlread($Volume) <> $VolLevel Then $oMediaPlaySettings.Volume = GUICtrlRead($Volume) $VolLevel = GUICtrlRead($Volume) EndIf EndSelect wend WEnd Exit #endregion #region functions Func Quit() $oMediaPlayControl.Stop Exit EndFunc #endregion Thanks for your help Link to comment Share on other sites More sharing options...
ReverendJ1 Posted December 6, 2006 Share Posted December 6, 2006 Without really looking at your code (try just posting the pertinent code, we can be lazy here ) the reason for the flicker is because you are refreshing your textbox too often. If you can, put in a small sleep to pause the script. I have found about 100 ms seems to help. Link to comment Share on other sites More sharing options...
eagle4life69 Posted December 6, 2006 Author Share Posted December 6, 2006 Without really looking at your code (try just posting the pertinent code, we can be lazy here ) the reason for the flicker is because you are refreshing your textbox too often. If you can, put in a small sleep to pause the script. I have found about 100 ms seems to help. I did this and now I have a delay on all other functions. It waits for the Sleep to go away. Here is the Code and the Picture I used in it expandcollapse popupIf WinExists("SubsonicRadio.com") Then WinClose("SubsonicRadio.com", "") EndIf #include <Array.au3> #include <File.au3> #include <GuiConstants.au3> #Include <GuiEdit.au3> Opt("TrayMenuMode",1) If @DesktopDepth > 8 Then $WinImage = @TempDir & "\" & "Sr468.jpg" FileInstall("Sr468.jpg", $WinImage, 1) EndIf $StripeStart = 60 #region Object $oMyError = ObjEvent("AutoIt.Error","Quit") $oMediaplayer = ObjCreate("WMPlayer.OCX.7") If Not IsObj($oMediaplayer) Then Exit $oMediaplayer.Enabled = true $oMediaplayer.WindowlessVideo= true $oMediaPlayer.UImode="invisible" $oMediaPlayer.URL="http://www.arhynes.org/stream/m3u/128k.m3u" $oMediaPlayControl=$oMediaPlayer.Controls $oMediaPlaySettings=$oMediaPlayer.Settings GuiCreate("SubsonicRadio.com", 468, 195, -1, (@DesktopHeight / 2) - (@DesktopHeight / 4.25), -1) $filemenu = GUICtrlCreateMenu ("&File") $fileitem = GUICtrlCreateMenu ("Play",$filemenu,1) GUICtrlSetState(-1,$GUI_DEFBUTTON) $24k = GUICtrlCreateMenuitem ("24k Stream",$fileitem) $64k = GUICtrlCreateMenuitem ("64k Stream",$fileitem) $128k = GUICtrlCreateMenuitem ("128k Stream",$fileitem) $mute = GUICtrlCreateMenuitem ("Mute",$filemenu) $helpmenu = GUICtrlCreateMenu ("?") $infoitem = GUICtrlCreateMenuitem ("About",$helpmenu) $exititem = GUICtrlCreateMenuitem ("Exit",$filemenu) $separator1 = GUICtrlCreateMenuitem ("",$filemenu,2) ; create a separator line $viewmenu = GUICtrlCreateMenu("View",-1,1) ; is created before "?" menu GUISetBkColor (0x2D3D4C) GUICtrlCreatePic($WinImage, 0, 0, 0, 0) GUICtrlCreateLabel("Now Playing",0,60,468,25,$SS_CENTER) GUICtrlSetColor(-1,0xDDDDDD) GUICtrlSetBkColor(-2,0x004371) GUICtrlSetFont(-3,8, 700) $Bar = GUICtrlCreateLabel("",0,76,468,25) $Nowplaying = GUICtrlCreateLabel("Receiving Song...",0,76,345,25,$SS_SUNKEN ) GUICtrlSetColor(-1,0xDDDDDD) ;~ GUICtrlSetBkColor(-2, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont(-3,8, 700) $Requester = GUICtrlCreateLabel("",345,76,90,25,0x1001 ) GUICtrlSetColor(-1,0xDDDDDD) ;~ GUICtrlSetBkColor(-2, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont(-3,8, 700) $Length = GUICtrlCreateLabel("0:00",435,76,33,25,0x1001 ) GUICtrlSetColor(-1,0xDDDDDD) GUICtrlSetFont(-3,8, 700) ;~ Volume $Volume = GuiCtrlCreateSlider(130, 120, 120, 20) GuiCtrlCreateLabel("Volume", 130, 105, 40, 20) GUICtrlSetColor(-1,0xDDDDDD) ; Gray GUISetState () GUICtrlSetData($Volume, 100) ; Created By $font="Comic Sans MS" GuiCtrlCreateLabel("Created By Eagle4life69", 0, 150,75, 25 ) GUICtrlSetFont (-1,7, 400,"",$font) GUICtrlSetColor(-2,0xDDDDDD) ; Gray ;~ Version GuiCtrlCreateLabel("Ver. 2.6", 428, 160, 40, 10) GUICtrlSetFont (-1,7, 400,"",$font) GUICtrlSetColor(-2,0xDDDDDD) ; Gray $Play = GuiCtrlCreateButton("Play", 100, 150, 40, 25,$WS_DLGFRAME) GUICtrlSetFont (-1,7, 400,"",$font) $Stop = GuiCtrlCreateButton("Stop", 160, 150, 40, 25,$WS_DLGFRAME) GUICtrlSetFont (-1,7, 400,"",$font) GuiSetState() $VolLevel = 100 ;~ Song info while 1 $file2= "c:\Subsonicradio2.txt" InetGet("http://www.subsonicradio.com/station/current_song.php",$file2,1) $Lineslog = _FileCountLines($file2) If $Lineslog == "26" Then $songnumber = '8' $requestnumber = '7' $songcl = "0x006644" Else $songnumber = '9' $requestnumber = '8' $songcl = "0x6b314d" EndIf $songmath = ($Lineslog-$songnumber) $songline = FileReadLine($file2,$songmath) $song2 = StringStripWS ( $songline, 4 ) $song=StringReplace($song2,">","<") $song1=StringSplit($song,"<") $requestmath = ($Lineslog-$requestnumber) $requestline = FileReadLine($file2,$requestmath) $request=StringReplace($requestline,">","<") $request1=StringSplit($request,"<") If $request1[5] == "" Then $requestedby="*Random Play*" else $Re=$request1[5] $requestedby= $Re EndIf GUICtrlSetData($Nowplaying, $song1[1]) GUICtrlSetData($Requester, $requestedby) GUICtrlSetBkColor($Nowplaying, $songcl) GUICtrlSetBkColor($Bar,$songcl) GUICtrlSetBkColor($Requester, $songcl) GUICtrlSetBkColor($Length, $songcl) $begin = TimerStart() ;~ $begin=1 $mathlog = ($Lineslog-"6") $linelog = FileReadLine($file2,$mathlog) $timer=StringReplace($linelog,">","<") $timer=StringSplit($timer,"<") $amount=$timer[3]; default time $begin = TimerStart() while (TimerStop($begin)/1000)<$amount $time=$amount-int(TimerStop($begin)/1000)/1 if $time>60 then GUICtrlSetData($Length, int($time/60)&":"&$time-int($time/60)*60) elseif $time<60 then GUICtrlSetData($Length, "0:" & $time) ;~ elseif $time<10 then ;~ GUICtrlSetData($Length, "0" & $time) endif $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE $oMediaPlayControl.Stop Exit ExitLoop Case $msg = $Play $oMediaPlayControl.Play Case $msg = $Stop $oMediaPlayControl.Stop Case $msg = $exititem $oMediaPlayControl.Stop Exit Case $msg = $mute If GUICtrlRead($mute,1) == "Mute" Then GUICtrlSetData($Volume, 0) GUICtrlSetData($mute,"Unmute") Else GUICtrlSetData($Volume, 100) GUICtrlSetData($mute,"Mute") EndIf Case Else If GUICtrlread($Volume) <> $VolLevel Then $oMediaPlaySettings.Volume = GUICtrlRead($Volume) $VolLevel = GUICtrlRead($Volume) EndIf EndSelect wend WEnd Exit #endregion #region functions Func Quit() $oMediaPlayControl.Stop Exit EndFunc #endregion Link to comment Share on other sites More sharing options...
ReverendJ1 Posted December 6, 2006 Share Posted December 6, 2006 Here you go. I got it all nice and pretty. I commented out the TWO parts I changed. BTW I think you posted the exact same code twice....... Anywho, I made it check to see if the time is different than last time before it updates the text box. I also fixed it so that it will pad the seconds & minutes with a 0 if they are less than 10. i.e. 9 minutes 7 seconds was showing up as 9:7, now it is 09:07. Not sure if it is necessary for the minutes, just take that if statement out otherwise, it will automatically be a zero for minutes if it needs to be, i.e. 0:30. Everything should be pretty self explanatory, if not, let me know. expandcollapse popupIf WinExists("SubsonicRadio.com") Then WinClose("SubsonicRadio.com", "") EndIf #include <Array.au3> #include <File.au3> #include <GuiConstants.au3> #Include <GuiEdit.au3> Opt("TrayMenuMode",1) ;;;;;;;;;; Code from ReverendJ1 Dim $OldTime ;;;;;;;;;; End code from ReverendJ1 If @DesktopDepth > 8 Then $WinImage = @TempDir & "\" & "Sr468.jpg" FileInstall("Sr468.jpg", $WinImage, 1) EndIf $StripeStart = 60 #region Object $oMyError = ObjEvent("AutoIt.Error","Quit") $oMediaplayer = ObjCreate("WMPlayer.OCX.7") If Not IsObj($oMediaplayer) Then Exit $oMediaplayer.Enabled = true $oMediaplayer.WindowlessVideo= true $oMediaPlayer.UImode="invisible" $oMediaPlayer.URL="http://www.arhynes.org/stream/m3u/128k.m3u" $oMediaPlayControl=$oMediaPlayer.Controls $oMediaPlaySettings=$oMediaPlayer.Settings GuiCreate("SubsonicRadio.com", 468, 195, -1, (@DesktopHeight / 2) - (@DesktopHeight / 4.25), -1) $filemenu = GUICtrlCreateMenu ("&File") $fileitem = GUICtrlCreateMenu ("Play",$filemenu,1) GUICtrlSetState(-1,$GUI_DEFBUTTON) $24k = GUICtrlCreateMenuitem ("24k Stream",$fileitem) $64k = GUICtrlCreateMenuitem ("64k Stream",$fileitem) $128k = GUICtrlCreateMenuitem ("128k Stream",$fileitem) $mute = GUICtrlCreateMenuitem ("Mute",$filemenu) $helpmenu = GUICtrlCreateMenu ("?") $infoitem = GUICtrlCreateMenuitem ("About",$helpmenu) $exititem = GUICtrlCreateMenuitem ("Exit",$filemenu) $separator1 = GUICtrlCreateMenuitem ("",$filemenu,2) ; create a separator line $viewmenu = GUICtrlCreateMenu("View",-1,1) ; is created before "?" menu GUISetBkColor (0x2D3D4C) GUICtrlCreatePic($WinImage, 0, 0, 0, 0) GUICtrlCreateLabel("Now Playing",0,60,468,25,$SS_CENTER) GUICtrlSetColor(-1,0xDDDDDD) GUICtrlSetBkColor(-2,0x004371) GUICtrlSetFont(-3,8, 700) $Bar = GUICtrlCreateLabel("",0,76,468,25) $Nowplaying = GUICtrlCreateLabel("Receiving Song...",0,76,345,25,$SS_SUNKEN ) GUICtrlSetColor(-1,0xDDDDDD) ;~ GUICtrlSetBkColor(-2, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont(-3,8, 700) $Requester = GUICtrlCreateLabel("",345,76,90,25,0x1001 ) GUICtrlSetColor(-1,0xDDDDDD) ;~ GUICtrlSetBkColor(-2, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont(-3,8, 700) $Length = GUICtrlCreateLabel("0:00",435,76,33,25,0x1001 ) GUICtrlSetColor(-1,0xDDDDDD) GUICtrlSetFont(-3,8, 700) ;~ Volume $Volume = GuiCtrlCreateSlider(130, 120, 120, 20) GuiCtrlCreateLabel("Volume", 130, 105, 40, 20) GUICtrlSetColor(-1,0xDDDDDD) ; Gray GUISetState () GUICtrlSetData($Volume, 100) ; Created By $font="Comic Sans MS" GuiCtrlCreateLabel("Created By Eagle4life69", 0, 150,75, 25 ) GUICtrlSetFont (-1,7, 400,"",$font) GUICtrlSetColor(-2,0xDDDDDD) ; Gray ;~ Version GuiCtrlCreateLabel("Ver. 2.6", 428, 160, 40, 10) GUICtrlSetFont (-1,7, 400,"",$font) GUICtrlSetColor(-2,0xDDDDDD) ; Gray $Play = GuiCtrlCreateButton("Play", 100, 150, 40, 25,$WS_DLGFRAME) GUICtrlSetFont (-1,7, 400,"",$font) $Stop = GuiCtrlCreateButton("Stop", 160, 150, 40, 25,$WS_DLGFRAME) GUICtrlSetFont (-1,7, 400,"",$font) GuiSetState() $VolLevel = 100 ;~ Song info while 1 $file2= "c:\Subsonicradio2.txt" InetGet("http://www.subsonicradio.com/station/current_song.php",$file2,1) $Lineslog = _FileCountLines($file2) If $Lineslog == "26" Then $songnumber = '8' $requestnumber = '7' $songcl = "0x006644" Else $songnumber = '9' $requestnumber = '8' $songcl = "0x6b314d" EndIf $songmath = ($Lineslog-$songnumber) $songline = FileReadLine($file2,$songmath) $song2 = StringStripWS ( $songline, 4 ) $song=StringReplace($song2,">","<") $song1=StringSplit($song,"<") $requestmath = ($Lineslog-$requestnumber) $requestline = FileReadLine($file2,$requestmath) $request=StringReplace($requestline,">","<") $request1=StringSplit($request,"<") If $request1[5] == "" Then $requestedby="*Random Play*" else $Re=$request1[5] $requestedby= $Re EndIf GUICtrlSetData($Nowplaying, $song1[1]) GUICtrlSetData($Requester, $requestedby) GUICtrlSetBkColor($Nowplaying, $songcl) GUICtrlSetBkColor($Bar,$songcl) GUICtrlSetBkColor($Requester, $songcl) GUICtrlSetBkColor($Length, $songcl) $begin = TimerStart() ;~ $begin=1 $mathlog = ($Lineslog-"6") $linelog = FileReadLine($file2,$mathlog) $timer=StringReplace($linelog,">","<") $timer=StringSplit($timer,"<") $amount=$timer[3]; default time $begin = TimerStart() while (TimerStop($begin)/1000)<$amount $time=$amount-int(TimerStop($begin)/1000)/1 ;;;;;;;;;;; Code from ReverendJ1 $Minutes = Int($time/60) $Seconds = $time - ($Minutes * 60) If $Minutes < 10 Then $Minutes = "0" & $Minutes EndIf If $Seconds < 10 Then $Seconds = "0" & $Seconds EndIf $NewTime = $Minutes & ":" & $Seconds If $NewTime <> $OldTime Then GUICtrlSetData($Length, $NewTime) $OldTime = $NewTime EndIf ;;;;;;;;;; End code from ReverendJ1 ;~ elseif $time<10 then ;~ GUICtrlSetData($Length, "0" & $time) $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE $oMediaPlayControl.Stop Exit ExitLoop Case $msg = $Play $oMediaPlayControl.Play Case $msg = $Stop $oMediaPlayControl.Stop Case $msg = $exititem $oMediaPlayControl.Stop Exit Case $msg = $mute If GUICtrlRead($mute,1) == "Mute" Then GUICtrlSetData($Volume, 0) GUICtrlSetData($mute,"Unmute") Else GUICtrlSetData($Volume, 100) GUICtrlSetData($mute,"Mute") EndIf Case Else If GUICtrlread($Volume) <> $VolLevel Then $oMediaPlaySettings.Volume = GUICtrlRead($Volume) $VolLevel = GUICtrlRead($Volume) EndIf EndSelect wend WEnd Exit #endregion #region functions Func Quit() $oMediaPlayControl.Stop Exit EndFunc #endregion I also Tidied it all up so the if then statements, etc. are lined up properly. You should get rid of all those extra lines everywhere, they make your code really hard to read. Link to comment Share on other sites More sharing options...
eagle4life69 Posted December 7, 2006 Author Share Posted December 7, 2006 Thanks so Much Not a huge chane but it fixed it. Thanks Link to comment Share on other sites More sharing options...
ReverendJ1 Posted December 7, 2006 Share Posted December 7, 2006 Glad I could help. 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