Music Room Help?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
TheOneAndOnly-K
Regular
Posts: 78
Joined: Mon Apr 07, 2014 10:33 am
Contact:

Music Room Help?

#1 Post by TheOneAndOnly-K »

Code: Select all

#Hey Renpy I got some music tracks...
init python:
    # Step 1. Create a MusicRoom instance.
    mr = MusicRoom(fadeout=1.0)
    # Step 2. Add music files.
    mr.add("music/4th String Quartet.mp3", always_unlocked=True)
    mr.add("music/Adventure Time.mp3", always_unlocked=True)
    mr.add("music/Asterisk Bleach.mp3", always_unlocked=True)
    mr.add("music/Can Do Kuroko No Basket.mp3", always_unlocked=True)
    mr.add("music/Death Note.mp3", always_unlocked=True)
    mr.add("music/Fruits Basket.mp3", always_unlocked=True)
    mr.add("music/Glaring Dream Gravitation.mp3", always_unlocked=True)
    mr.add("music/Gotta Go Fast Sonic X.mp3", always_unlocked=True)
    mr.add("music/Hatafutte Parade.mp3", always_unlocked=True)
    mr.add("music/I Will Fullmetal Alchemist.mp3", always_unlocked=True)
    mr.add("music/Let Me Be With You Chobits.mp3", always_unlocked=True)
    mr.add("music/Monochrome No Kiss Black Butler.mp3", always_unlocked=True)
    mr.add("music/Pokemon.mp3", always_unlocked=True)
    mr.add("music/Rage On Free.mp3", always_unlocked=True)
    mr.add("music/Resonance Soul Eater.mp3", always_unlocked=True)
    mr.add("music/Sakura Kiss Ouran High.mp3", always_unlocked=True)
    mr.add("music/Snow Fairy Fairy Tail.mp3", always_unlocked=True)
    mr.add("music/The Orphans.mp3", always_unlocked=True)

#Hey Renpy now I gotta make a player to play em...
screen music_room:

    tag menu
    window:
        style "gm_root"
        
    frame:
        style_group "gm_nav"
        size_group "mm"
        xpos 720
        ypos 580
        has vbox:
            xalign 0.98 
            yalign 0.98
        
    frame: #these positioning changes depending on your layout
        style_group "gm_root"   #<=== 
        xpos 10
        ypos 10
        xmargin .05
        yanchor 0
        ypadding .05
        

        has vbox:
            xalign .5
            yalign .5
            spacing 0
            

        # The buttons that play each track.  MUST CORRESPOND TO THE TRACK LIST ABOVE
        textbutton "The Zodiac Theme" action mr.Play("music/4th String Quartet.mp3")
        textbutton "Adventure T Theme" action mr.Play("music/Adventure Time.mp3")
        textbutton "Asterik" action mr.Play("music/Asterisk Bleach.mp3")
        textbutton "Can Do" action mr.Play("music/Can Do Kuroko No Basket.mp3")
        textbutton "Death Note Theme" action mr.Play("music/Death Note.mp3")
        textbutton "Fruits Basket Theme" action mr.Play("music/Fruits Basket.mp3")
        textbutton "Gotta Go Fast" action mr.Play("music/Gotta Go Fast Sonic X.mp3")
        textbutton "Hatafutte Parade" action mr.Play("music/Hatafutte Parade.mp3")
        textbutton "I Will" action mr.Play("music/I Will Fullmetal Alchemist.mp3")
        textbutton "Let Me Be With You" action mr.Play("music/Let Me Be With You Chobits.mp3")
        textbutton "Monochrome No Kiss" action mr.Play("music/Monochrome No Kiss Black Butler.mp3")
        textbutton "Pokémon Theme" action mr.Play("music/Pokemon.mp3")
        textbutton "Rage On" action mr.Play("music/Rage On Free.mp3")
        textbutton "Resonance" action mr.Play("music/Resonance Soul Eater.mp3")
        textbutton "Sakura Kiss" action mr.Play("music/Sakura Kiss Ouran High.mp3")
        textbutton "Snow Fairy" action mr.Play("music/Snow Fairy Fairy Tail.mp3")
        textbutton "Super Drive" action mr.Play("music/Glaring Dream Gravitation.mp3")
        textbutton "The Orphans" action mr.Play("music/The Orphans.mp3")

    frame:
        xpos 500
        ypos 535
        has hbox:
            xalign 0.98
            yalign 0.98
        
        # Buttons that let us advance tracks.
        textbutton "<<" action mr.Previous()
        textbutton "II" action mr.Stop()
        textbutton ">>" action mr.Next()

    # Start the music playing on entry to the music room.
    on "replace" action mr.Play()

    # Restore the main menu music upon leaving.
    on "replaced" action Play("music", "music/Bright wish.mp3")
    
    imagemap:
        ground "frame.png"
        hover "frame1.png"
        
        hotspot (480, 280, 140, 40) action [ Play("The Zodiac Theme", "TZB.png"), Show("music_info", info="TZB.png") ]
        hotspot (480, 320, 140, 40) action [ Play("Adventure T Theme", "title.jpg"), Show("music_info", info="title.jpg") ]
        hotspot (480, 280, 140, 40) action [ Play("Asterik", "971606931.jpg"), Show("music_info", info="971606931.jpg") ]
        hotspot (480, 320, 140, 40) action [ Play("Can Do", "KnB.jpg"), Show("music_info", info="KnB.jpg") ]
        hotspot (480, 280, 140, 40) action [ Play("Death Note Theme", "DN.png"), Show("music_info", info="DN.png") ]
        hotspot (480, 320, 140, 40) action [ Play("Fruits Basket Theme", "6865467.jpg"), Show("music_info", info="6865467.jpg") ]
        hotspot (480, 280, 140, 40) action [ Play("Gotta Go Fast", "Sonic.jpg"), Show("music_info", info="Sonic.jpg") ]
        hotspot (480, 320, 140, 40) action [ Play("Hatafutte Parade", "1.jpg"), Show("music_info", info="1.jpg") ]
        hotspot (480, 280, 140, 40) action [ Play("I Will", "cover_I.jpg"), Show("music_info", info="cover_I.jpg") ]
        hotspot (480, 320, 140, 40) action [ Play("Let Me Be With You", "chobits.jpg"), Show("music_info", info="chobits.jpg") ]
        hotspot (480, 280, 140, 40) action [ Play("Monochrome No Kiss", "BB.jpg"), Show("music_info", info="BB.jpg") ]
        hotspot (480, 320, 140, 40) action [ Play("Pokémon Theme", "P.png"), Show("music_info", info="P.png") ]
        hotspot (480, 280, 140, 40) action [ Play("Rage On", "F.jpg"), Show("music_info", info="F.jpg") ]
        hotspot (480, 320, 140, 40) action [ Play("Resonance", "17.jpg"), Show("music_info", info="17.jpg") ]
        hotspot (480, 280, 140, 40) action [ Play("Sakura Kiss", "OH.jpg"), Show("music_info", info="OH.jpg") ]
        hotspot (480, 320, 140, 40) action [ Play("Snow Fairy", "cover.jpg"), Show("music_info", info="cover.jpg") ]
        hotspot (480, 280, 140, 40) action [ Play("Super Drive", "download.jpg"), Show("music_info", info="download.jpg") ]
        hotspot (480, 320, 140, 40) action [ Play("The Orphans", "To.png"), Show("music_info", info="To.png") ]        
        hotspot (480, 360, 140, 40) action [ Stop("music"), Hide("music_info") ]
        hotspot (480, 400, 140, 40) action Return()

screen music_info:
    zorder 1
    add info xpos 40 ypos 40

label music_room:
    call screen music_room
    return
The error:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/_layout/screen_main_menu.rpym", line 29, in script
  File "game/screens.rpy", line 781, in python
  File "renpy/common/00action_audio.rpy", line 45, in python
  File "renpy/common/00action_audio.rpy", line 52, in python
Exception: Audio channel 'Adventure T Theme' is unknown.

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\execution.py", line 294, in run
    node.execute()
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\ast.py", line 732, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\python.py", line 1382, in py_exec_bytecode
    exec bytecode in globals, locals
  File "renpy/common/_layout/screen_main_menu.rpym", line 29, in <module>
    $ ui.interact()
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\ui.py", line 237, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\display\core.py", line 2059, in interact
    scene_lists.replace_transient()
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\display\core.py", line 577, in replace_transient
    self.remove(layer, tag)
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\display\core.py", line 851, in remove
    self.hide_or_replace(layer, remove_index, "hide")
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\display\core.py", line 775, in hide_or_replace
    d = oldsle.displayable._hide(now - st, now - at, prefix)
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\display\screen.py", line 189, in _hide
    hid.update()
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\display\screen.py", line 270, in update
    self.screen.function(**self.scope)
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\screenlang.py", line 1236, in __call__
    renpy.python.py_exec_bytecode(self.code.bytecode, locals=scope)
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\python.py", line 1382, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/screens.rpy", line 781, in <module>
    hotspot (480, 320, 140, 40) action [ Play("Adventure T Theme", "title.jpg"), Show("music_info", info="title.jpg") ]
  File "renpy/common/00action_audio.rpy", line 45, in __init__
    self.selected = self.get_selected()
  File "renpy/common/00action_audio.rpy", line 52, in get_selected
    return renpy.music.get_playing(self.channel) == self.file
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\audio\music.py", line 291, in get_playing
    c = renpy.audio.audio.get_channel(channel)
  File "C:\Users\Mam\Downloads\Fish\Renpy\renpy\audio\audio.py", line 758, in get_channel
    raise Exception("Audio channel %r is unknown." % name)
Exception: Audio channel 'Adventure T Theme' is unknown.

Windows-7-6.1.7601-SP1
Ren'Py 6.17.4.409

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Music Room Help?

#2 Post by Alex »

I suppose the problem is here

Code: Select all

hotspot (480, 320, 140, 40) action [ Play("Adventure T Theme", "title.jpg"), Show("music_info", info="title.jpg") ]
- you trying to play "title.jpg" file on channel "Adventure T Theme"
http://www.renpy.org/doc/html/screen_ac ... io-actions

As I posted in your other thread, you don't need this imagemap part at all.

User avatar
korova
Veteran
Posts: 217
Joined: Sat Jun 27, 2009 5:15 pm
Completed: Ivy, Chocolate, Time, Clair Obscur
Projects: Writing exercises, The House [Nano18]
Tumblr: korova08
itch: korova
Location: Normandie, France
Contact:

Re: Music Room Help?

#3 Post by korova »

I think your problem come from your instruction "Play()"
for example :

Code: Select all

hotspot (480, 280, 140, 40) action [ Play("The Zodiac Theme", "TZB.png"), Show("music_info", info="TZB.png") ]
Play syntax should be like :

Code: Select all

 Play(channel, file, **kwargs)

    Causes an audio file to be played on a given channel.

    channel
        The channel to play the sound on.
    file
        The file to play. 
meaning the first argument should be the name of a channel for the music to play (i.e. "music" or "sound"), when your first argument is actually the name of your music, which should be the second argument. (and i don't think that Play uses image files as arguments)

(I hope that's clear enough, my english is not so good)

[edit] I wasn't fast enough... answer is given just above !

Post Reply

Who is online

Users browsing this forum: No registered users