How to loop a track inside a MusicRoom?

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
abeplaga
Regular
Posts: 34
Joined: Mon Oct 15, 2018 10:09 am
Contact:

How to loop a track inside a MusicRoom?

#1 Post by abeplaga » Fri Mar 29, 2019 11:04 pm

Hi everyone!

I'm trying to add a botton with the possibility to loop a track of a MusicRoom but I don't get it.

I searched the documentation and the only way I found is create a botton whose action is mr.SetLoop(True) but it doesn't work. I think that SetLoop is a loop for all MusicRoom and no for a single track... but no matter how much I read the documentation and think for myself, I can't imagine how to do it for just one song.

Is it possible or is it very messy? If anyone could tell me how to do it, I'd be very grateful.

User avatar
isobellesophia
Miko-Class Veteran
Posts: 976
Joined: Mon Jan 07, 2019 2:55 am
Completed: None
Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
Organization: Friendly Teachers series
Deviantart: SophBelle
itch: Child Creation
Location: Philippines, Mindanao
Contact:

Re: How to loop a track inside a MusicRoom?

#2 Post by isobellesophia » Fri Mar 29, 2019 11:21 pm

I am a friendly user, please respect and have a good day.


Image

Image


User avatar
abeplaga
Regular
Posts: 34
Joined: Mon Oct 15, 2018 10:09 am
Contact:

Re: How to loop a track inside a MusicRoom?

#3 Post by abeplaga » Sat Mar 30, 2019 6:33 pm

Thanks but with this, for I read, stop the music to play a track but I don't want that. I want a button like any audio reproductor: click and when actual track ends, it plays again.

You gimme an idea with the renpy.music.play: using music.queue but actually it doesn't work: when I click the button the actual track is looping, but when I click again the loop persists and the music doesn't return to normal :cry:

Code: Select all

$ musicloop = False
$ music_is_normal = ""

screen of the musicroom:
    if musicloop== False:
        textbutton "LOOP (not active)" action SetVariable("musicloop", True)
    else:
        textbutton "LOOP (active)" action [SetVariable("musicloop", False), SetVariable("music_is_normal", True)]
        $ actualtrack = renpy.music.get_playing()
        $ renpy.music.queue(actualtrack, loop=True)

    if music_is_normal == True:
        $ renpy.music.queue(mywholemusic, loop=False)
        timer 0.1 action SetVariable("music_is_normal", False)

TheMCButterfly
Newbie
Posts: 17
Joined: Sat Mar 30, 2019 12:16 pm
Projects: Friends Forever - Talk to a character
IRC Nick: Butterfly
Contact:

Re: How to loop a track inside a MusicRoom?

#4 Post by TheMCButterfly » Sun Mar 31, 2019 4:25 am

I'm pretty sure you can just do

Code: Select all

define audio.tutorial = "music/filename.ogg"


play music tutorial

You can stop the sound with:

Code: Select all


stop music


User avatar
abeplaga
Regular
Posts: 34
Joined: Mon Oct 15, 2018 10:09 am
Contact:

Re: How to loop a track inside a MusicRoom?

#5 Post by abeplaga » Sun Mar 31, 2019 7:31 am

TheMCButterfly wrote:
Sun Mar 31, 2019 4:25 am
I'm pretty sure you can just do

Code: Select all

define audio.tutorial = "music/filename.ogg"


play music tutorial

You can stop the sound with:

Code: Select all


stop music

How can add this to a button? I want to add this loop/no-loop feature to a button.

User avatar
Donmai
Eileen-Class Veteran
Posts: 1885
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question
Projects: Slumberland
Location: Brazil
Contact:

Re: How to loop a track inside a MusicRoom?

#6 Post by Donmai » Sun Mar 31, 2019 1:05 pm

I don't know which version of the music room you're using. Mine starts with these lines:

Code: Select all

init python:
    mr = MusicRoom(fadeout=1.0, single_track=False, loop=True)
f you set single_track to False, each song will play once and the player will automatically advance to the next track. Set single_track to True and each song will loop until you manually advance to the next track.
I've also tried, but I couldn't find a way to loop only a single track in the music room.
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

User avatar
abeplaga
Regular
Posts: 34
Joined: Mon Oct 15, 2018 10:09 am
Contact:

Re: How to loop a track inside a MusicRoom?

#7 Post by abeplaga » Tue Apr 02, 2019 8:34 pm

Donmai wrote:
Sun Mar 31, 2019 1:05 pm
I don't know which version of the music room you're using. Mine starts with these lines:

Code: Select all

init python:
    mr = MusicRoom(fadeout=1.0, single_track=False, loop=True)
f you set single_track to False, each song will play once and the player will automatically advance to the next track. Set single_track to True and each song will loop until you manually advance to the next track.
I've also tried, but I couldn't find a way to loop only a single track in the music room.
That was exactly what I was looking for ^^

I went back to review the documentation and it escaped me completely ... Thank you, thank you so much!!!

Post Reply

Who is online

Users browsing this forum: Google [Bot]