RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[Completed] Pre-Title Movie using SOV Player

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 67
Eternal Newbie
    Pre-Title Movie
    August 28th, 2011



    Summary
    Just a quick snippet that would allow the use of a movie before the title screen, like an intro movie.

    Features Desired
    • Play movie before the title screen

    Games its been in
    • The Tales of series is a good example

    What other scripts are you using?
    • SOV Player



    Did you search?
    Yes

    Where did you search?
    • rmrk.net
    • rpgmakervx.net
    • rpgrevolution.com
    • google

    What did you search for?
    A combination of the following terms:
    • SuperOverlord
    • video
    • splash
    • movie
    • pre-title
    • rmvx
    • vx
    • RPG Maker VX
    • avi
    • SOV Player
    • AVI Player
    • script

    Here is the SOV Player script. It will definitely prove useful in figuring this out, since I figure it's a matter of calling the video scene on the Main script. I just can't figure out how to do this correctly (I can get it to not syntax error but the video won't show)
    [/list]
    Code: [Select]
    #==============================================================================
    #
    # SOV ~ Videos
    #
    #==============================================================================
    # Author: SuperOverlord
    #==============================================================================
    # Features:
    #------------------------------------------------------------------------------
    # o Play video's on the map or in battle using a simple script event command.
    #
    # o Optionally pause or exit video's while they play.
    #
    # o View the video in the game window or in fullscreen.
    #
    # o Setup video skills, which show the video before damage effects.
    # Videos must be
    #   Compression Type: None
    #   Size: 640x480
    #   Ratio: Square Pixels
    #   Frame Rate: 24FPS
    #   Sound Compression: None
    #   Sample Rate: 44100mHz
    #   Bit rate: 16bits
    #==============================================================================
    # Instructions:
    #------------------------------------------------------------------------------
    # o Place all videos in a folder with the same name as in configuration.
    #   This folder is created automatically the first time the game is played if
    #   it doesn't already exist.
    #
    # o Playing Videos when on the map.
    #
    #   - See script calls below.
    #
    # o Playing videos in battle.
    #
    #   - As when on the map the script event command can be used in battle also.
    #
    #   - As well as this you can setup skills as video skills which display
    #     a video before damaging the enemy.
    #
    #     To do this the following tags can be used in the skills notebox:
    #     1) <video_name = "filename">
    #        ~ name is the name of the video file. If the filename extension is
    #          missing the first file matching that name is used.
    #          (Quotes are necessary around the filename)
    #
    #      As well as the first tag 2 others are available. These tags will only
    #      take effect if placed on a line below the first tag.
    #      If these don't exist they are assumed true.
    #
    #      2) <video_exitable = n>   ~ Can the video be exited by the exit input?
    #      3) <video_pausable = n>   ~ Can the video be paused?
    #         ~ n is replaced with either t or f (t : true, f : false)
    #
    #      For other Video properties (x,y,width,height,fullscreen) the default
    #      settings are used. (See script calls below)
    #==============================================================================
    # Script Calls:
    #------------------------------------------------------------------------------
    # Commands (From the script call command on page three of event commands)
    #------------------------------------------------------------------------------
    # o To change default values for video properties.
    #
    #  1) Video.default_x = n
    #  2) Video.default_y = n
    #  3) Video.default_width  = n
    #  4) Video.default_height = n
    #  5) Video.fullscreen = bool

    #  In all 5 commands above:
    #  ~ n is an integer value
    #  ~ bool is either true or false
    #
    # o To play videos
    #
    #   play_video(filename,exitable,pausable)
    #   ~ filename : name of video file             (Must be in quotes)
    #   ~ exitable : Can the video be exited?       (When left out = true)
    #   ~ pausable : Can the video be paused?       (When left out = true)

    #   For all other values the default's are used.
    #==============================================================================
    # Compatibility:
    #------------------------------------------------------------------------------
    # o Skill videos will depend on the battle system but sould work.
    #==============================================================================
    # Credit:
    #------------------------------------------------------------------------------
    # o Credit goes to Trebor and Berka whose scripts helped be figure out the
    #   mci_send_stringA function.
    #==============================================================================

    module SOV
      module Video
      #--------------------------------------------------------------------------
      # Configuration
      #--------------------------------------------------------------------------
        # Name of folder for videos to be held in.
        DIR_NAME = "Movies"
        # Exit video input
        EXIT_INPUT  = Input::B
        # Pause video input
        PAUSE_INPUT = Input::R
      #--------------------------------------------------------------------------
      # End Configuration
      #--------------------------------------------------------------------------
      end
    end

    #==============================================================================
    # Import
    #------------------------------------------------------------------------------
    $imported = {} if $imported == nil
    $imported['Movies'] = true
    #==============================================================================

    #==============================================================================
    # ** SOV::Video::Commands
    #==============================================================================

    module SOV::Video::Commands
      #--------------------------------------------------------------------------
      # * Play a video
      #  filename : video's filename (with or without extension)
      #  exitable : Can the video be exited
      #  pausable : Can the video be paused
      #--------------------------------------------------------------------------
      def play_video(filename,exitable=true,pausable=true)
        video = Cache.video(filename)
        video.exitable = exitable
        video.pausable = pausable
        if $game_temp.in_battle    # In battle
          $scene.play_video(video)
        else                       # On map
          $game_map.video = video
        end
      end
      #---------------------------------------------------------------------------
      # Define as module function
      #---------------------------------------------------------------------------
      module_function :play_video
    end

    #==============================================================================
    # ** SOV::Video::Regexp
    #==============================================================================

    module SOV::Video::Regexp
      #--------------------------------------------------------------------------
      # * Skill
      #--------------------------------------------------------------------------
      module Skill
        FILENAME   = /<video[_ ]?(?:file)?name = "(.+)">/i
        PAUSABLE   = /<video[_ ]?paus(?:e|able) = (t|f)>/i
        EXITABLE   = /<video[_ ]?exit(?:able)? = (t|f)>/i
      end
    end

    #==============================================================================
    # ** SOV::Game
    #==============================================================================

    module SOV::Game
      #--------------------------------------------------------------------------
      # Constants
      #--------------------------------------------------------------------------
      INI = 'Game'
      #--------------------------------------------------------------------------
      # * Get the game windows handle
      #--------------------------------------------------------------------------
      def self.hwnd
        unless defined?(@@hwnd)
          find_window = Win32API.new('user32','FindWindow','pp','i')
          @@hwnd = find_window.call('RGSS Player',title) 
        end
        return @@hwnd
      end
      #--------------------------------------------------------------------------
      # * Get game title
      #--------------------------------------------------------------------------
      def self.title
        unless defined?(@@title)
          @@title = read_ini('title')
        end
        return @@title
      end
      #--------------------------------------------------------------------------
      # * Read ini (Returns nil or match)
      #--------------------------------------------------------------------------
      def self.read_ini(variable,filename=INI)
        reg = /^#{variable}=(.*)$/
        File.foreach(filename+'.ini') { |line| break($1) if line =~ reg }
      end
    end

    #==============================================================================
    # ** Cache
    #==============================================================================

    module Cache
      #--------------------------------------------------------------------------
      # Class Variables
      #--------------------------------------------------------------------------
      @@vcache = {}
      #--------------------------------------------------------------------------
      # Define as class methods
      #--------------------------------------------------------------------------
      class << self
        #------------------------------------------------------------------------
        # Alias List
        #------------------------------------------------------------------------
        alias sov_video_clear clear unless $@
        #------------------------------------------------------------------------
        # * Get a video object
        #  filename : basename of file
        #------------------------------------------------------------------------
        def video(filename)
          # Get full filename if extension is missing
          if File.extname(filename) == ''
            files = Dir["#{SOV::Video::DIR_NAME}/#{filename}.*"]
            filename = File.basename(files[0]) # Set as first matching file
          end
          # Create or get the video object.
          if @@vcache.has_key?(filename)
            @@vcache[filename]
          else
            @@vcache[filename] = Video.new(filename)
          end
        end
        #------------------------------------------------------------------------
        # * Clear
        #------------------------------------------------------------------------
        def clear
          @@vcache.clear
          sov_video_clear
        end
      end
    end

    #==============================================================================
    # ** RPG::Skill
    #==============================================================================

    class RPG::Skill < RPG::UsableItem
      #--------------------------------------------------------------------------
      # * Determine if skill has a video skill
      #--------------------------------------------------------------------------
      def video
        if @video == nil
          @note.each_line { |line|
            if @video == nil
              @video = Cache.video($1) if line =~ SOV::Video::Regexp::Skill::FILENAME
            else
              @video.pausable = ($1 == 't') if line =~ SOV::Video::Regexp::Skill::PAUSABLE
              @video.exitable = ($1 == 't') if line =~ SOV::Video::Regexp::Skill::EXITABLE
            end
          }
          @video = :invalid if @video == nil
        end
        return @video
      end
    end

    #==============================================================================
    # ** Video
    #------------------------------------------------------------------------------
    #  Class handling playing videos.
    #==============================================================================

    class Video
      #--------------------------------------------------------------------------
      # Constants
      #--------------------------------------------------------------------------
      TYPE_AVI  = 'avivideo'
      TYPE_MPEG = 'mpegvideo'
      #--------------------------------------------------------------------------
      # Class Variables
      #--------------------------------------------------------------------------
      @@default_x = 0
      @@default_y = 0
      @@default_width  = Graphics.width
      @@default_height = Graphics.height
      @@fullscreen = false
      #--------------------------------------------------------------------------
      # * Get and Set default_x/y/width/height
      #--------------------------------------------------------------------------
      for d in %w(x y width height)
        # Define setter method
        module_eval(%Q(def self.default_#{d}=(i); @@default_#{d} = i; end))
        # Define getter method
        module_eval(%Q(def self.default_#{d}; @@default_#{d}; end))
      end
      #--------------------------------------------------------------------------
      # * Get fullscreen
      #--------------------------------------------------------------------------
      def self.fullscreen
        @@fullscreen
      end 
      #--------------------------------------------------------------------------
      # * Set fullscreen
      #--------------------------------------------------------------------------
      def self.fullscreen=(val)
        @@fullscreen = val
      end
      #--------------------------------------------------------------------------
      # * Win32API
      #--------------------------------------------------------------------------
      @@mciSendStringA = Win32API.new('winmm','mciSendStringA','pplp','i')
      #--------------------------------------------------------------------------
      # * Video Command
      #  command_string : string following mci_command_string format
      #  buffer : string to retrieve return data
      #  buffer_size : number of characters in buffer
      #  callback_handle : handle of window to callback to. Used if notify is used
      #                    in the command string. (Not supported by game window)
      #--------------------------------------------------------------------------
      def self.send_command(cmnd_string,buffer='',buffer_size=0,callback_handle=0)
        # Returns error code. No error if NULL
        err = @@mciSendStringA.call(cmnd_string,buffer,buffer_size,callback_handle)
        if err != 0
          buffer = ' ' * 255
          Win32API.new('winmm','mciGetErrorString','LPL','V').call(err,buffer,255)
          raise(buffer.squeeze(' ').chomp('\000'))
        end
      end
      #--------------------------------------------------------------------------
      # * Play a video
      #--------------------------------------------------------------------------
      def self.play(video)
        # Make path and buffer
        path = "#{SOV::Video::DIR_NAME}/#{video.filename}"
        buffer = ' ' * 255
        # Initialize device and dock window with game window as parent.
        type = " type #{video.type}" if video.type != ''
        send_command("open #{path}#{type} alias VIDEO style child parent #{SOV::Game.hwnd}")
        # Display video in client rect at x,y with width and height.
        x = video.x
        y = video.y
        width  = video.width
        height = video.height
        send_command("put VIDEO window at #{x} #{y} #{width} #{height}")
        # Begin playing video
        screen = @@fullscreen ? 'fullscreen' : 'window'
        send_command("play VIDEO #{screen}")
        # Start Input and status processing loop
        while buffer !~ /^stopped/
          # Idle processing for a frame
          sleep(1.0/Graphics.frame_rate)
          # Get mode string
          send_command('status VIDEO mode',buffer,255)
          Input.update
          if Input.trigger?(SOV::Video::PAUSE_INPUT) and video.pausable?
            Sound.play_cursor
            if buffer =~ /^paused/                 # If already paused
              send_command("resume VIDEO")         # Resume video
            else                                   # Otherwise
              send_command("pause VIDEO")          # Pause video
            end
          elsif Input.trigger?(SOV::Video::EXIT_INPUT) and video.exitable?
            Sound.play_cancel
            # Terminate loop on exit input
            break
          end
        end
        # Terminate the device
        send_command('close VIDEO')
      end
      #--------------------------------------------------------------------------
      # Public Instance Variables
      #--------------------------------------------------------------------------
      attr_accessor :x
      attr_accessor :y
      attr_accessor :width
      attr_accessor :height
      attr_writer :exitable
      attr_writer :pausable
      attr_reader :filename
      #--------------------------------------------------------------------------
      # * Initialize
      #--------------------------------------------------------------------------
      def initialize(filename)
        unless FileTest.file?("#{SOV::Video::DIR_NAME}/#{filename}")
          raise(Errno::ENOENT,filename)
        end
        @filename = filename
        @x = @@default_x
        @y = @@default_y
        @width  = @@default_width
        @height = @@default_height
        @exitable = true
        @pausable = true
      end
      #--------------------------------------------------------------------------
      # * Get Type
      #--------------------------------------------------------------------------
      def type
        if @type == nil
          case File.extname(@filename)
          when '.avi'; @type = TYPE_AVI
          when '.mpeg'||'.mpg'; @type = TYPE_MPEG
          else
            @type = ''
          end
        end
        @type
      end
      #--------------------------------------------------------------------------
      # * Is the video exitable?
      #--------------------------------------------------------------------------
      def exitable?
        @exitable
      end
      #--------------------------------------------------------------------------
      # * Is the video pausable?
      #--------------------------------------------------------------------------
      def pausable?
        @pausable
      end
      #--------------------------------------------------------------------------
      # Access
      #--------------------------------------------------------------------------
      private_class_method :send_command 
    end

    #==============================================================================
    # ** Game_Interpreter
    #==============================================================================

    class Game_Interpreter
      #--------------------------------------------------------------------------
      # Import
      #--------------------------------------------------------------------------
      include(SOV::Video::Commands)
    end

    #==============================================================================
    # ** Game_Map
    #==============================================================================

    class Game_Map
      #--------------------------------------------------------------------------
      # Public Instance Variables
      #--------------------------------------------------------------------------
      attr_accessor :video 
    end

    #==============================================================================
    # ** Scene_Map
    #==============================================================================

    class Scene_Map
      #--------------------------------------------------------------------------
      # Alias List
      #--------------------------------------------------------------------------
      alias sov_video_update update unless $@
      #--------------------------------------------------------------------------
      # * Play Video
      #--------------------------------------------------------------------------
      def play_video(video)
        # Memorize and stop current bgm and bgs
        bgm = RPG::BGM.last
        bgs = RPG::BGS.last
        RPG::BGM.stop
        RPG::BGS.stop
        # Play video
        Video.play(video)
        # Restart bgm and bgs
        bgm.play
        bgs.play
      end
      #--------------------------------------------------------------------------
      # * Update
      #--------------------------------------------------------------------------
      def update
        if $game_map.video != nil
          play_video($game_map.video)
          $game_map.video = nil
          Input.update
        else
          sov_video_update
        end
      end
    end

    #==============================================================================
    # ** Scene_Battle
    #==============================================================================

    class Scene_Battle
      #--------------------------------------------------------------------------
      # * Alias list
      #--------------------------------------------------------------------------
      alias sov_video_execute_action_skill execute_action_skill unless $@
      #--------------------------------------------------------------------------
      # * Play Video
      #--------------------------------------------------------------------------
      def play_video(video)
        # Memorize and stop current bgm
        bgm = RPG::BGM.last
        RPG::BGM.stop
        # Play video
        Video.play(video)
        # Restart bgm
        bgm.play
      end
      #--------------------------------------------------------------------------
      # * Execute Action Skill
      #--------------------------------------------------------------------------
      def execute_action_skill
        skill = @active_battler.action.skill   
        if skill.video.is_a?(Video)
          execute_action_video(skill)
        else
          sov_video_execute_action_skill
        end
      end
      #--------------------------------------------------------------------------
      # * Execute Action Video
      #--------------------------------------------------------------------------
      def execute_action_video(skill)
        text = @active_battler.name + skill.message1
        @message_window.add_instant_text(text)
        unless skill.message2.empty?
          wait(10)
          @message_window.add_instant_text(skill.message2)
        end
        wait(20)
        @message_window.clear
        # Fadout to black screen
        br = Graphics.brightness
        120.times { |i| Graphics.brightness = 255 - 255/60 * i; Graphics.update }
        # Play video
        play_video(skill.video)
        # Reset brightness
        Graphics.brightness = br
        targets = @active_battler.action.make_targets
        display_animation(targets, skill.animation_id)
        @active_battler.mp -= @active_battler.calc_mp_cost(skill)
        $game_temp.common_event_id = skill.common_event_id
        for target in targets
          target.skill_effect(@active_battler, skill)
          display_action_effects(target, skill)
        end
      end
    end

    #==============================================================================
    # Pre-Main Processing
    #==============================================================================

    unless FileTest.directory?(SOV::Video::DIR_NAME) # If directory doesn't exist.
      Dir.mkdir(SOV::Video::DIR_NAME)                # Make the directory
    end

    Thanks to cozziekuns for the quick little snippet.

    Insert this code below Graphics.freeze and above $scene = Scene_Title.new
    Code: [Select]
    video = Cache.video("Filename") # Change Filename to the filename, and keep the quotes
    video.exitable = true # True/False
    video.pausable = true # True/False
    Video.play(video)
    « Last Edit: August 29, 2011, 04:21:47 AM by JonFawkes »

    ****
    Rep:
    Level 71
    I'm not 100% sure but I think you change " $scene = Scene_Title.new" to "$scene = Video.new("Splash")" This way might not work you probably have to screw around with video script so it would continue to the title.

    **
    Rep:
    Level 67
    Eternal Newbie
    Nope, that didn't work. I tried a coupe of configurations but the video doesn't show up. Thanks for trying though

    *****
    Rep:
    Level 84
    This text is way too personal.
    Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
    Insert after Graphics.freeze but before $scene = Scene_Title.new or whatever.

    Code: [Select]
    video = Cache.video("Filename") # Change Filename to the filename, and keep the quotes
    video.exitable = true # True/False
    video.pausable = true # True/False
    Video.play(video)

    **
    Rep:
    Level 67
    Eternal Newbie
    Thanks so much! I'll be sure to credit you.