Hallo, ich habe ein kleines Programm geschrieben, um dauerhaft Musik im Hintergrund laufen zu lassen...
Alle Informationen werden als ToolTip ausgegeben.
Man gibt in der config.ini im Scriptverzeichnis den Pfad zum ordner mit den mp3's an
Funktionen:
Zeigt bei nächstem Titel den Namen an (Auch abstellbar in der config.ini), ebenfalls aufrufbar über strg+alt+i aufrufbar
Zufallsfunktion (Ohne die möglichkeit, das ein Titel doppelt vorkommt!), standartgemäß von alleine an, in der options.ini umstellbar, und temporär über strg+alt+r verändernbar
Quit funktion (strg+alt+q)
Im Ordnerpfad für die mp3's können @ScriptDir und @UserProfileDir verwendet werden!!!
Es kann allerdings nur mp3's abspielen
Hier ist der code, wenn ihr was meiner anleitung nicht versteht, einfach nach-haken!
Spoiler anzeigen
#include <File.au3>
#include <Sound.au3>
#include <Array.au3>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;All Features wich you can enable/disable are shown here
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
HotKeySet ("!^n", "nextSong") ;Press ctrl+alt+n for next song
HotKeySet ("!^r", "rand") ;Press ctrl+alt+r to disable/enable random playing
HotKeySet ("!^q", "quit") ;Press ctrl+alt+q to quit
HotKeySet ("!^i", "info") ;Press ctrl+alt+i to get now playing filename
$showTitle = IniRead (@ScriptDir & "\config.ini", "ops", "showSongTitle", True)
;;;; This program can only play .mp3's! (I think it can play other formats too, but if there e.g is a textfile in the folder the program will crash, if i don't just enable mp3's...
$rndList = _ArrayCreate ("")
$rand = IniRead (@ScriptDir & "\config.ini", "ops", "DefaultRandomState", True)
$path = IniRead (@ScriptDir & "\config.ini", "ops", "path", @ScriptDir)
If StringInStr ($path, "@ScriptDir") Then
$splt = StringSplit ($path, "@ScriptDir")
If $splt[1] == "" Then
$splt[1] = @ScriptDir ;Replace @ScriptDir to the real scriptpath
ElseIf $splt[1] <> "" Then
$x = 0
Do
$x += 1
Until $splt[$x] == ""
$splt[$x] = @ScriptDir ;Replace @ScriptDir to the real scriptpath
EndIf
EndIf
If StringInStr ($path, "@UserProfileDir") Then
$splt = StringSplit ($path, "@UserProfileDir")
If $splt[1] == "" Then
$splt[1] = @UserProfileDir ;Replace @ScriptDir to the real scriptpath
ElseIf $splt[1] <> "" Then
$x = 0
Do
$x += 1
Until $splt[$x] == ""
$splt[$x] = @UserProfileDir ;Replace @ScriptDir to the real scriptpath
EndIf
EndIf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;To here
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
While 1
$lst = _FileListToArray ($path, "*.mp3")
If Not IsArray ($lst) Then
MsgBox (32, "Error: not files found!", "No supported files found in " & $path & "! Waiting for files.")
Do
Sleep (3000)
$lst = _FileListToArray ($path, "*.mp3")
Until IsArray ($lst)
EndIf
$i = 1
Do
If $rand = True And $lst[0] <> $rndList[0] Then
Do
$i = Random (1, $lst[0])
$splt = StringSplit ($i, ".")
$i = $splt[1]
Until _ArraySearch ($rndList, $i) == -1
_ArrayAdd ($rndList, $i)
$rndList[0] = UBound ($rndList)
ElseIf $lst[0] == $rndList[0] Then
$rndList = 0
$rndList = _ArrayCreate ("")
EndIf
$open = _SoundOpen ($path & "\" & $lst[$i])
_SoundPlay ($open)
ToolTip ("Now playing " & $lst[$i])
If $showTitle == True Then $init = TimerInit ()
$stop = False
Do
If $stop = True Then ExitLoop
If $showTitle == True Then
If TimerDiff ($init) >= 1500 Then ToolTip ("") ;Show 1,5 seconds the new title
EndIf
Until _SoundPos ($open) == _SoundLength ($open)
$i += 1
_SoundClose ($open)
Until $i = -1 = $lst[0]
WEnd
Func nextSong ()
_SoundStop ($open)
_SoundClose ($open)
$stop = True
EndFunc
FUNC RAND ()
If $rand = True Then
ToolTip ("Random off")
$rand = False
ElseIf $rand = False Then
ToolTip ("Random on")
$rand = True
EndIf
$init = TimerInit ()
Do
Sleep (100)
Until TimerDiff ($init) >= 200 ;Show 0,2 seconds the random state
ENDFUNC
FUNC QUIT ()
Exit
ENDFUNC
FUNC INFO ()
ToolTip ($lst[$i])
$init = TimerInit ()
Do
Sleep (100)
Until TimerDiff ($init) >= 1500 ; Show 1,5 seconds the title
ENDFUNC
;Made by Das Schwert
[/autoit]EDIT:
Ihr könnt es zum Beispiel in den Autostart schieben...