Jump to content

Music Player Help


Recommended Posts

I Have music player that playsmusic, stops, has volume controll, but i want to be able to see the status of the song, like the progress bar of the song. heres what i got, its not bad , but needs some work.

;Created By Bill
;***************
;

$Volume = _SoundGetWaveVolume()

#include <GuiConstants.au3>
#include "Sound.au3"

GuiCreate("Music Player", 400, 260,-1, -1);


$filemenu = GUICtrlCreateMenu("&File");
$new = GUICtrlCreateMenuItem("Upload Song", $filemenu);
$Fileexit = GUICtrlCreateMenuitem("Exit " & @TAB & "Alt+F4", $filemenu);
$Progress_1 = GUICtrlCreateProgress(20,150,360,10,$PBS_SMOOTH)
GUICtrlSetData ($Progress_1,1)
$Group_1 = GuiCtrlCreateGroup("Music", 10, 20, 380, 70);
$Group_2 = GuiCtrlCreateGroup("Controlls", 10, 100, 380, 120);
$Input_3 = GUICtrlCreateEdit("", 20, 50, 360, 16,$ES_READONLY, $WS_EX_STATICEDGE);
$Slider_1 = GuiCtrlCreateSlider(20, 180, 360, 30,$TBS_AUTOTICKS);
GUICtrlSetLimit($Slider_1, 100, 0);
GUICtrlSetData($Slider_1, $Volume);
$Button_5 = GuiCtrlCreateButton("Upload", 40, 120, 50, 21);
$Button_6 = GuiCtrlCreateButton("Play", 100, 120, 50, 20);
$Button_7 = GuiCtrlCreateButton("Stop", 160, 120, 50, 20);
$Button_8 = GuiCtrlCreateButton("Exit", 220, 120, 50, 20);
SoundSetWaveVolume($Volume);
GuiSetState();
While 1
    $ix = GuiGetMsg();
    if $ix = $GUI_EVENT_CLOSE Then
        ExitLoop
    EndIf
    if $ix = $Fileexit Then
        ExitLoop
    EndIf
    if $ix = $Button_8 Then
        ExitLoop
    EndIf
    if $ix = $new Then
        $sound=FileOpenDialog("Open Music File","E:\","All Files(*.*)",3)
        GUICtrlSetData($Input_3, $sound);
    EndIf
    if $ix = $Button_5 Then
        $sound=FileOpenDialog("Open Music File","C:\Documents and Settings\Owner\My Documents\My Music\","All Files(*.*)",3)
        GUICtrlSetData($Input_3, $sound);
        GUICtrlSetData($Button_5,"Change")
        GUICtrlSetState($Button_6,$GUI_FOCUS)
    EndIf
    if $ix = $Button_6 Then
        SoundPlay($sound)
    EndIf
    If $ix = $Button_7 Then
        SoundPlay("C:\NoFile1238467124910246.mp3")
    EndIf
    if $ix = $Slider_1 Then
            SoundSetWaveVolume(GUICtrlRead($Slider_1));
            ToolTip(GUICtrlRead($Slider_1));
            Sleep(200);
            ToolTip("");
            EndIf
    
WEnd


Func _SoundGetWaveVolume();
    Local $WaveVol = -1, $p, $ret
    Const $MMSYSERR_NOERROR = 0
    $p = DllStructCreate("dword");
    If @error Then
        SetError(2);
        Return -2
    EndIf
    $ret = DllCall("winmm.dll", "long", "waveOutGetVolume", "long", -1, "long", DllStructGetPtr($p));
    If ($ret[0] == $MMSYSERR_NOERROR) Then
        $WaveVol = Round(Dec(StringRight(Hex(DllStructGetData($p, 1), 8), 4)) / 0xFFFF * 100);
    Else
        SetError(1);
    EndIf
    $Struct = 0
    Return $WaveVol
EndFunc 
Exit

[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

Link to comment
Share on other sites

I don't have a full answer to the progress of playback.

You could maybe get properties for duration on the file your playing back and set the progress bar to the scale of playback time.

You could use this udf to get the duration of playback: Get Extended File Property

Myself I think I'd actually use the WMMedia.au3 to make a music player. Since this also has the functions to control volume on any played file (the way your setting volume atm only adjusts wav volume, so if I play a mid file then the volume doesn't work).

Also it can report the duration of a song as well as report where the song is upto in playback..

Ther's many more useful functions as well in this udf.

This udf would definately be easier to work with to make your music player show stats and be the da - shizna :)

One more thing..

If you'd like your volume control to actually adjust the volume while sliding back and forth instead of it adjusting the volume when you let the slider go...

Add in front of GuiCreate("Music Player", 400, 260,-1, -1) in your script

$Main =oÝ÷ Øû­¶¬)Þiº/^{X§Ê«±Êâ¦Ö®¶­sbb33cµföÄöÆBÒwV7G&Å&VBb33cµ6ÆFW%óoÝ÷ Ù©§¶¬jëh×6    if $ix = $Slider_1 Then
            SoundSetWaveVolume(GUICtrlRead($Slider_1));
            ToolTip(GUICtrlRead($Slider_1));
            Sleep(200);
            ToolTip("");
            EndIfoÝ÷ Ùh­Øb±«­¢+Ø%Õ¥
ÑɱI ÀÌØíM±¥É|Ĥ±ÐìÐìÀÌØíY½±=±Q¡¸($%M½Õ¹MÑ]ÙY½±Õµ¡U%
ÑɱI ÀÌØíM±¥É|Ĥ¤(ÀÌØíY½±=±ôÕ¥
ÑɱI ÀÌØíM±¥É|Ĥ($%Q½½±Q¥À¡U%
ÑɱI ÀÌØíM±¥É|Ĥ¤ì(%¹%($ÀÌØí¤ôU%Ñ
ÕÉͽÉ%¹¼ ÀÌØí5¥¸¤(%%ÀÌØí¥lÉtôÀQ¡¸($%Q½½±Q¥À ÅÕ½ÐìÅÕ½Ðì¤(¹%

This will make it so volume will adjust while your sliding the slider.

The tooltip will show while the slider is being slid by the mouse.

Good luck

Cheers

Edited by smashly
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...