kann einer den Fehler finden? (skript ist ein bisschen unnordentlich)
Spoiler anzeigen
Local $progress_slider ,$slots, $Form1
#NoTrayIcon
#include <Bass.au3>
#include <BassConstants.au3>
#include <GUIConstantsEx.au3>
#Include <GuiListView.au3>
#include <ListViewConstants.au3>
#include <sound.au3>
#include <WindowsConstants.au3>
Global $gaDropFiles[1]
Global Const $WM_DROPFILES = 0x0233
Func WM_DROPFILES_FUNC($hWnd, $msgID, $wParam, $lParam) ; diese Funktion wird benötigt, damit man auch mehrere Dateien droppen kann
Local $nSize, $pFileName
Local $nAmt = DllCall('shell32.dll', 'int', 'DragQueryFileW', 'hwnd', $wParam, 'int', 0xFFFFFFFF, 'ptr', 0, 'int', 255)
For $i = 0 To $nAmt[0] - 1
$nSize = DllCall('shell32.dll', 'int', 'DragQueryFileW', 'hwnd', $wParam, 'int', $i, 'ptr', 0, 'int', 0)
$nSize = $nSize[0] + 1
$pFileName = DllStructCreate('wchar[' & $nSize & ']')
DllCall('shell32.dll', 'int', 'DragQueryFileW', 'hwnd', $wParam, 'int', $i, 'ptr', DllStructGetPtr($pFileName), 'int', $nSize)
ReDim $gaDropFiles[$i + 1]
$gaDropFiles[$i] = DllStructGetData($pFileName, 1)
$pFileName = 0
Next
EndFunc
Func Aktualisieren()
$Sliderstatus = GUICtrlRead($progress_slider)
GUICtrlSetData($slots, $Sliderstatus)
EndFunc
Func _BASS_ChannelSetVolume($hChannel, $nVol)
Local $ret = _BASS_ChannelSetAttribute($hChannel,$BASS_ATTRIB_VOL,$nVol)
Return SetError(@error,@extended,$ret)
EndFunc
Func _BASS_ChannelGetVolume($hChannel)
Local $ret = _BASS_ChannelGetAttribute($hChannel,$BASS_ATTRIB_VOL)
Return SetError(@error,@extended,$ret)
EndFunc
AdLibRegister("Aktualisieren", 100)
$firststart = IniRead("INRadio.ini","Start","firststart","")
;If $firststart = "" Then
; MsgBox(0,"Warnung!","Bitte über den Radiotuner Starten!")
; Exit
;ElseIf ProcessExists( "Radiotuner.exe" ) then
;Else
;MsgBox(0,"Warnung!","Bitte über den Radiotuner Starten!")
; Exit
;EndIf
Global $playing_state = -1
;Open Bass.DLL. Required for all function calls.
_BASS_STARTUP ("BASS.dll")
;Initalize bass. Required for most functions.
_BASS_Init (0, -1, 44100, 0, "")
;Check if bass iniated. If not, we cannot continue.
If @error Then
MsgBox(0, "Error", "Could not initialize audio")
Exit
EndIf
;Prompt the user to select a MP3 file
$file = FileOpenDialog("Open...", "", "MP3 Files (*.mp3)")
;Create a stream from that file.
$MusicHandle = _BASS_StreamCreateFile (False, $file, 0, 0, 0)
;Check if we opened the file correctly.
If @error Then
MsgBox(0, "Error", "Could not load audio file" & @CR & "Error = " & @error)
Exit
EndIf
;Create GUI and controls
$Form1 = GUICreate("INRadio-Localtuner", 380, 650, 193, 115)
$progress_slider = GUICtrlCreateProgress(8, 32, 366, 20)
$Volume_slider1 = GUICtrlCreateSlider(8,210,366,80)
$Volume_slider2 = GUICtrlCreateSlider(8,292,366,80)
GUICtrlSetLimit(-1,100,0)
GUICtrlSetData($Volume_Slider1,50)
GUICtrlSetData($Volume_Slider2,50)
GUICtrlCreateLabel("Lautstärke",8,190,80,20)
GUICtrlSetLimit(-1, 100, 0)
$hListView = GUICtrlCreateListView('Dateiname', 10, 375, 350, 200)
GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; Control als Drop-Control einrichten
GUIRegisterMsg($WM_DROPFILES, 'WM_DROPFILES_FUNC')
WinSetOnTop($Form1, '', 1)
$rightVol = GUICtrlCreateProgress(8, 88, 366, 17)
GUICtrlSetLimit(-1, 100, 0)
$LeftVol = GUICtrlCreateProgress(8, 136, 366, 17)
GUICtrlSetLimit(-1, 100, 0)
$slots = GUICtrlCreateLabel(GUICtrlRead($progress_slider)& "%",8, 8, 150, 17)
;GUICtrlCreateLabel("Fortschritt", 8, 8, 150, 17)
GUICtrlCreateLabel("Right Channel Volume Level", 8, 112, 150, 17)
GUICtrlCreateLabel("Left Channel Volume Level", 8, 64, 150, 17)
$Close = GUICtrlCreateButton("Close", 296, 160, 75, 25, 0)
$Play_pause = GUICtrlCreateButton("Play", 216, 160, 75, 25, 0)
$Stop = GUICtrlCreateButton("Stop", 136, 160, 75, 25, 0)
$newfile = GUICtrlCreateButton("Andere Datei", 36, 160, 75, 25, 0)
;Show GUI
GUISetState(@SW_SHOW)
;Get the length of the song in bytes.
$song_length = _BASS_ChannelGetLength ($MusicHandle, $BASS_POS_BYTE)
While 1
;Get Current playback position
$current = _BASS_ChannelGetPosition ($MusicHandle, $BASS_POS_BYTE)
;Calculate the percentage
$percent = Round(($current / $song_length) * 100, 0)
;Set the slider to show percent
GUICtrlSetData($progress_slider, $percent)
;Get Right/Left Playback Levels
$levels = _BASS_ChannelGetLevel ($MusicHandle)
;Get Right and calculate percentage
$rightChLvl = _LoWord ($levels)
$rightChLvlper = Round(($rightChLvl / 32768) * 100, 0)
;Get Left and calculate percentage
$LeftChLvl = _HiWord ($levels)
$leftChLvlper = Round(($LeftChLvl / 32768) * 100, 0)
;Set the levels on GUI.
GUICtrlSetData($rightVol, $rightChLvlper)
GUICtrlSetData($LeftVol, $leftChLvlper)
;Get GUI Message
$nMsg = GUIGetMsg()
Switch $nMsg
;If Close button or red x, then exit. Alway remember to free resources
Case $GUI_EVENT_CLOSE, $Close
ProcessClose("Radiotuner.exe")
AdLibUnRegister("Aktualisieren")
Exit
Case $Play_pause
;Check if playing or paused, then take appropriate action
Switch $playing_state
Case - 1 ; Song stopped, start from begining.
;Play Song
_BASS_ChannelPlay ($MusicHandle, 1)
$playing_state = 1
EndSwitch
Case $newfile
_BASS_ChannelStop ($MusicHandle)
$file = FileOpenDialog("Open...", "", "MP3 Files (*.mp3)")
$MusicHandle = _BASS_StreamCreateFile (False, $file, 0, 0, 0)
_BASS_ChannelStop ($MusicHandle)
Case $Volume_slider1
_BASS_ChannelSetVolume($MusicHandle, GUICtrlRead($Volume_slider1) / 100)
Case $volume_slider2
SoundSetWaveVolume(GUICtrlRead($Volume_Slider2))
Case $GUI_EVENT_DROPPED
For $i = 0 To UBound($gaDropFiles) - 1
GUICtrlCreateListViewItem(StringRegExpReplace($gaDropFiles[$i], '.*\\(.*)\..*', '$1'), $hListView)
_GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE)
Next
Case $Stop
;Stop Song
_BASS_ChannelStop ($MusicHandle)
$playing_state = -1
EndSwitch
WEnd
If $progress_slider =100 Then
$play_pause
EndIf
Func OnAutoItExit()
;Free Resources
_BASS_Free()
EndFunc ;=