Karuzo Posted February 16, 2014 Share Posted February 16, 2014 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) Link to comment
Castillo Posted February 16, 2014 Share Posted February 16, 2014 Why it doesn't work? what does it show? Link to comment
Castillo Posted February 16, 2014 Share Posted February 16, 2014 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 ) Link to comment
Karuzo Posted February 16, 2014 Author Share Posted February 16, 2014 thanks, the text is being drawn now, but it says : Song: nil - nil How could i solve this ? Link to comment
cheez3d Posted February 16, 2014 Share Posted February 16, 2014 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. Link to comment
Karuzo Posted February 16, 2014 Author Share Posted February 16, 2014 Well those are Radio-Streams as you can see. :-/ Link to comment
Castillo Posted February 16, 2014 Share Posted February 16, 2014 They may not have any title at all. Link to comment
Karuzo Posted February 16, 2014 Author Share Posted February 16, 2014 Hmm, but i saw it on some servers, that they have this feature. Is there another way or smth like that ? Link to comment
Castillo Posted February 16, 2014 Share Posted February 16, 2014 What I mean is that the sounds you are playing may have no title. Link to comment
Karuzo Posted February 16, 2014 Author Share Posted February 16, 2014 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 . Link to comment
Moderators Citizen Posted February 16, 2014 Moderators Share Posted February 16, 2014 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 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now