John Smith Posted November 16, 2014 Share Posted November 16, 2014 i am trying to play a song which was selected in gridlist but failing in doing so rowMusic = { "Ke$ha - We R Who We R", "Eric Saade - Popular", "Loreen - Euphoria" } -- some hidden code in here which isnt needed here function onPlayButtonClick() if not guiGridListGetSelectedItem(GUIEditor.gridlist[1]) then outputChatBox("You need to select a song!",255,0,0) end if source == GUIEditor.button[1] then for i,mName in pairs(rowMusic) do local theMusic = guiGridListGetItemText ( GUIEditor.gridlist[1], guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ), 1 ) if mName == theMusic then if fileExists(theMusic) then sound = playSound(theMusic) guiSetText(GUIEditor.button[1],"Play") else downloadFile(theMusic) outputChatBox("Please stand by while song you requested is downloading.",255,0,0) end end end end end addEventHandler("onClientGUIClick",root,onPlayButtonClick) theMusic (which i selected) was Ke$ha - We R Who We R and when i used outputDebugString to get that string as wiki says filepath must be a string,but already is a string so why isn't it working? or do i need to do something like this? theMusic = """..theMusic..""" -- should(?) become "Ke$ha - We R Who We R" aka filepath Any help is appreaciated Link to comment
Dealman Posted November 17, 2014 Share Posted November 17, 2014 Try; local theMusic = guiGridListGetItemText ( GUIEditor.gridlist[1], guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ), 1 )..".mp3" As the wiki mentioned, the filepath must be a string. But you're checking if the file "Ke$ha - We R Who We R" exists - not "Ke$ha - We R Who We R.mp3". It has to be a filepath. It might be something else causing it, I may have overlooked it - didn't read through all of your code. Writing this from my phone Edit: I should have a link to a radio resource in my signature, which I made a while back, to stream URLs. You're free to download it and see if you find anything useful - it's open source as with all my releases. Link to comment
John Smith Posted November 28, 2014 Author Share Posted November 28, 2014 it has been a while since i posted a new post in here now i got this code without any errors but music isn't playing though. function onPlayButtonClick() if not guiGridListGetSelectedItem(GUIEditor.gridlist[1]) then outputChatBox("You need to select a song!",255,0,0) end if source == GUIEditor.button[1] then for i,mName in pairs(rowMusic) do local theMusic = guiGridListGetItemText ( GUIEditor.gridlist[1], guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ), 1 ) if mName == theMusic then if fileExists(theMusic..".mp3") then sound = playSound(theMusic..".mp3") guiSetText(GUIEditor.button[1],"Play") else downloadFile(theMusic..".mp3") outputDebugString(tostring(theMusic..".mp3")) outputChatBox("Please stand by while song you requested is downloading.",255,0,0) setElementData(localPlayer,"state","Downloading\n "..theMusic) exports.loading:startLoading() end end end end end addEventHandler("onClientGUIClick",root,onPlayButtonClick) anybody knows what's the cause? Link to comment
John Smith Posted November 30, 2014 Author Share Posted November 30, 2014 please help Link to comment
Moderators IIYAMA Posted December 1, 2014 Moderators Share Posted December 1, 2014 Check if the variable sound is created and if that part is executed. Link to comment
John Smith Posted December 14, 2014 Author Share Posted December 14, 2014 it starts downloading and onClientFileDownloadComplete or whatever says that download has failed, and it keeps restarting though the filepath is perfectly fine written please help Link to comment
ViRuZGamiing Posted December 14, 2014 Share Posted December 14, 2014 Couldn't the problem be that theMusic isn't to string so it gives now as path; theMusic".mp3" which actually has to be "theMusic.mp3". tostring(theMusic)..".mp3" Link to comment
John Smith Posted December 14, 2014 Author Share Posted December 14, 2014 -- theMusic returns this theMusic = Loreen - Euphoria -- an example -- how i use it theMusic..".mp3" -- becomes Loreen - Euphoria.mp3 and yet it doesn't download the file at all, i dont know why Link to comment
ViRuZGamiing Posted December 14, 2014 Share Posted December 14, 2014 theMusic needs to be tostring(theMusic) Link to comment
John Smith Posted December 14, 2014 Author Share Posted December 14, 2014 it is already a string Link to comment
Moderators IIYAMA Posted December 14, 2014 Moderators Share Posted December 14, 2014 it starts downloading and onClientFileDownloadComplete or whatever says that download has failed, and it keeps restarting Post the other part of the code, you said that the file is constantly in a re- download progress. A file which get overwrite every time can't be played, since it is never complete. Link to comment
John Smith Posted December 14, 2014 Author Share Posted December 14, 2014 function handleSongDownload(fname,state) if getElementType(source) == "resource" and getResourceName(getThisResource()) == "musicpanel" then if state then setElementData(localPlayer,"state","Music Download Finished. ") outputDebugString("download finished "..tostring(state)) setTimer(function() exports.loading:stopLoading() setElementData(localPlayer,"state","Playing") end,5000,1) else downloadFile(fname) outputDebugString("download failed of "..tostring(fname).." restarting...") setElementData(localPlayer,"state","Trouble in Music Download.\nRestarting...") end end end addEventHandler("onClientFileDownloadComplete",root,handleSongDownload) Link to comment
Moderators IIYAMA Posted December 14, 2014 Moderators Share Posted December 14, 2014 1. The download is never successful? 2. Show me the music-file (line) in the meta.xml which is meant to be played. 3. Show me the string you send to download the file. Link to comment
John Smith Posted December 14, 2014 Author Share Posted December 14, 2014 1.it just keeps returning that download has failed for forever 2. "Ke$ha - We R Who We R.mp3" download="false" /> "Eric Saade - Popular.mp3" download="false" /> "Loreen - Euphoria.mp3" download="false" /> 3. -- originally when i click a button else -- if music file doesn't exist then downloadFile(tostring(theMusic)..".mp3") -- becomes a correct string wwith .mp3 on the end which becomes string filepath -- if file download fails, it activates this downloadFile(fname) -- filepath is fname Link to comment
Gallardo9944 Posted December 15, 2014 Share Posted December 15, 2014 Try using latent events to transfer the file itself. Should work properly. Link to comment
Moderators IIYAMA Posted December 15, 2014 Moderators Share Posted December 15, 2014 Well, try first to download one successful. I will recommend you to remove those spaces between the file name and replace them with _ They always bring bad luck. @ Gallardo9944 That way they can become corrupted and they will be corrupted when the download gets interrupted by a disconnect. Link to comment
Gallardo9944 Posted December 15, 2014 Share Posted December 15, 2014 That way they can become corrupted and they will be corrupted when the download gets interrupted by a disconnect. Not really. If a file is not written yet, the song will simply be unsaved. If you disconnect while the file is being written, it will still finish the process. Link to comment
John Smith Posted December 15, 2014 Author Share Posted December 15, 2014 i have done some tests and confirmed that spaces are not the problem @iiyama @gallardo excuse me but i dont want to use those function(s) i haven't yet used them and its harder than downloadFile and i just want to do it like this way because there isnt any reason why to complicate all this when it's easy with downloadFile by "investigating" i have found no clue of this problem in my server it would always fail to download(even when i have turned off all custom resource), even though some other resources like my custom downloader can download things perfectly fine. So, my knowledge of mta and lua itself ends in here, and i am stuck without knowing what to do and how to fix the problem. In my local server it downloads perfectly fine even if file has name fioefj32f o2f23.r.-2.,32,.-23.,4"#"&%$#$%#$.txt and it has no custom resources Link to comment
John Smith Posted December 16, 2014 Author Share Posted December 16, 2014 please help me someone this is driving me crazy Link to comment
Moderators IIYAMA Posted December 16, 2014 Moderators Share Posted December 16, 2014 You should let somebody you trust, test it for you. It might be possible that it is an intern problem. Link to comment
John Smith Posted December 19, 2014 Author Share Posted December 19, 2014 i have found out that it was a host problem about downloading files because some test examples didn't work (like easiest example of downloadFile), but still musicpanel isn't downloading anything properly, leaving files at 0 byte of size. though my music panel still isn't downloading. The only possible error i could have caught is this. BASS ERROR 1 in LoadMedia path:C:\Program Files (x86)\MTA San Andreas 1.4\mods\deathmatch\resources\musicpanel\Eric Saade - Popular.mp3 3d:0 loop: Link to comment
Anubhav Posted December 19, 2014 Share Posted December 19, 2014 try removing the spaces. Link to comment
John Smith Posted December 20, 2014 Author Share Posted December 20, 2014 if using simple script with a single line downloadFile("asf$ #435 34%#$#W ER čl34 -5#$#JSD]˘^˘˛°˛.txt") worked fine and downloaded well then that just can't be the case unless the table is passing values incorrectly Link to comment
Saml1er Posted December 20, 2014 Share Posted December 20, 2014 Try using latent events to transfer the file itself. Should work properly. I'd suggest the same. Link to comment
John Smith Posted December 20, 2014 Author Share Posted December 20, 2014 can you give me an easiest example of downloading a "example.txt" file with those file functions and latent events? i haven't really used latent events before so i don't want to make a massive mistake D: 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