Skocz do zawartości

Kolejny odtwarzacz MP3


Rekomendowane odpowiedzi

Tak jak w temacie.

Zapraszam do komentowania :4_joy:

 

Skróty:
LSHIFT + k = Poprzedni utwór

LSHIFT + l = Następny utwór

LSHIFT + ; = Przyśpieszenie utworu o 2 s

LSHIFT + ' = Cofnięcie utworu o 2 s

 

Spoiler
#include <Sound.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <String.au3>
#include <Array.au3>
#include <GuiListBox.au3>
Global $test, $test11, $i = 0, $pa = 0, $lista[0]
Global $m = 0, $iii = 0

HotKeySet("+l", "nextt")
HotKeySet("+k", "prev")
HotKeySet("+;", "cofnij")
HotKeySet("+'", "dalej")

$Form1_1 = GUICreate("Odtwarzacz MP3", 483, 310, 192, 124)
GUISetBkColor(0xFFFFFF)
GUISetFont(8, 400, 0, "Copperplate Gothic Light") ; will display underlined characters
$start = GUICtrlCreateButton("Start", 8, 8, 49, 33)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$stop = GUICtrlCreateButton("Stop", 64, 8, 49, 33)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$pauza = GUICtrlCreateButton("Pauza", 120, 8, 49, 33)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Label1 = GUICtrlCreateLabel("00:00:00", 72, 48, 50, 17)
$Label2 = GUICtrlCreateLabel("/", 125, 48, 9, 17)
$Label3 = GUICtrlCreateLabel("00:00:00", 135, 48, 50, 17)
$Label4 = GUICtrlCreateLabel("", 90, 120, 450, 20)
$Slider1 = GUICtrlCreateSlider(8, 88, 286, 29)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$status = GUICtrlCreateLabel("", 120, 72, 150, 15)
$dalej = GUICtrlCreateButton(">", 40, 48, 25, 33)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$cofnij = GUICtrlCreateButton("<", 8, 48, 27, 33)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Label5 = GUICtrlCreateLabel("Glosnosc", 296, 8, 57, 17)
$Slider2 = GUICtrlCreateSlider(296, 24, 182, 45)
GUICtrlSetData(-1, 20)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Button1 = GUICtrlCreateButton("Nastepna", 176, 8, 59, 33)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Button2 = GUICtrlCreateButton("Cofnij", 240, 8, 51, 33)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Group1 = GUICtrlCreateGroup("Playlista", 8, 144, 465, 137)
$dodaj = GUICtrlCreateButton("Dodaj", 360, 192, 75, 17)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$zapisz = GUICtrlCreateButton("Zapisz", 360, 216, 75, 17)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$usun = GUICtrlCreateButton("Usun", 360, 240, 75, 17)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$otworz = GUICtrlCreateButton("Otwórz", 360, 168, 75, 17)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$List1 = GUICtrlCreateList("", 16, 160, 337, 110, BitOR($WS_BORDER, $WS_VSCROLL))
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label6 = GUICtrlCreateLabel("Aktualnie gra:", 8, 120, 80, 17)
$autor = GUICtrlCreateLabel("m4rcin93", 420, 288, 100, 17)
$Label7 = GUICtrlCreateLabel("Status:", 72, 72, 40, 17)
$random = GUICtrlCreateCheckbox("Losuj", 8, 288, 97, 17)
GUISetState(@SW_SHOW)

petla()

Func petla()
	While 1
		$nMsg = GUIGetMsg()
		Switch $nMsg
			Case $GUI_EVENT_CLOSE
				Exit
			Case $Button1
				nextt()
			Case $Button2
				prev()
			Case $autor
				ShellExecute("https://www.mpcforum.pl/profile/30908-m4rcin93/")
			Case $start
				start()
			Case $stop
				stop()
			Case $pauza
				pauza()
			Case $dalej
				dalej()
			Case $cofnij
				cofnij()
			Case $Slider2
				$glo = GUICtrlRead($Slider2)
				SoundSetWaveVolume($glo)
			Case $dodaj
				dodaj()
			Case $zapisz
				zapisz()
			Case $otworz
				otworz()

			Case $usun
				usun()
		EndSwitch

		If $test11 = 1 Then
			GUICtrlSetData($Label1, _SoundPos($test))
			GUICtrlSetData($Slider1, _Soundpos($test, 2) / 1000)
			if _SoundPos($test) = _SoundLength($test) Then
				If $m = UBound($lista) - 1 Then
					$m = -1
				EndIf
				$m = $m + 1
				$test11 = 0
				_SoundClose($test)
				_GUICtrlListBox_SetCurSel($List1, $m)
				coss()
				Return $m

			Endif
		endif
	WEnd
Endfunc   ;==>petla

Func dalej()
	_SoundSeek($test, "", "", Round(_Soundpos($test, 2) / 1000, 0) + 2)
	_Soundplay($test)
EndFunc   ;==>dalej

Func cofnij()
	_SoundSeek($test, "", "", Round(_Soundpos($test, 2) / 1000, 0) - 2)
	_Soundplay($test)
EndFunc   ;==>cofnij
Func status()
	If _SoundStatus($test) = "playing" Then
		GUICtrlSetData($status, "Gra")
	EndIf
	If _SoundStatus($test) = "stopped" Then
		GUICtrlSetData($status, "Zatrzymano")
	EndIf
	If _SoundStatus($test) = "paused" Then
		GUICtrlSetData($status, "Pauza")
	EndIf
EndFunc   ;==>status
Func usun()
	If _GUICtrlListBox_GetCount($List1) = 0 Then
		MsgBox(48, "Informacja", "Playlista jest pusta!")
	Else
		$zaz = _GUICtrlListBox_GetCurSel($List1)
		$zaz1 = _GUICtrlListBox_GetText($List1, $zaz)
		If not $zaz1 = 0 Then
			_arraydelete($lista, $zaz)
			_GUICtrlListBox_DeleteString($List1, $zaz)
		EndIf
	EndIf
EndFunc   ;==>usun
Func otworz()
	$playy = FIleOpenDialog("Wybierz plik z playlista", @ScriptDir, "TXT (*.txt)")
	If $playy = "" Then
		MsgBox(48, "Informacja", "Nie wybrano playlisty!")
	Else

		_GUICtrlListBox_ResetContent($List1)
		For $x = 0 to UBound($lista)
			_arraydelete($lista, _GUICtrlListBox_GetText($List1, $x))
		Next

		For $o = 1 To _FileCountLines($playy)
			Local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = ""
			$aPathSplit = _PathSplit(FileReadLine($playy, $o), $sDrive, $sDir, $sFilename, $sExtension)
			_GUICtrlListBox_InsertString($List1, $aPathSplit[3])
			_arrayadd($lista, FileReadLine($playy, $o))
		Next
		_GUICtrlListBox_SetCurSel($List1, 0)
		$m = 0
		Return $m
		_SoundClose($test)
	EndIf

EndFunc   ;==>otworz
Func dodaj()
	$plik = FileOpenDialog("Wybierz plik muzyczny..", @ScriptDir & "\", "MP3 (*.mp3*)", $FD_MULTISELECT)
	If $plik = "" Then
		MsgBox(48, "Informacja", "Nie wybrano pliku!")
	Else
		$plik1 = "|" & $plik & "|"
		$por = _StringBetween($plik1, '|', '|')
		For $xx = 0 To UBound($por) - 1
			If UBound($por) - 1 = 0 Then
				Local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = ""
				$aPathSplit1 = _PathSplit($por[0], $sDrive, $sDir, $sFilename, $sExtension)
				_ArrayAdd($lista, $por[0])
				_GUICtrlListBox_AddString($List1, $aPathSplit1[3] & @CRLF)
			Else
				If $xx > 0 Then
					$cos = _StringBetween($por[0] & $por[$xx], $por[0], $por[$xx])
					If StringRight($por[0], 1) = "\" Then
						_ArrayAdd($lista, $por[0] & $por[$xx])
						_GUICtrlListBox_AddString($List1, $por[$xx] & @CRLF)
					Else
						_ArrayAdd($lista, $por[0] & "\" & $por[$xx])
						_GUICtrlListBox_AddString($List1, $por[$xx] & @CRLF)
					EndIf
				EndIf
			EndIf
		Next
		_GUICtrlListBox_SetCurSel($List1, 0)
	EndIf
EndFunc   ;==>dodaj

Func zapisz()
	If _GUICtrlListBox_GetCount($List1) = 0 Then
		MsgBox(48, "Informacja", "Playlista jest pusta!")
	Else
		$p = InputBox("Zapisz playliste", "Podaj nazwe pliku")
		If $p = "" Then
			MsgBox(48, "Informacja", "Nie zapisano playlisty!")
		Else
			For $l = 0 To UBound($lista) - 1
				FileWrite(@ScriptDir & "\" & $p & ".txt", $lista[$l] & @CRLF)
			Next
			MsgBox(64, "Informacja", "Zapisano jako " & $p & ".txt")
		EndIf
	EndIf
EndFunc   ;==>zapisz
Func start()
	If _GUICtrlListBox_GetCount($List1) = 0 Then
		MsgBox(48, "Informacja", "Playlista jest pusta!")
	Else
		$i = $i + 1
		If $i = 2 Then
			$i = 0
			stop()
			start()
		Else
			If @error then _SoundResume($test)
			coss()
		EndIf
	EndIf
EndFunc   ;==>start

Func stop()
	If _GUICtrlListBox_GetCount($List1) = 0 Then
		MsgBox(48, "Informacja", "Playlista jest pusta!")
	Else
		_SoundStop($test)
		status()
		$test11 = 0
	EndIf
EndFunc   ;==>stop

Func pauza()
	If _GUICtrlListBox_GetCount($List1) = 0 Then
		MsgBox(48, "Informacja", "Playlista jest pusta!")
	Else
		If $pa = 1 Then
			_SoundResume($test)
			GUICtrlSetBkColor($pauza, 0xFFFFFF)
			status()
			GUICtrlSetData($pauza, "Pauza")
			$pa = 0
		Else

			_SoundPause($test)

			GUICtrlSetBkColor($pauza, 0xFFFF00)
			status()
			$pa = 1
			GUICtrlSetData($pauza, "Wznów")
		EndIf
	EndIf
EndFunc   ;==>pauza

Func coss()

	If GUICtrlRead($random) = $GUI_CHECKED Then
		$m = Round(Random(0, Ubound($lista) - 1), 0)
		_GUICtrlListBox_SetCurSel($List1, $m)
	Else
		$m = _GUICtrlListBox_GetCurSel($List1)
	EndIf

	$test = _SoundOpen($lista[$m])
	If @error then
		If $iii = 1 Then

			$iii = 0
			nextt()
		EndIf
		If $iii = -1 Then
			$iii = 0
			prev()
		EndIf
	Else
	EndIf

	$test1 = _SoundPlay($test)
	GUICtrlSetLimit($Slider1, (_soundlength($test, 2) / 1000), 0)
	GUICtrlSetData($Label3, _SoundLength($test))
	Local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = ""
	$aPathSplit2 = _PathSplit($lista[$m], $sDrive, $sDir, $sFilename, $sExtension)
	GUICtrlSetData($Label4, $aPathSplit2[3] & $aPathSplit2[4])
	status()
	If $test1 = 1 Then $test11 = 1
	petla()

EndFunc   ;==>coss

Func nextt()
	If _GUICtrlListBox_GetCount($List1) = 0 Then
		MsgBox(48, "Informacja", "Playlista jest pusta!")
	Else
		If $m = Ubound($lista) - 1 Then
			$m = 0
			_SoundClose($test)
			_GUICtrlListBox_SetCurSel($List1, $m)
			coss()
		EndIf
		_SoundClose($test)
		$iii = 1
		$m = $m + 1
		_GUICtrlListBox_SetCurSel($List1, $m)
		coss()
	EndIf
EndFunc   ;==>nextt

Func prev()
	If _GUICtrlListBox_GetCount($List1) = 0 Then
		MsgBox(48, "Informacja", "Playlista jest pusta!")
	Else
		If $m = 0 Then
			$m = UBound($lista)
		EndIf
		_SoundClose($test)
		$iii = -1
		$m = $m - 1
		_GUICtrlListBox_SetCurSel($List1, $m)

		coss()
	EndIf
EndFunc   ;==>prev

 

 

Edytowane przez m4rcin93
Odnośnik do komentarza
Udostępnij na innych stronach

 Udostępnij

  • Ostatnio przeglądający forum Kolejny odtwarzacz MP3   0 użytkowników
    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...