Jump to content

Song Name problem


Karuzo

Recommended Posts

Posted

Hey Guys,

so i wanted to show the song-name which is currently playing,

but that doesn't really work.

addEventHandler("onClientGUIClick", root, 
        function () 
            if ( source == deutschbtn ) then 
                if isElement(sound3) then destroyElement(sound3) end 
                if isElement(sound2) then destroyElement(sound2) end 
                if isElement(sound4) then destroyElement(sound4) end 
                if isElement(sound1) then destroyElement(sound1) end 
                if isElement(sound5) then destroyElement(sound5) end 
                sound1 = playSound( "http://stream.laut.fm:80/deutschrap", false ) 
                meta1 = getSoundMetaTags(sound1) 
            elseif ( source == breakzbtn ) then 
                if isElement(sound3) then destroyElement(sound3) end 
                if isElement(sound1) then destroyElement(sound1) end 
                if isElement(sound4) then destroyElement(sound4) end 
                if isElement(sound2) then destroyElement(sound2) end 
                if isElement(sound5) then destroyElement(sound5) end 
                sound2 = playSound( "http://stream.breakz.us", false ) 
                meta2 = getSoundMetaTags(sound2) 
            elseif ( source == rapzbtn ) then 
                if isElement(sound1) then destroyElement(sound1) end 
                if isElement(sound2) then destroyElement(sound2) end 
                if isElement(sound4) then destroyElement(sound4) end 
                if isElement(sound3) then destroyElement(sound3) end 
                if isElement(sound5) then destroyElement(sound5) end 
                sound3 = playSound( "http://laut.fm/rapztv", false ) 
                meta3 = getSoundMetaTags(sound3) 
            elseif ( source == blackbtn ) then 
                if isElement(sound1) then destroyElement(sound1) end 
                if isElement(sound2) then destroyElement(sound2) end 
                if isElement(sound3) then destroyElement(sound3) end 
                if isElement(sound4) then destroyElement(sound4) end 
                if isElement(sound5) then destroyElement(sound5) end 
                sound4 = playSound( "http://stream.blackbeatslive.de/", false ) 
                meta4 = getSoundMetaTags(sound4) 
            elseif ( source == Radyobutton5 ) then 
            if isElement(sound1) then destroyElement(sound1) end 
                if isElement(sound2) then destroyElement(sound2) end 
                if isElement(sound3) then destroyElement(sound3) end 
                if isElement(sound4) then destroyElement(sound4) end 
                if isElement(sound5) then destroyElement(sound5) end 
                sound5 = playSound( "http://46.20.4.51:8040/", false ) 
            elseif ( source == radkapat ) then 
                if isElement(sound1) then destroyElement(sound1) end 
                if isElement(sound2) then destroyElement(sound2) end 
                if isElement(sound3) then destroyElement(sound3) end 
                if isElement(sound4) then destroyElement(sound4) end 
                if isElement(sound5) then destroyElement(sound5) end 
            end 
        end 
    ) 
     
addEventHandler("onClientSoundFinishedDownload", root, 
    function() 
        meta4 = getSoundMetaTags(sound4) 
        meta3 = getSoundMetaTags(sound3) 
        meta2 = getSoundMetaTags(sound2) 
        meta1 = getSoundMetaTags(sound1) 
end) 
addEventHandler("onClientRender", gRoot, 
    function() 
        if isElement(sound1) then 
        dxDrawText("Song: "..meta1.artist.." - " ..meta1.title,X,Y+600, Width, Height,  tocolor(255,255,0), 1, "default-bold","left", "top",false, false,true,true) 
        elseif isElement(sound2) then 
        dxDrawText("Song: "..meta2.artist.." - " ..meta2.title,X,Y+600, Width, Height,  tocolor(255,255,0), 1, "default-bold","left", "top",false, false,true,true) 
        elseif isElement(sound3) then  
        dxDrawText("Song: "..meta3.artist.." - " ..meta3.title,X,Y+600, Width, Height,  tocolor(255,255,0), 1, "default-bold","left", "top",false, false,true,true) 
        elseif isElement(sound4) then 
        dxDrawText("Song: "..meta4.artist.." - " ..meta4.title,X,Y+600, Width, Height,  tocolor(255,255,0), 1, "default-bold","left", "top",false, false,true,true) 
        end 
        end) 

Posted
addEventHandler ( "onClientRender", gRoot, 
    function ( ) 
        if isElement ( sound1 ) then 
            dxDrawText("Song: ".. tostring ( meta1.artist ) .." - ".. tostring ( meta1.title ),X,Y+600, Width, Height,  tocolor(255,255,0), 1, "default-bold","left", "top",false, false,true,true) 
        elseif isElement ( sound2 ) then 
            dxDrawText("Song: ".. tostring ( meta2.artist ) .." - ".. tostring ( meta2.title ),X,Y+600, Width, Height,  tocolor(255,255,0), 1, "default-bold","left", "top",false, false,true,true) 
        elseif isElement ( sound3 ) then 
            dxDrawText("Song: ".. tostring ( meta3.artist ) .." - ".. tostring ( meta3.title ),X,Y+600, Width, Height,  tocolor(255,255,0), 1, "default-bold","left", "top",false, false,true,true) 
        elseif isElement ( sound4 ) then 
            dxDrawText("Song: ".. tostring ( meta4.artist ) .." - ".. tostring ( meta4.title ),X,Y+600, Width, Height,  tocolor(255,255,0), 1, "default-bold","left", "top",false, false,true,true) 
        end 
    end 
) 

Posted

Did you properly set the info of the song?

Right click the song and go to Properties then go to the Details tab and add Title and Author if not set.

Posted

Oh, well , i can't say that really if they have or not, but a friend of mine said that this won't work cause i would need an API of a radio-hoster to get the titles..

So, i think theres no other way .

  • Moderators
Posted

You should test your webstreams with VLC to check if it can get the song name from the stream.

You used:

onClientSoundFinishedDownload 

which is only working with real files, not for streams because they never stop downloading. Use this event instead:

onClientSoundStream 

The idea I got is that you need to wait that event before getting the metadatas of the stream.

So basically, you can remove the following lines from your onClientGUIClick:

- line 10

- line 18

- line 26

- line 34

- line 41

and use the onClientSoundStream event. You will likely use a setTimer too to update the new meta tags when a new song is playing.

It's just an idea, it maybe doesn't work as I guessed it would. The only way to know it is to test it.

Regards,

Citizen

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
  • Recently Browsing   0 members

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