Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How to add music to a story

I am trying to add a background music to my story with this inserted into the top of the start of the twine story.
<audio autoplay loop>
<source src="music/hearthstone.mp3" type="audio/aac>
</audio>
The music file is a subfolder for which the HTML doc is stored, the specifications are all correct, i have tried to get it to work with the torch browser and firefox. Am i missing something?

Comments

  • edited February 2017
    It's not an aac file, it's an mp3. So type="audio/mp3"

    Also, you missed a closing quote in the type statement.
  • That's not the correct type for MP3s either—it will work in most cases, but you can do better. The correct type for MP3s would look like the following:
    <audio autoplay loop>
    <source src="music/hearthstone.mp3" type='audio/mpeg; codecs="mp3"'>
    </audio>
    
  • Im afraid neither of those work. This is what my start file looks like
    <audio autoplay loop>
    <source src="music/hearthstone.mp3" type='audio/mpeg; codecs="mp3"'>
    </audio>
    You seem to be standing on the edge of an upside down cliff, looking directly infront of you is a lush mountain peak. It has much more foliage than a rocky tip has the right to.
    Below you is nothing, your feet are stuck in place in mid air, above the rocky shape of what should be down the mountain you see the edges slowly close to a point, so it appears as if the mountain is floating.
    You feel a tight grip against your right wrist and see a stone skeleton, frozen in the hard rock, loosly keeping you connected to the floating mountain.


    DriftAway
    RedPowerGain
    Safe1

    I do have the StoryInt passage with this:
    <<cacheaudio "mainsong" "music/hearthstone.mp3">>
  • If you're using sugarcube and you have it cached, just use the audio macros.
    <<audio "mainsong" loop play>>
    

    Also, make sure it's StoryInit, not StoryInt.
  • edited February 2017
    Chapel wrote: »
    If you're using sugarcube and you have it cached, just use the audio macros.
    <<audio "mainsong" loop play>>
    

    Also, make sure it's StoryInit, not StoryInt.

    It just comes up with Error: <<audio>>: no track by ID: mainsong
    The StoryInit is coded with
    <<cacheaudio "mainsong" "music/hearthstone">>
  • edited February 2017
    In the future, you should always state which story format you're using and its version. Even within the same story format different major versions can have significant differences and what works in one major version will not work in another.


    I cannot say if this is your only issue at this time, however, in that last example you're not specifying a file extension. The file extension is the only way SugarCube v1 has to determine the audio file type. SugarCube v2 has additional options for that, however, the file extension is still the default method to determine the audio file type.
  • Proxy4D wrote: »
    It just comes up with Error: <<audio>>: no track by ID: mainsong
    The StoryInit is coded with
    <<cacheaudio "mainsong" "music/hearthstone">>

    You really need to copy and paste directly from your code. Every time you post your code its different. Anyway, one more good college try:
    ::StoryInit
    <<cacheaudio "mainsong" "music/hearthstone.mp3">>
    
    ::Start
    <<audio "mainsong" loop play>>
    

    To humor me, double check one more time that the file path is right and free of any silly errors, like a folder named "musci" or something. Then copy and paste the above exactly as it's written into the StoryInit and Start passages, and let me know if you have any luck.
  • Chapel wrote: »
    Proxy4D wrote: »
    It just comes up with Error: <<audio>>: no track by ID: mainsong
    The StoryInit is coded with
    <<cacheaudio "mainsong" "music/hearthstone">>

    You really need to copy and paste directly from your code. Every time you post your code its different. Anyway, one more good college try:
    ::StoryInit
    <<cacheaudio "mainsong" "music/hearthstone.mp3">>
    
    ::Start
    <<audio "mainsong" loop play>>
    

    To humor me, double check one more time that the file path is right and free of any silly errors, like a folder named "musci" or something. Then copy and paste the above exactly as it's written into the StoryInit and Start passages, and let me know if you have any luck.

    Thank you for this, it finally works :smiley:
Sign In or Register to comment.