• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

http_get_file fails - OGG on HTML5

J

jsterj

Guest
I am unable to do a simple file download of an OGG file when running in HTML5. It works perfectly when testing locally (i.e. not HTML5)

Below is the code. I moved it into an empty test project to rule out any other factors.


I have a single object in a room. In the create event I have the following:
GML:
musicFile = http_get_file("https://example.com/music/SomeMusicFile.ogg", "SomeMusicFile.ogg");

Then in the ASYNC - HTTP event I have:
GML:
if(ds_map_find_value(async_load, "id") == musicFile)
{
    var status = ds_map_find_value(async_load, "status");
    
    show_debug_message("status: " + string(status));
    show_debug_message("http status: " + string(ds_map_find_value(async_load, "http_status")));
    
    if(status == 0) {
        show_debug_message("yeah, status is 0");
    }
}

The console shows the following:
Code:
too many arguments provided for a function call test.js:183:409
status: -1
http status: 200
I don't know what the "too many arguments" message is referring to. The JavaScript is obfuscated, so not much help. It's referring to this line:
JavaScript:
if(_Fr._h2._C2)console.log(text);
versus when tested locally I get this output(i.e. all works fine):
Code:
status: 1
http status: undefined
status: 1
http status: undefined
status: 0
http status: 200
yeah, status is 0

I tested the same code but using a simple TXT file and it worked fine. I DO NOT want to include the music files in the game bundle. There are going to be many and load times would just be too long. If anyone knows a better method than what I'm doing, please let me know.

Any help would be greatly appreciated. I've searched all over for a solution, tried a thousand different approaches, and have come up empty.

Thanks,
Justin
 
J

jsterj

Guest
Some web server forbid you to download specific media type according to the web config
OK. Got ya. Even when I run this project locally though (exe on Windows) , I'm still pulling the OGG file from my webserver. And it is working fine. It will download, play, etc. It only breaks when I export it for HTML5.
 

Zhanghua

Member
OK. Got ya. Even when I run this project locally though (exe on Windows) , I'm still pulling the OGG file from my webserver. And it is working fine. It will download, play, etc. It only breaks when I export it for HTML5.
Can you download the file just from the browser by the url?
 
J

jsterj

Guest
Maybe the file is too big to fit into the Local Storage? In Chrome the limit is about 5 MB per domain.
That is a possibility. I think the file is around 7mb. I'm in the process of re-thinking my approach to this project.
 
J

jsterj

Guest
What I ended up doing was somewhat of a hybrid solution. I left the images out of the game bundle and only pull them from the server as needed. They're smaller than the audio files, and so this doesn't cause an issue. The music files are now included in the bundle. I did some testing and found that streamed audio does not appear to be preloaded when the game starts but is only pulled from the server when needed. The preloading of too many assets is what I was trying to avoid, so this solution ended up working out for me. Thanks for your help @Zhanghua and @Ricardo
 
Top