Jump to content

Youknowwho's media player build


youknowwho4eva
 Share

Recommended Posts

Of course I have to thank the makers of Bass, and Irrlichtpluginutils. This is just the beginning. I plan on making it much better. As you can tell with all the quoted out and in stuff it's very much a work in progress. But I think my visualization is pretty nifty. Right now you select a song, then play pause or stop. That's it. I'm just laying the ground work and couldn't wait to share the visualizer I came up with. So not judging the functionality of it yet, what do you think of where I'm heading with the visualization? For a pretty cool effect turn on the lines that it says to turn on.

Edit: forgot to link pages I used:

http://www.autoitscript.com/forum/index.php?showtopic=83481

http://www.autoitscript.com/forum/index.php?showtopic=84055

http://www.box.net/shared/47jcql2vqk

#include <GUIConstants.au3>
#include <Constants.au3>
#include <WindowsConstants.au3>
#include <WINAPI.au3>
#include <IrrlichtPluginUtils.au3>
#include <Bass.au3>
#include <BassConstants.au3>
#include <GUIConstantsEx.au3>
#include <math.au3>

Global $playing_state = -1

HotKeySet("{ESC}", "Terminate")

$bass_dll = DllOpen("BASS.dll")

;Initalize bass.  Required for most functions.
_BASS_Init ($bass_dll, 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
$fileb = FileOpenDialog("Open...", "", "MP3 Files (*.mp3)")

;Create a stream from that file.
$MusicHandle = _BASS_StreamCreateFile ($bass_dll, False, $fileb, 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


#Region - GUI Create
$gui = GUICreate("trans", @DesktopWidth, @DesktopHeight, -1, -1, 0x9C800000, $WS_EX_LAYERED)
GUISetBkColor(0xABCDEF)
GUISetStyle( $WS_POPUP, -1, $gui )
_WinAPI_SetLayeredWindowAttributes($gui, 0xABCDEF, 255)
CreateDeviceOnWindow( $gui, $EDT_BURNINGSVIDEO, 0, 0, @DesktopWidth, @DesktopHeight - 100, 64, 0, 0 )
$play = GUICtrlCreateButton("Play", (@DesktopWidth / 2) - 100, @DesktopHeight - 80, 50, 20, -1, $GUI_WS_EX_PARENTDRAG)

$stop = GUICtrlCreateButton("Stop", (@DesktopWidth / 2) + 50, @DesktopHeight - 80, 50, 20, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetTip(-1, "Click label to drag layered window")

GUISetState()

$Camera = AddCameraSceneNode( 0, 0, 0, -40, 0, 0, 0 )
$Node = AddCubeSceneNode( 10 )
$nodeTexture = Getmaterial( $node,0 )
Setambientcolor( $nodetexture, 0, 40,180,50 )
setemissivecolor($nodetexture,0,40,180,50)
$Node2 = AddCubeSceneNode( 10 )
$node2Texture = Getmaterial( $node2,0 )
Setambientcolor( $node2texture, 0, 0,60,155 )
setemissivecolor($node2texture,0,0,60,155)
;~ setspecularcolor($node2texture,5,0,255,255)
$Node3 = AddCubeSceneNode( 10 )
$node3Texture = Getmaterial( $node3,0 )
Setambientcolor( $node3texture, 0, 180,40,50 )
setemissivecolor($node3texture,0,180,40,50)
$Node4 = AddCubeSceneNode( 10 )
$node4Texture = Getmaterial( $node4,0 )
Setambientcolor( $node4texture, 0, 55,55,55 )
setemissivecolor($node4texture,0,55,55,55)
;~ setspecularcolor($node4texture,5,0,255,255)
;~ setmaterialflag($node,$emf_wireframe, 1)     ; turn on this line
;~ setmaterialflag($node2,$emf_wireframe, 1)
;~ setmaterialflag($node3,$emf_wireframe, 1)
;~ setmaterialflag($node4,$emf_wireframe, 1)    ; to this line
$Y = 0
$x = 0
$z = 0
$Ys = 2
$xs = 2
$zs = 2
$start = 0
$posz = 50
$pos2z = 0
;~ $directionz = 3
;~ $Directiony = 3
;~ $directionx = 3
;~ $directionzs = 1/64
;~ $Directionys = 1/64
;~ $directionxs = 1/64

_BASS_ChannelPlay ($bass_dll, $MusicHandle, 1)
$song_length = _BASS_ChannelGetLength ($bass_dll, $MusicHandle, $BASS_POS_BYTE)
$percent = 0
Call("main")
Func main()
    GUICtrlSetData($play,"Pause")
While $percent <> 100 and $playing_state = -1
    $nMsg = GUIGetMsg()
    Switch $nMsg
;If Close button or red x, then exit.  Alway remember to free resources
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Play
;Check if playing or paused, then take appropriate action
            Switch $playing_state
                Case 0; Song Paused, Resume.
    ;Resume Song
                    _BASS_Pause ($bass_dll)
                    $playing_state = - 1
                Case  1; Song stopped, start from begining.
    ;Play Song
                    _BASS_ChannelPlay ($bass_dll, $MusicHandle, 1)
                    $playing_state = 1
                Case - 1; Song Playing, Pause
    ;Pause song
                    _BASS_Pause ($bass_dll)
                    $playing_state = 0
            EndSwitch
        Case $Stop
;Stop Song
            _BASS_ChannelStop ($bass_dll, $MusicHandle)
            $playing_state = 1
    EndSwitch
    $current = _BASS_ChannelGetPosition ($bass_dll, $MusicHandle, $BASS_POS_BYTE)
;Calculate the percentage
    $percent = Round(($current / $song_length) * 100, 0)
    $start += 1
    If $start = 100 Then $start = 1
    Sleep(10)
;Get Right/Left Playback Levels
    $levels = _BASS_ChannelGetLevel ($bass_dll, $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.
    
    $rightVol = $rightChLvlper
    $LeftVol = $leftChLvlper
If _MathCheckDiv($start,20) = 2 Or $start = 1 Then
    $posz += 10
    $pos2z += 10
    If $posz = 100 Then $posz = 0
        
    If $pos2z = 100 Then $pos2z = 0
$posx = Random(-50,50,1)
$posy = Random(-50,50,1)
setposition($node,$posx,$posy,$posz)
setposition($node2,$posx,$posy,$posz)   
$pos2x = Random(-50,50,1)
$pos2y = Random(-50,50,1)
setposition($node3,$pos2x,$pos2y,$pos2z)
setposition($node4,$pos2x,$pos2y,$pos2z)
EndIf


setscale($node,($rightvol + $leftvol) / 100 + 1,($rightvol + $leftvol) / 100 + 1,($rightvol + $leftvol) / 100 + 1)
SetRotation( $Node,$rightvol * 360 / 100,0,0)
setscale($node2,($rightvol + $leftvol) / 100 + 1,($rightvol + $leftvol) / 100 + 1,($rightvol + $leftvol) / 100 + 1)
SetRotation( $Node2,0,45,$leftvol * 360 / 100)
setscale($node3,($rightvol + $leftvol) / 100 + 1,($rightvol + $leftvol) / 100 + 1,($rightvol + $leftvol) / 100 + 1)
SetRotation( $Node3,$rightvol * 360 / 100,0,0)
setscale($node4,($rightvol + $leftvol) / 100 + 1,($rightvol + $leftvol) / 100 + 1,($rightvol + $leftvol) / 100 + 1)
SetRotation( $Node4,0,45,$leftvol * 360 / 100)
BeginScene( true, true, 0, 171, 205, 239 )

SceneDraw( )
GuiDraw( )

EndScene( )

sleep( 20 )
;~ $ys += $directionys
;~ $xs += $directionxs
;~ $zs += $directionzs
;~ If $ys = 3 Then
;~   $directionys = 0
;~   $directionxs = 0
;~   $directionzs = 0
;~ ElseIf $ys = 0 Then
;~   Exit
;~ EndIf

;~ $Y += $Directiony
;~ If $Y > 360 Then $Y -= 363
;~ If $Y < 0 Then $Y += 360

;~ $x += $Directionx
;~ If $x > 360 Then $x -= 363
;~ If $x < 0 Then $x += 360

;~ $z += $Directionz
;~ If $z > 360 Then $z -= 363
;~ If $z < 0 Then $z += 360
;~ If $x = 3 and $y = 3 and $z = 3 Then
;~   If $start < 3 Then
;~       $start += 1
;~   ElseIf $start = 3 Then
;~   $directiony = -10
;~   $directionx = -10
;~   $directionz = -10
;~   $directionys = -1/16
;~   $directionxs = -1/16
;~   $directionzs = -1/16
;~   EndIf
;~ EndIf


WEnd
EndFunc
$pz = 0

While $percent = 100 or $playing_state <> -1
    If GUICtrlRead($play) <> "Play" then GUICtrlSetData($play,"Play")
    $nMsg = GUIGetMsg()
    Switch $nMsg
;If Close button or red x, then exit.  Alway remember to free resources
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Play
;Check if playing or paused, then take appropriate action
            Switch $playing_state
                Case 0; Song Paused, Resume.
    ;Resume Song
                    _BASS_start ($bass_dll)
                    $playing_state = - 1
                    Call("main")
                Case  1; Song stopped, start from begining.
    ;Play Song
                    _BASS_ChannelPlay ($bass_dll, $MusicHandle, 1)
                    $playing_state = -1
                    $current = _BASS_ChannelGetPosition ($bass_dll, $MusicHandle, $BASS_POS_BYTE)
;Calculate the percentage
    $percent = Round(($current / $song_length) * 100, 0)
    $start += 1
    If $start = 100 Then $start = 1
    Sleep(10)
;Get Right/Left Playback Levels
    $levels = _BASS_ChannelGetLevel ($bass_dll, $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.
    
    $rightVol = $rightChLvlper
    $LeftVol = $leftChLvlper
                    Call("main")
                Case - 1; Song Playing, Pause
    ;Pause song
                    _BASS_Pause ($bass_dll)
                    $playing_state = 0
                    Call("main")
            EndSwitch
        Case $Stop
;Stop Song
            _BASS_ChannelStop ($bass_dll, $MusicHandle)
            $playing_state = 1
    EndSwitch
    $pz += 5
    Sleep(100)
    setposition($node,-25,0,50)
    setscale($node,1,1,1)
    SetRotation( $Node,0,0,$pz)
    setposition($node2,-25,0,50)
    setscale($node2,1,1,1)
    SetRotation( $Node2,0,45,$pz)
    setposition($node3,25,0,50)
    setscale($node3,1,1,1)
    SetRotation( $Node3,0,0,$pz)
    setposition($node4,25,0,50)
    setscale($node4,1,1,1)
    SetRotation( $Node4,0,45,$pz)
BeginScene( true, true, 0, 171, 205, 239 )

SceneDraw( )
GuiDraw( )

EndScene( )
    
    
    
WEnd


Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False)
    If $dwFlages = Default Or $dwFlages = "" Or $dwFlages < 0 Then $dwFlages = 0x03

    If Not $isColorRef Then
        $i_transcolor = Hex(String($i_transcolor), 6)
        $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
    EndIf
    Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $dwFlages)
    Select
        Case @error
            Return SetError(@error, 0, 0)
        Case $Ret[0] = 0
            Return SetError(4, _WinAPI_GetLastError(), 0)
        Case Else
            Return 1
    EndSelect
EndFunc;==>_WinAPI_SetLayeredWindowAttributes

Func Terminate()
;Free Resources
    _BASS_Free($bass_dll)
    Exit 0
EndFunc
Edited by youknowwho4eva

Giggity

Link to comment
Share on other sites

i got this error..

C:\Documents and Settings\zainiafzan\My Documents\Downloads\Compressed\MultiChannelViewerExample\mp3 built.au3 (55) : ==> Unknown function name.:
CreateDeviceOnWindow( $gui, $EDT_BURNINGSVIDEO, 0, 0, @DesktopWidth, @DesktopHeight - 100, 64, 0, 0 )
^ ERROR
>Exit code: 1   Time: 5.873
Link to comment
Share on other sites

i got this error..

C:\Documents and Settings\zainiafzan\My Documents\Downloads\Compressed\MultiChannelViewerExample\mp3 built.au3 (55) : ==> Unknown function name.:
CreateDeviceOnWindow( $gui, $EDT_BURNINGSVIDEO, 0, 0, @DesktopWidth, @DesktopHeight - 100, 64, 0, 0 )
^ ERROR
>Exit code: 1   Time: 5.873
Make sure you have:

Au3Irrlicht.dll

IrrlichtPluginUtils.au3

Irrlicht.dll

- see it here http://www.autoitscript.com/forum/index.php?showtopic=70506

Só o que posso lhe dizer, bom é quando faz mal!My work:Au3Irrlicht - Irrlicht for AutoItMsAgentLib - An UDF for MSAgentAu3GlPlugin T2 - A 3D plugin for AutoIt...OpenGl Plugin - The old version of Au3GlPlugin.MAC Address Changer - Changes the MAC AddressItCopter - A dragonfly R/C helicopter simulator

VW Bug user

Pinheiral (Pinewood) city:

http://pt.wikipedia.org/wiki/Pinheiral

Link to comment
Share on other sites

And before I forget it, my opinion about the media player: Cool! :(

Nice idea :mellow:

Só o que posso lhe dizer, bom é quando faz mal!My work:Au3Irrlicht - Irrlicht for AutoItMsAgentLib - An UDF for MSAgentAu3GlPlugin T2 - A 3D plugin for AutoIt...OpenGl Plugin - The old version of Au3GlPlugin.MAC Address Changer - Changes the MAC AddressItCopter - A dragonfly R/C helicopter simulator

VW Bug user

Pinheiral (Pinewood) city:

http://pt.wikipedia.org/wiki/Pinheiral

Link to comment
Share on other sites

  • 7 months later...

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...