RMMV Save the time a song is at in a variable

Peva

Don't overwhelm yourself. Set small goals.
Veteran
Joined
Dec 5, 2012
Messages
258
Reaction score
34
First Language
English
Primarily Uses
RMMV
Are there any plugins that let you save the exact time of a song (bgm) thats playing in a variable, and subsequently, let you start another song at the exact time saved in that variable? If there aren't any, is that something simple that can be made?
 

Peva

Don't overwhelm yourself. Set small goals.
Veteran
Joined
Dec 5, 2012
Messages
258
Reaction score
34
First Language
English
Primarily Uses
RMMV

Peva

Don't overwhelm yourself. Set small goals.
Veteran
Joined
Dec 5, 2012
Messages
258
Reaction score
34
First Language
English
Primarily Uses
RMMV

Peva

Don't overwhelm yourself. Set small goals.
Veteran
Joined
Dec 5, 2012
Messages
258
Reaction score
34
First Language
English
Primarily Uses
RMMV

poppicha

Villager
Member
Joined
Aug 30, 2015
Messages
21
Reaction score
12
First Language
Thai
Primarily Uses
RMMV
Hello, @Peva As $gameVariable can only store an integer number(as I tested it),
I'm going to save the current play time in AudioManager._currentSaveBgmTime so you can use it later.
JavaScript:
AudioManager._currentSaveBgmTime = AudioManager._bgmBuffer.seek();
var saveBgmTime = AudioManager._currentSaveBgmTime;
var newBgm = { name: filename, volume: n, pitch: n, pan: n }
AudioManager.playBgm(newBgm, saveBgmTime);
 
Last edited:

imcatman

Veteran
Veteran
Joined
Apr 12, 2019
Messages
49
Reaction score
17
First Language
German
Primarily Uses
RMMV
To save the exact time of the currently playing song (bgm) in a variable and restart next time, the following worked.
Save the current number of seconds in variable 1 while fading out the playing bgm.
$gameVariables.setValue(1,AudioManager.saveBgm())



Play from the last number of seconds from next time AudioManager.replayBgm($gameVariables.value(1));

Is this what you are looking for?
 

Peva

Don't overwhelm yourself. Set small goals.
Veteran
Joined
Dec 5, 2012
Messages
258
Reaction score
34
First Language
English
Primarily Uses
RMMV
Sorry, just to confirm, do I just run these as "script" in the event editor?
 

imcatman

Veteran
Veteran
Joined
Apr 12, 2019
Messages
49
Reaction score
17
First Language
German
Primarily Uses
RMMV
yes it is in my case
first do it in script
Examples:
AudioManager.stopBgm()
$gameVariables.setValue(1,AudioManager.saveBgm())


then at a time of your choosing
AudioManager.replayBgm($gameVariables.value(1));
 

Latest Threads

Latest Posts

Latest Profile Posts


Clarn Hold
(No storylines)
There was a tutorial on how to draw anime eyes. Just draw Among Us. So I tried.
Screenshot_107.jpg
DamageActor3_7.png added!
index.php

Making a "characters first appearance" drawing for my game. Now I just have to finish the sprite art animation for her grand entrance.​
ScreenShot_9_24_2022_7_56_24.png
New area being started today. It leads to one of the games 2 optional bosses.

Forum statistics

Threads
125,540
Messages
1,171,815
Members
164,611
Latest member
anonymouss
Top