Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Music Playback Methods

I was wondering if methods exist which perform the following:

A) Fast-forwards the current BGM by a particular amount.
B) Returns your time into the current BGM (ie, 1 minute and 30 seconds in).

If these methods don't exist, does anybody know of any workarounds?
 
1) No. Myself and a few others are working on Audio modules that will allow us to do that.

2) Yes, but requires some work. Something like:

Code:
module Audio
  class << self
    alias_method :seph_audioduration_audio_pbgm, :play_bgm
    alias_method :seph_audioduration_audio_update, :update
    @bgm_duration = 0
    def play_bgm(*args)
      seph_audioduration_audio_pbgm(*args)
      @bgm_duration = 0
    end
    def update
      seph_audioduration_audio_update
      @bgm_duration += 1
    end
    def bgm_duration
      return @bgm_duration
    end
  end
end

Insert that code. You should be able to just use Audio.bgm_duration and it will tell you how many frames an audio track has been played.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top