RPG Maker Forums

Hello. I'm trying to use the MCI Audio Player script by ForeverZer0 at https://forum.chaos-project.com/index.php?topic=11778.0 but I can't seem to get it to play audio files, and he's no longer offering support for his scripts. I've looked at some posts on the web about it, but either find unanswered questions or instances where people ask for support, say they've figured it out, but don't reveal their solution.

The script features functions that I deem important for proper screenplay (and I'm currently not using MV due to not knowing JavaScript and there being some scripts that haven't been ported), like the ability to play two tracks and effectively "fade one into the other" rather than jarringly having to abruptly switch from one song to another, to fade out a song and then play another, and the ability to fade in a song rather than just fade out.
If it's far too complex for a simple hotfix, I'd might be willing to commission someone to get it to work for me, as the only workaround I could think of is using BGS but that would come with its own issues.

There are a number of errors that I'll face and I feel it's necessary to show my troubleshooting process first.

From the beginning, on a fresh project, I switch 'RPG_VERSION' to 2 on line 207 at
# Enter the code for the version of RPG Maker you are using this script for.
# RMXP = 0
# RMVX = 1
# RMVXA = 2
RPG_VERSION = 0
and try running the game to test an event.
I am met with an error
Script 'ForeverZer0 MCI Audio Player' line 254: NoMethodError occurred.
undefined method 'gsub' for nil:NilClass
So, I decided to edit the def open(filename) segment at line 241 to
Code:
    def open(filename)
      #--
      puts "Filename: #{filename}"
      #--
      if File.exists?(filename)
        puts "exists"
        path = filename
      else
        #--
        puts "does not exist"
        #--
        path = Dir::glob(filename + '.*')[0]
        if path == nil
          directory = File.dirname(filename)
          if RTP.subfolder?(directory)
            file = File.basename(filename)
            path = RTP[directory].find {|f| File.basename(f, '.*') == file }
          end
        end
      end
      #--
      puts "Path: #{path}"
      #--
      @filepath = path.gsub(/\\/, '/')
      if MIDI_MODE && ['.mid', '.midi'].include?(File.extname(path))
        @midi = true
        cmd = "open \"#{path}\" type sequencer alias #{@name}"
      else
        cmd = "open \"#{path}\" type mpegvideo alias #{@name}"
      end
      MCISendString.call(cmd, nil, 0, 0)
      MCISendString.call("set #{@name} time format milliseconds", nil, 0, 0)
      MCISendString.call("set #{@name} seek exactly on", nil, 0, 0)
      @opened = true
    end
which reads in the console as
Filename: Audio/BGM/Theme1
does not exist
Path:
Meaning that the path is nil.
I figure this might be due to the RTP module process near the bottom (line 830) since it might not account for Steam users, and to control, I eliminate the reading of RTP files so I can focus on at least getting custom files to work, and instead replace the def open(filename) segment with
Code:
    def open(filename)
      #--
      puts "Filename: #{filename}"
      #--
      #my edit-- files are automatically considered not to "exist", so I'mm
      #having it so it doesn't check for it in the first place.
      #--
#~       if File.exists?(filename)
#~         path = filename
#~       else
#~         path = Dir::glob(filename + '.*')[0]
#~         if path == nil
#~           directory = File.dirname(filename)
#~           if RTP.subfolder?(directory)
#~             file = File.basename(filename)
#~             path = RTP[directory].find {|f| File.basename(f, '.*') == file }
#~           end
#~         end
#~       end
      path = filename
      #The game was trying to load a nil file upon game start to where it
      #would be impossible to gsub a blank string.
      #--
#~       @filepath = path.gsub(/\\/, '/')
      #--
      puts "Path: #{path}"
      if path != nil
        @filepath = path.gsub(/\\/, '/')
      else
        @filepath = path
      end
      #--
      if MIDI_MODE && ['.mid', '.midi'].include?(File.extname(path))
        @midi = true
        cmd = "open \"#{path}\" type sequencer alias #{@name}"
      else
        cmd = "open \"#{path}\" type mpegvideo alias #{@name}"
      end
      MCISendString.call(cmd, nil, 0, 0)
      MCISendString.call("set #{@name} time format milliseconds", nil, 0, 0)
      MCISendString.call("set #{@name} seek exactly on", nil, 0, 0)
      @opened = true
    end
As now I'm just going to exclusively test custom music.
I place an mp3 file named 'myFile' in my BGM folder, and set it as the Title Screen theme.
At this point, I can't even get custom music to play/pause.

At def pause and resume at line 304 I replace the code with the following
Code:
    def pause
      MCISendString.call("pause #{@name}", nil, 0, 0)
      #--
      puts "attempting to pause"
      #--
    end
    #---------------------------------------------------------------------------
    # * Resume playback on a paused mixer from previous position
    #---------------------------------------------------------------------------
    def resume
      MCISendString.call("resume #{@name}", nil, 0, 0)
      #--
      puts "attempting to resume"
      #--
    end
I make an event that makes the script call:
Code:
Audio['myName'].play('Audio/BGM/myFile')
20.times { Fiber.yield }
if Audio['myName'].opened?; puts "opened"; else; puts "not opened"; end
if Audio['myName'].playing?; puts "playing"; else; puts "not playing"; end
20.times { Fiber.yield }
Audio['myName'].pause
20.times { Fiber.yield }
if Audio['myName'].paused?; puts "paused"; else; puts "not paused"; end
if Audio['myName'].playing?; puts "playing"; else; puts "not playing"; end
Audio['myName'].resume
20.times { Fiber.yield }
if Audio['myName'].playing?; puts "playing"; else; puts "not playing"; end
which leads the console to print
Filename: Audio/BGM/myFile
Path: Audio/BGM/myFile
opened
not playing
attempting to pause
not paused
not playing
attempting to resume
not playing
I also tried a variation where I instead made the call Audio['myName'].play('myFile') (akin to example call included in the script's description)
along with trying to play the song from the editor's Play BGM call, but still had the same issue. No sound is heard, the file is 'opened', readied to be played by the MCI player, but it is never actually played.

I know that I have winmm.dll and the proper codecs on my computer (as I can play mp3/wav/ogg/midi files on a given audio player). I should also mention that I use Windows 10, if that means anything.

I'm unsure whether it's an issue with the script or the MCI dll itself, nor do I know whether the original demo had a dll file included that was required to make the script work -- The download link is now invalid. I feel like I once had this script working back when I was using Windows XP and I don't remember having to use the demo file.

Does anyone have any assistance they can offer on this one, or are you unable to replicate the issues I'm facing?

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,036
Messages
1,018,461
Members
137,821
Latest member
Capterson
Top