[Adventuron] Importing multimedia

With video and sounds (the latter being what I’m specifically interested in): can they be imported as assets, similarly to way graphics are, or do they have to be hosted somewhere else and linked to (as in the example code below)?

start_at = lakeside

locations {
lakeside : location “You are by the side of a lake.” {
on_describe {
// Plays incidental sound
: play_sound “incidental_door_creak”;

     // Plays ambient sound
     : play_ambient "ambient_wind_blowing";
  }

}
forest : location “You are in a forest.” {
on_describe {
// Stops playing ambient sound
: stop_ambient;
}
}
}

on_startup {
// Print graphic also plays videos too.
: print_graphic “intro” ;
: press_any_key ;
}

assets {
videos {
// Still image is also required at moment (will relax this)
intro : mp4 “https://some.url/intro.mp4” still=“still”;
ending : mp4 “https://some.url/ending.mp4” still=“still”;
}
graphics {
still : placeholder;
}
sounds {
incidental_door_creak : sound_sample “https://some.url/door_creak.mp3” ;
ambient_wind_blowing : sound_sample “https://some.url/wind_blowing.mp3” ;
}
}

You put them in the same folder as the HTML file and access them via relative URL paths.

if uploading to itch or zipping up a game, just put the multimedia files at the same level or in a subfolder to the game HTML file.

Example of a relative path

intro.mp4 (will look for file in same folder as HTML game file)

videos/ending.mp4 (will look for file in subfolder under the folder containing the HTML file).

Of course, you can always use http or Https links too, but yes, that requires hosting.

If uploading a game to itch, you can zip the folder containing the HTML file and all assets, naming the HTML file index.hrml, and up to a 1GB will be able to be uploaded and it is as if it is hosting the multimedia content for you.

Thanks - that makes sense. I will experiment with it.

Hmm, I can’t get that to work for some reason. I have a test mp3 called ‘test.mp3’ and I’ve put it under assets as:

incidental_door_creak : sound_sample “test.mp3” ;

…but it doesn’t play when called by

: play_sound “incidental_door_creak”;

The .mp3 is in the same folder as the compiled HTML file.

Related to this and apologies if this is a silly question, but: when I’m working in the editor, not with a compiled HTML file, where would I put the .mp3? In the folder I’m using to save my code or somewhere else? Or perhaps I have entirely the wrong end of the stick and by HTML game file you mean the local storage in the browser, not a compiled game file?

Hi Chris. There was a configuration issue with the library I was using, which meant that it was triggering security CORS warnings when executing a game from local storage (file://… as opposed to http:// or https:// …).

Anyway, I just made an update, so check out the beta beta and look for 59a or above, and it should work now.

I also fixed a bug where certain sound functions would hang the game if the sound preference was switched off (a callback not being called).

Anyway, give it a whirl. Tell me how you get on.

Right: that does work if I compile the game and put the compiled HTML file it in the same folder as the mp3 and reference the mp3 as:

incidental_door_creak : sound_sample “test.mp3” ;

But…where do I put the mp3 file and what path do I use to find it if I’m editing the game in the IDE? The above doesn’t work. Say I have the mp3 just on the desktop, how would I reference it in the above? The full path (C:\Users\chris\Desktop\test.mp3 - but the editor doesn’t like that) or something else? Possibly this is staggeringly obvious, but, well: I am flummoxed!

The online IDE won’t work with resources that feature a relative path, so you have two options:

  1. Use some basic webspace just for development, and upload your assets there, and reference by http until you deploy. There may be free limited webspace deals around, but I can’t comment on anything specific.

  2. The second method is to set your project folder to be your browser specific download folder, and in Adventuron - compile and then immediately click the html file that was saved when you absolutely need to test the linked assets - place your mp3 assets there too. A lot of the time you won’t care if the sound plays or not when you are testing game logic. This adds an additional step when you require to test the media hooks, but it’s probably less mess on than getting webspace if you don’t have any. Be sure to clear down the html files you are generating from time to time which should be easy as they will all have unique timestamped names Sorry for the bother. This is the bleeding edge, and this solution means I don’t have to pay for expensive hosting of user assets myself…

NOTE: If you have windows 10, don’t use the system “Downloads” folder as a root for your project files, as Windows has a “smart storage” “feature” that will delete files from this folder when it gets low on disk space. Eeeek!

This reminds me to get on with the offline version of the editor - which will not suffer from the same problem. But, that won’t be coming along super quickly.

Thanks, that’s fine and makes perfect sense. I’m reassured to know this is the case and I wasn’t simply being incredibly dense in not knowing where to put the files!

And you’re correct that the sounds are the least of the worries and easy to test: it’s just window dressing really and can be dealt with last.

My apologies for straying into the bleeding edge which does, frankly, sound rather painful.

Nothing wrong with your questions.

I know when something is seamless and when something is awkward. This is the latter.