Advertisement
Guest User

Untitled

a guest
Jun 9th, 2011
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 9.64 KB | None | 0 0
  1. #include 'BASS.au3'
  2. #include <Sound.au3>
  3. #include <Array.au3>
  4. #include <GUIConstants.au3>
  5. #include <WindowsConstants.au3>
  6. #include <SliderConstants.au3>
  7. #include <GUISlider.au3>
  8. #include <GDIPlus.au3>
  9. #include <GUIListView.au3>
  10. #include <GUIImageList.au3>
  11. # End
  12.  
  13. If $CMDLine[0] > 0 And $CMDLine[1] = "/pirate" Then ShellExecute("http://gianluthebest.altervista.org/software/mymediaplayer/lol.swf")
  14.  
  15. ;Settings
  16. Opt("GUIonEventMode", 1)
  17. Opt("TrayMenuMode", 3)
  18.  
  19.  
  20. Global Const $Titolo = "My Media Player 4"
  21. Global Const $Len = StringLen($Titolo)
  22. Global $Array = StringSplit($Titolo, "", 2), $Array2 = StringSplit("Caricamento...", "", 2)
  23. Global $Sound, $Sound_Opened, $FileOpen, $Volume = 81, $GUI_INFO, $W = 10, $H = 50
  24. Global $ItemCurrent = 0, $Versione = "3.9.3 beta"
  25. Global $hDevice = -1, $hFreq = 48000 ; 44100 High Quality -- 48000 Very High quality
  26. Global $hDEBUG = True
  27. Global $CurrentLanguage = "it"
  28. Global $SupportedFile = "*.mp3;*.wav;*.wma;"
  29. Global $SizeCurrentSong = 0
  30. Global Const $Credits = "Versione " & $Versione & @CR & "Creata da" & @CR & "- Gianlu-thebest Ideatore e sviluppatore principale" &@CR & "- Acidburn16 per supporto video nella v3"&@CR&"- Giorgi Marco per supporto nello slider"
  31. ;~ Dim $hTXT[] = _
  32. ;~  [""]
  33.  
  34. ;Bass DLL
  35. _BASS_Startup()
  36. if @error Then exit @error
  37. _BASS_Init(0, $hDevice, $hFreq, 0, "")
  38. if @error Then exit @error
  39.  
  40. ;GDI+
  41. _GDIPlus_Startup()
  42.  
  43. If $hDEBUG = False Then
  44.     $Splash_Startup = GUICreate($Titolo, 500, 200, -1, -1, $WS_POPUP)
  45.     WinSetTrans($Splash_Startup, "", 0)
  46.     GUISetState(@SW_SHOW)
  47.     $Graphic = _GDIPlus_GraphicsCreateFromHWND($Splash_Startup)
  48.     _GDIPlus_GraphicsClear($Graphic, 0xFFFFFFFF)
  49.     $Font = _GDIPlus_FontFamilyCreate("Comic Sans MS")
  50.     $Brush = _GDIPlus_BrushCreateSolid(0xFFFF0000)
  51.     $Font = _GDIPlus_FontCreate($Font, 15)
  52.     $Layout = _GDIPlus_RectFCreate($W, $H, 100, 100)
  53.     $Format = _GDIPlus_StringFormatCreate()
  54.     For $i = 0 To 255
  55.         WinSetTrans($Splash_Startup, "", $i)
  56.     Next
  57.  
  58.     For $i In $Array
  59.         _GDIPlus_GraphicsDrawStringEx($Graphic, $i, $Font, $Layout, $Format, $Brush)
  60.         $W += 20
  61.         $Layout = _GDIPlus_RectFCreate($W, $H)
  62.         $Brush = _GDIPlus_BrushCreateSolid("0xFF" & Random(11, 99, 1) & Random(11, 99, 1) & Random(11, 99, 1))
  63.         Sleep(100)
  64.     Next
  65.     Sleep(500)
  66.     $H += 90 + 10
  67.     $W -= ($W - 50)
  68.     $Layout = _GDIPlus_RectFCreate($W, $H)
  69.     $Brush = _GDIPlus_BrushCreateSolid("0xFF" & Random(11, 99, 1) & Random(11, 99, 1) & Random(11, 99, 1))
  70.     For $i In $Array2
  71.         _GDIPlus_GraphicsDrawStringEx($Graphic, $i, $Font, $Layout, $Format, $Brush)
  72.         $W += 20
  73.         $Layout = _GDIPlus_RectFCreate($W, $H)
  74.         $Brush = _GDIPlus_BrushCreateSolid("0xFF" & Random(11, 99, 1) & Random(11, 99, 1) & Random(11, 99, 1))
  75.         Sleep(100)
  76.     Next
  77.     Sleep(500)
  78.     GUIDelete($Splash_Startup)
  79. EndIf
  80.  
  81. $GUI = GUICreate("My Media Player 4", 600, 500, -1, -1)
  82. GUICtrlCreatePic("images\sfondo.jpg", 0, 0, 600, 500)
  83. GUICtrlSetState(-1, 128)
  84.  
  85. GUICtrlCreateTab(1, 1, 598, 498)
  86.  
  87. ; ================== Riproduzione ====================
  88. GUICtrlCreateTabItem("Riproduzione")
  89.  
  90. $Apri = GUICtrlCreateButton("Apri", 15, 25, 101, 30)
  91. GUICtrlSetResizing(-1, 1)
  92. GUICtrlSetOnEvent($Apri, "_Apri")
  93.  
  94. $Play = GUICtrlCreateButton(";", 275, 120, 50, 50)
  95. GUICtrlSetResizing(-1, 1)
  96. GUICtrlSetOnEvent($Play, "_Play_Pause")
  97. GUICtrlSetState(-1, 128)
  98. GUICtrlSetFont($Play, 15, Default, Default, "WebDings")
  99.  
  100. $Back = GUICtrlCreateButton(7, 225, 120, 50, 50)
  101. GUICtrlSetResizing(-1, 1)
  102. GUICtrlSetOnEvent($Back, "_Back")
  103. GUICtrlSetState(-1, 128)
  104. GUICtrlSetFont($Back, 15, Default, Default, "WebDings")
  105.  
  106. $Next = GUICtrlCreateButton(8, 325, 120, 50, 50)
  107. GUICtrlSetResizing(-1, 1)
  108. GUICtrlSetOnEvent($Next, "_Next")
  109. GUICtrlSetState(-1, 128)
  110. GUICtrlSetFont($Next, 15, Default, Default, "WebDings")
  111.  
  112. $Volume_Slider = GUICtrlCreateSlider(400, 135, 150, 25)
  113. GUICtrlSetResizing(-1, 1)
  114. _GUICtrlSlider_SetRange($Volume_Slider, 0, 100)
  115.  
  116. $Volume_Label = GUICtrlCreateLabel("Volume: " & $Volume, 460, 110, 100)
  117. GUICtrlSetResizing(-1, 1)
  118. GUICtrlSetBkColor($Volume_Label, -2)
  119. GUICtrlSetData($Volume_Slider, 80)
  120.  
  121. $Pos_Label = GUICtrlCreateLabel("Posizione: ", 15, 110, 200)
  122. GUICtrlSetResizing(-1, 1)
  123. GUICtrlSetBkColor($Pos_Label, -2)
  124.  
  125. $Label_File = GUICtrlCreateLabel("File: Nessuno", 15, 90, 600)
  126. GUICtrlSetResizing(-1, 1)
  127. GUICtrlSetBkColor($Label_File, -2)
  128.  
  129. $List = GUICtrlCreateListView("Canzone|Percorso", 15, 200, 570, 150)
  130. _GUICtrlListView_SetColumnWidth($List, 0, 280)
  131. _GUICtrlListView_SetColumnWidth($List, 1, 290)
  132.  
  133. $Label_Info = GUICtrlCreateLabel($Credits, 15, 425, 570, 150)
  134.  
  135. GUICtrlCreateButton("Pulisci lista", 15, 355)
  136. GUICtrlSetOnEvent(-1, "_ClearList")
  137.  
  138. GUICtrlCreatePic("images\mymediaplayer.bmp", 175, 20, 370, 74)
  139. GUICtrlSetOnEvent(-1, "_MMP")
  140.  
  141. $Slider = GUICtrlCreateSlider(12, 175, 576, 22)
  142. GUICtrlSetOnEvent($Slider, "_Move")
  143.  
  144. GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
  145.  
  146. AdlibRegister("End", 200)
  147. AdlibRegister("barra", 1000)
  148.  
  149. GUISetState(@SW_SHOW, $GUI)
  150. Do
  151.     If _GUICtrlSlider_GetPos($Volume_Slider) <> $Volume Then
  152.         $Volume = GUICtrlRead($Volume_Slider)
  153.         If $Sound_Opened = True Then
  154.             _BASS_ChannelSetVolume($Sound, $Volume)
  155.             If @error Then Exit @error
  156.         EndIf
  157.         GUICtrlSetData($Volume_Label, "Volume: " & $Volume)
  158.     EndIf
  159. ;~  If GUICtrlRead($Pos_Label) <> "Posizione: "&_SoundPos($Sound)&"/"&_SoundLength($Sound) Then GUICtrlSetData($Pos_Label,"Posizione: "&_SoundPos($Sound)&"/"&_SoundLength($Sound))
  160.  
  161.     Sleep(100)
  162. Until False
  163.  
  164.  
  165. Func barra()
  166.     If Not $Sound_Opened Then Return 0
  167.     $CurrentPos = _BASS_ChannelGetPosition($Sound,$BASS_POS_BYTE)
  168.     ConsoleWrite($CurrentPos & " " & $SizeCurrentSong & @CRLF)
  169.     _GUICtrlSlider_SetPos($Slider,$CurrentPos)
  170. EndFunc   ;==>barra
  171.  
  172. Func _Exit()
  173.     _GDIPlus_Shutdown()
  174.     _BASS_Free()
  175.     Exit
  176. EndFunc   ;==>_Exit
  177.  
  178. Func _Move()
  179.     _BASS_ChannelSetPosition($Sound,_GUICtrlSlider_GetPos($Slider),$BASS_POS_BYTE)
  180. EndFunc   ;==>_Move
  181.  
  182. Func _Apri()
  183.     $FileOpen = FileOpenDialog("Apri un file", "", "All Media Files Supported ("&$SupportedFile&")", 4, "", $GUI)
  184.     If Not @error Then
  185.         If $Sound_Opened = True And _BASS_ChannelIsActive($Sound) <> $BASS_ACTIVE_PLAYING Then
  186.             _BASS_ChannelStop($Sound)
  187.             $Sound_Opened = False
  188.             $PlaySong = False
  189.         EndIf
  190.         If Not IsDeclared("PlaySong") Then $PlaySong = True
  191.  
  192.         $Split2 = StringSplit($FileOpen, "|")
  193.         If @error Then
  194.             GUICtrlSetData($Label_File, "File: " & FileGetName($FileOpen))
  195.             _GUICtrlListView_InsertItem($List, FileGetName($FileOpen))
  196.             _GUICtrlListView_AddSubItem($List, _GUICtrlListView_GetItemCount($List) - 1, $FileOpen, 1)
  197.         Else
  198.             For $i = 2 To $Split2[0]
  199.                 _GUICtrlListView_InsertItem($List, $Split2[$i])
  200.                 _GUICtrlListView_AddSubItem($List, $i - 2, $Split2[1] & "\" & $Split2[$i], 1)
  201.             Next
  202.         EndIf
  203.  
  204.         If _GUICtrlListView_GetItemCount($List) > 1 Then
  205.             GUICtrlSetState($Next, 64)
  206.             GUICtrlSetState($Back, 64)
  207.         EndIf
  208.         $GetSong = _GUICtrlListView_GetItem($List, $ItemCurrent, 1)
  209.  
  210.         If IsArray($GetSong) And $PlaySong = True Then
  211.             GUICtrlSetState($Play, 64)
  212.             GUICtrlSetData($Label_File, "File: " & FileGetName($GetSong[3]))
  213.  
  214.             $Sound = _BASS_StreamCreateFile(False, $GetSong[3], 0, 0, $BASS_STREAM_PRESCAN)
  215.             If @error Then Exit @error
  216.             _Bass_ChannelPlay($Sound, False)
  217.             If @error Then Exit @error
  218.  
  219.             $SizeCurrentSong = _BASS_ChannelGetLength($Sound,$BASS_POS_BYTE)
  220.             _GUICtrlSlider_SetRangeMax($Slider,$SizeCurrentSong)
  221.         EndIf
  222.         $Sound_Opened = True
  223.     ElseIf @error = 2 Then
  224.         MsgBox(16, "Errore", "Errore nell'aprire il/i file(s)")
  225.     EndIf
  226.     GUICtrlSetColor($Play, 0x0000FF)
  227. EndFunc   ;==>_Apri
  228.  
  229. Func _Play_Pause()
  230.     If _BASS_ChannelIsActive($Sound) = $BASS_ACTIVE_PAUSED Then
  231.         GUICtrlSetData($Play, ";")
  232.         _Bass_ChannelPlay($Sound, False)
  233.     ElseIf _BASS_ChannelIsActive($Sound) = $BASS_ACTIVE_PLAYING Then
  234.         GUICtrlSetData($Play, 4)
  235.         _Bass_ChannelPause($Sound)
  236.     EndIf
  237. EndFunc   ;==>_Play_Pause
  238.  
  239. Func _Back()
  240.     If $ItemCurrent > 0 Then $ItemCurrent -= 1
  241.     $_CanzonePrecedente = _GUICtrlListView_GetItem($List, $ItemCurrent, 1)
  242.     $Canz = $_CanzonePrecedente[3]
  243.     If FileExists($Canz) Then
  244.         _BASS_ChannelStop($Sound)
  245.         $Sound = _BASS_StreamCreateFile(False, $Canz, 0, 0, 0)
  246.     Else
  247.         $ItemCurrent = _GUICtrlListView_GetItemCount($List)
  248.         $_CanzonePrecedente = _GUICtrlListView_GetItem($List, $i, 1)
  249.         $Canz = $_CanzonePrecedente[3]
  250.         _BASS_ChannelStop($Sound)
  251.         $Sound = _BASS_StreamCreateFile(False, $Canz, 0, 0, 0)
  252.     EndIf
  253.  
  254.     GUICtrlSetData($Label_File, FileGetName($Canz))
  255. EndFunc   ;==>_Back
  256.  
  257. Func _Next()
  258.     $ItemCurrent += 1
  259.     $_CanzonePrecedente = _GUICtrlListView_GetItem($List, $ItemCurrent, 1)
  260.     $Canz = $_CanzonePrecedente[3]
  261.     If FileExists($Canz) Then
  262.         _BASS_ChannelStop($Sound)
  263.         $Sound = _BASS_StreamCreateFile(False, $Canz, 0, 0, 0)
  264.     Else
  265.         $ItemCurrent = 0
  266.         $_CanzonePrecedente = _GUICtrlListView_GetItem($List, $ItemCurrent, 1)
  267.         $Canz = $_CanzonePrecedente[3]
  268.         _BASS_ChannelStop($Sound)
  269.         $Sound = _BASS_StreamCreateFile(False, $Canz, 0, 0, 0)
  270.     EndIf
  271.  
  272.     GUICtrlSetData($Play, ";")
  273.     _Bass_ChannelPlay($Sound, False)
  274.     GUICtrlSetData($Label_File, FileGetName($Canz))
  275. EndFunc   ;==>_Next
  276.  
  277. Func FileGetName($FullPath)
  278.     $Split = StringSplit($FullPath, "\")
  279.     Return $Split[$Split[0]]
  280. EndFunc   ;==>FileGetName
  281.  
  282. Func End()
  283.     If _BASS_ChannelIsActive($Sound) = $BASS_ACTIVE_STOPPED And $Sound_Opened = True Then Return _Next()
  284. EndFunc   ;==>End
  285.  
  286. Func _MMP()
  287.     MsgBox(64, $Titolo, $Credits)
  288. EndFunc   ;==>_MMP
  289.  
  290. Func _ClearList()
  291.     GUICtrlDelete($List)
  292.     $List = GUICtrlCreateListView("Canzone|Percorso", 15, 200, 570, 150)
  293.     _GUICtrlListView_SetColumnWidth($List, 0, 280)
  294.     _GUICtrlListView_SetColumnWidth($List, 1, 290)
  295.     _BASS_Free()
  296.     GUICtrlSetData($Label_File, "File: Nessuno")
  297.     $ItemCurrent = 0
  298. EndFunc   ;==>_ClearList
  299.  
  300. Func FileGetExt($file)
  301.     Return StringRight($file,3)
  302. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement