Author Topic: Quick Question about sol.audio.play_music  (Read 397 times)

etertaycb

  • Newbie
  • *
  • Posts: 3
    • View Profile
Quick Question about sol.audio.play_music
« on: May 31, 2018, 09:33:23 am »
Hello,  I've been playing around with solarus trying to get a feel for the engine and ive run into this error I know its probably a simple answer but for the life of me I cant seem to figure it out... here is the code..

Quote
elseif key == "p" then
sol.audio.play_sound("bush")
elseif key == "l" then
sol.audio.play_music("boss")
elseif key == "[" and sol.audio.get_music() ~= nil  then
 last_playedmus = sol.audio.get_music()
sol.audio.stop_music()
elseif key == "[" and sol.audio.get_music() == nil  then
sol.audio.play_music(last_playedmus)


  end

when i launch the game and press "L" the boss music ought to play but instead the console says   "No such music: 'boss' "  the music that is set to play in the map editor works fine, but for some reason I cant get any music to play via the script.  the rest of the function works fine and playing a sound effect with a key also works fine

could I get some quick help with this? thank you!

Diarandor

  • Hero Member
  • *****
  • Posts: 1020
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Quick Question about sol.audio.play_music
« Reply #1 on: May 31, 2018, 01:48:36 pm »
The error is clear: there is no file "musics/boss.ogg".
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

etertaycb

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Quick Question about sol.audio.play_music
« Reply #2 on: May 31, 2018, 02:23:48 pm »
The error is clear: there is no file "musics/boss.ogg".

there IS a file there though. its one of the default music files and ive also tried a few others and adding my own. same result.  Even when I call the same song that is playing i get the same result
« Last Edit: May 31, 2018, 02:25:41 pm by etertaycb »

Diarandor

  • Hero Member
  • *****
  • Posts: 1020
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Quick Question about sol.audio.play_music
« Reply #3 on: May 31, 2018, 03:14:56 pm »
-I was wrong on something: the extension should not be written in the filename (according to the Lua API).

-We need more info to find the problem. This could even be an engine bug, but that's unlikely to be the case, so I want to be sure before we open an issue. Questions:
1) Which version of Solarus are you using?
2) Is that file added as a quest file in the Quest Editor?
3) Which is the extension of the file? (Some audio extensions are not supported by Solarus)
4) Is that music being played when attached to a map in the map editor?

It would also help a lot if you can temporarily share a link to your folder, so that we can help you solve this problem.
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

etertaycb

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Quick Question about sol.audio.play_music
« Reply #4 on: May 31, 2018, 03:33:42 pm »
Here is a link to the quest folder with the issue re-created

https://mega.nz/#!TCpiSabL!cXUcY3GXMEoEjLOy5F5o2crFVOkJ3y3V6DPFvw2lhJg


 I've recreated the issue (bug?) in its simplest form. here are the answers to your questions

1.) 1.5.3
2.) yes, in addition i am only using the default music files in the folder "eduardo"
the song I tried to use in this example was "game_over.ogg"
3.) .ogg  (default files)
4.) yes. If I attach the same song "game_over.ogg" with the map editor the song will play

the error I receive is Error: In on_key_pressed: [string "main.lua"]:48: No such music: 'game_over

Code: [Select]
function sol.main:on_key_pressed(key, modifiers)

  local handled = false
  if key == "f5" then
    -- F5: change the video mode.
    sol.video.switch_mode()
    handled = true
  elseif key == "f11" or
    (key == "return" and (modifiers.alt or modifiers.control)) then
    -- F11 or Ctrl + return or Alt + Return: switch fullscreen.
    sol.video.set_fullscreen(not sol.video.is_fullscreen())
    handled = true
  elseif key == "f4" and modifiers.alt then
    -- Alt + F4: stop the program.
    sol.main.exit()
    handled = true
  elseif key == "escape" and sol.main.game == nil then
    -- Escape in title screens: stop the program.
    sol.main.exit()
    handled = true
-- this is where I get an issue
elseif key == "p" then
sol.audio.play_music("game_over")

  end

Diarandor

  • Hero Member
  • *****
  • Posts: 1020
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Quick Question about sol.audio.play_music
« Reply #5 on: May 31, 2018, 05:06:08 pm »
Your musics are in the folder "musics/eduardo/", so
the id for your boss music is "eduardo/boss" and not just "boss". That will fix your problem. You can now destroy your link above.
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”