PHLIM2'S MUSIC PLAYER LITE

RPG Maker VX Ace

Current Version: v1.01

  • phlim2
  • 02/22/2013 02:31 AM
  • 4942 views
Description
Since I've been working on Searching for Mother, I've wanted to have a music player of some sort. So I decided to try out the old method I used in RPG Maker VX. It didn't work out at all.

So today, I decided to see if I could create a new music player from scratch. It took a lot of trial and error, but I managed to do it!

Screenshots

Integrated into the title screen!


Simple to use GUI!


Doesn't require any unlock data!


Easily customisable!

Script
=begin
=========================================================
* PHLiM2's Music Player Lite v1.01 for RPG Maker VX Ace *
=========================================================
#################
# RELEASE NOTES #
#################
|
| 22-Feb-2013 [v1.01]
|- Made the player a lot more customizable.
|--- Added TEXTSTOP, TEXTPLAY, TEXTMARK addons.
|--- Added INCREMENT addon.
|--- Added the ability to remove window backgrounds.
|--- Added the ability to flip window positions.
|--- Added the ability to change the command text
|--- Added the PAUSE addon.
|--- Removed the FILLSCREEN addon, as this has no real use in the Lite version.
|- The music now stops when loading the Music Player from the Title Screen.
|- Adjusted to run on both 544x416 and 640x480 resolutions
|
| 22-Feb-2013 [v1.00]
|- Initial Release
|
################
#  HOW TO USE  #
################
|
| Using this script is pretty simple. All you have to do is edit the list below,
| including all the songs you want to include, and such.
|
| SONGTITLE: This section is pretty much the title of the song. Feel free to
|            change this to whatever you wish.
|
| PLAYSONG:  To use this section properly, you must use the FILENAME of the song
|            you wish to play.
|
| SONGPIT:   This adjusts the pitch of the song. You can choose any value
|            between 1 and 454. (Seriously, you can exceed the maker's limits.)
|
| TEXTSTOP:  The text which appears when nothing is playing.
|
| TEXTPLAY:  The text which appears when a song is playing.
|
| TEXTMARK:  The mark which appears next to the song number.
|
| INCREMENT: Choose whether to start the song numbers from 0 or 1.
|
| LISTNOBG:  Remove window BG for List window?
|
| PLAYNOBG:  Remove window BG for Now Playing window?
|
| FLIPWIN:   Flip the positions of the List/Now Playing windows?
|
| CMDTEXT:   The command text for the music player.
|
| PAUSE:     Choose whether or not to have a fake "Loading" pause.
|
##############################
# WHAT ABOUT VOLUME CONTROL? #
##############################
|
| Well, as most songs are USUALLY normalized, I have decided to not include this
| section. However, you can change the overall volume by editing this line:
| # @volume = 100 #
|
=end
module P2MUSICPLAY
  ##########################################
  # Song Title                             #
  ##########################################
  SONGTITLE = [
                "Airship",
                "Battle1",
                "Battle2",
                "Battle3",
                "Battle4",
                "Battle5",
                "Battle6",
                "Battle7",
                "Battle8",
                "Battle9",
                "Dungeon1",
                "Dungeon2",
                "Dungeon3",
                "Dungeon4",
                "Dungeon5",
                "Dungeon6",
                "Dungeon7",
                "Dungeon8",
                "Dungeon9",
                "Field1",
                "Field2",
                "Field3",
                "Field4",
                "Scene1",
                "Scene2",
                "Scene3",
                "Scene4",
                "Scene5",
                "Scene6",
                "Ship",
                "Theme1",
                "Theme2",
                "Theme3",
                "Theme4",
                "Theme5",
                "Town1",
                "Town2",
                "Town3",
                "Town4",
                "Town5",
                "Town6",
                "Town7"]
                
  ##########################################
  # File Name (without the file extension) #
  ##########################################
  FILENAME = [
                "Airship",
                "Battle1",
                "Battle2",
                "Battle3",
                "Battle4",
                "Battle5",
                "Battle6",
                "Battle7",
                "Battle8",
                "Battle9",
                "Dungeon1",
                "Dungeon2",
                "Dungeon3",
                "Dungeon4",
                "Dungeon5",
                "Dungeon6",
                "Dungeon7",
                "Dungeon8",
                "Dungeon9",
                "Field1",
                "Field2",
                "Field3",
                "Field4",
                "Scene1",
                "Scene2",
                "Scene3",
                "Scene4",
                "Scene5",
                "Scene6",
                "Ship",
                "Theme1",
                "Theme2",
                "Theme3",
                "Theme4",
                "Theme5",
                "Town1",
                "Town2",
                "Town3",
                "Town4",
                "Town5",
                "Town6",
                "Town7"]
                
  ##########################################
  # Song Pitch                             #
  ##########################################
  SONGPIT  = [
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100,
              100]
              
  ##########################################
  # Music Stopped Text                     #
  ##########################################
  TEXTSTOP = "STOPPED"
  
  ##########################################
  # Music Playing Text                     #
  ##########################################
  TEXTPLAY = "NOW PLAYING"
    
  ##########################################
  # Song Index Increment                   #
  ##########################################
  TEXTMARK = ":"
  
  ##########################################
  # Song Index Increment                   #
  ##########################################
  INCREMENT = true
  
  ##########################################
  # Remove List Background?                #
  ##########################################
  LISTNOBG  = false
    
  ##########################################
  # Remove Player Background?              #
  ##########################################
  PLAYNOBG  = false
    
  ##########################################
  # Flip Window Positions?                 #
  ##########################################
  FLIPWIN   = false
    
  ##########################################
  # Command Text                           #
  ##########################################
  CMDTEXT   = "BGM Player"
      
  ##########################################
  # Song Loading Pause?                    #
  ##########################################
  PAUSE   = true
    
end
################################################################################
# Window_MusicList                                                             #
################################################################################
class Window_MusicList < Window_Command
  def initialize(x,y)
    super(x,y)
    self.openness = 0
    if P2MUSICPLAY::LISTNOBG
      self.opacity=0
    end
  end
  def window_width
    return Graphics.width - 16
  end
  def visible_line_number
    if Graphics.height == 416
      return 9
    elsif Graphics.height == 480
      return 11
    else
      return 10
    end
  end
  def make_command_list
    add_multiple
  end
  def add_multiple
    songs = Array.new(P2MUSICPLAY::SONGTITLE)
    for i in songs
      add_command(i, :playsong)
    end
  end
  def draw_item(index)
    if P2MUSICPLAY::INCREMENT
      @new_index = index + 1
    else
      @new_index = index
    end
    @new = sprintf("[%03d]",@new_index)
    change_color(normal_color, command_enabled?(index))
    draw_text(item_rect_for_text(index), @new+" "+P2MUSICPLAY::TEXTMARK+" "+command_name(index), 0)
  end
end
################################################################################
# Window_MusicNowPlaying                                                       #
################################################################################
class Window_MusicNowPlaying < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(line_number = 5)
    super(0, 0, window_width, fitting_height(line_number))
    self.openness = 0
    if P2MUSICPLAY::PLAYNOBG
      self.opacity=0
    end
  end
  def window_width
    return Graphics.width - 16
  end
   
  #--------------------------------------------------------------------------
  # * Set Text
  #--------------------------------------------------------------------------
  def set_text(text)
    if text != @text
      @text = text
      refresh
    end
  end
  #--------------------------------------------------------------------------
  # * Clear
  #--------------------------------------------------------------------------
  def clear
    set_text("")
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_text_ex(0, 0, @text)
  end
  #--------------------------------------------------------------------------
  # * Draw Text with Control Characters
  #--------------------------------------------------------------------------
  def draw_text_ex(x, y, text)
    reset_font_settings
    text = convert_escape_characters(text)
    pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
    process_character(text.slice!(0, 1), text, pos) until text.empty?
  end
end
################################################################################
# Scene_MusicPlayer                                                            #
################################################################################
class Scene_MusicPlayer < Scene_MenuBase
  def start
    super
    Graphics.fadein(10)
    create_command_window
    @nowplaying = Window_MusicNowPlaying.new
    @nowplaying.x = @command_window.x
    if P2MUSICPLAY::FLIPWIN
      @nowplaying.y = 16 if Graphics.height == 416
      @nowplaying.y = 24 if Graphics.height == 480
      @command_window.y = @nowplaying.y + @nowplaying.height
    else
      @nowplaying.y = @command_window.y + @command_window.height
    end

    @info = "\\c[2]CONFIRM: \\c[0]Play Song\n\\c[2]DASH: \\c[0]Stop Song\n\\c[2]CANCEL: \\c[0]Return"
    nothingplaying
    @command_window.open
    @nowplaying.open
    @volume = 100
  end
  def nothingplaying
    @nowplaying.set_text("\\c[4]"+P2MUSICPLAY::TEXTSTOP+":\\c[0] No Song Playing\n\n"+@info)
  end
    def create_command_window
    @command_window = Window_MusicList.new(8,24)
    @command_window.y = 16 if Graphics.height == 416
    @command_window.set_handler(:playsong, method(:cmd_playsong))
    @command_window.set_handler(:cancel, method(:cmd_cancel))
  end

  def cmd_playsong
    if P2MUSICPLAY::PAUSE
      @nowplaying.set_text("\\c[3]LOADING SONG:\\c[0] "+P2MUSICPLAY::SONGTITLE[@command_window.index]+"\n\n"+@info)
      Audio.bgm_fade(1200)
      Graphics.wait(60)
    end
    Audio.bgm_play("Audio/BGM/"+P2MUSICPLAY::FILENAME[@command_window.index],@volume,P2MUSICPLAY::SONGPIT[@command_window.index])
    @nowplaying.set_text("\\c[4]"+P2MUSICPLAY::TEXTPLAY+":\\c[0] "+P2MUSICPLAY::SONGTITLE[@command_window.index]+"\n\n"+@info)
    @command_window.activate
  end
  def cmd_cancel
    @command_window.close
    Audio.bgm_fade(360)
    SceneManager.call(Scene_Title)
  end
  alias upall update_all_windows
  def update_all_windows
    upall
    if Input.press?(:A)
      Audio.bgm_fade(600)
      nothingplaying
    end
  end
end
################################################################################
# Music Player Title Addon                                                     #
################################################################################
class Window_TitleCommand < Window_Command
  alias addplayer make_command_list
  def make_command_list
    addplayer
    add_command(P2MUSICPLAY::CMDTEXT, :player)
  end
end
class Scene_Title < Scene_Base
  alias playercommand create_command_window
  def create_command_window
    playercommand
    @command_window.set_handler(:player, method(:command_player))
  end
  def command_player
    close_command_window
    Audio.bgm_stop
    SceneManager.call(Scene_MusicPlayer)
  end
end

Posts

Pages: 1
Sure, as long as you credit me for it. :D
im new to scripting is there a way to put this in the in game menu
Great Script! Thanks for sharing! You my friend are a genius!
Pages: 1