查看: 1858|回复: 3

[已经解决] 关于VA视频播放的问题

[复制链接]
梦石
0
星屑
918
在线时间
213 小时
注册时间
2006-10-8
回帖
237
发表于 2013-9-1 10:55:53 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
自己做的游戏,自己做了视频,有30秒左右

转换好了,可以播放

但是问题来了,如果每次运行游戏都得等30秒似乎不是那么人性化

怎么样做才能实现“任意键跳过视频”呢?

求教各位老大啊,搜索主站发现有一脚本可以直接地图播放动画并支持跳过,但是却发现下载不了,郁闷啊


(这里)
EST - SOV Video Player ++ Script Conversion 1.4
http://www.rpgmakervxace.net/topic/7177-est-sov-video-player-script-conversion-v-12-20120927/


求各位解决难题。

梦石
0
星屑
407
在线时间
1291 小时
注册时间
2013-1-12
回帖
3349

贵宾

发表于 2013-9-1 11:54:13 | 显示全部楼层
[pre lang="ruby" line="1"]#==============================================================================
#
# [ACE]EST_SOV_Video_Player ++ Conversion
#
# v1.4
#==============================================================================
# Author : Estriole
# (Conversion to ace and improving)
# VX version author: SuperOverlord
#
# also credit Crystal Noel for solution for title that have encoding problem character
# also credit ruin for fixes he made to this script.
#
# History :
# version 1.4 2013.05.16 - apply fixes from ruin. typo error and ability to use
#                          play video using battle event page.
# version 1.3 2013.03.05 - create configuration for people that have encoding character
#                          problem with their title. ex: Pokémon Ace.
#                          set the IGNORE_TITLE to true inside module Sov::Video
# version 1.2 2012.09.27 - made if game at fullscreen automaticly become windowed
# version 1.1 2012.09.25 - some bug fix. now avi video can played at full screen mode(alt enter) with some position error.
#                        - can play other format such as mkv but it will play full screen and when played at full screen
#                          mode (alt enter) the size will be smaller and the game switched.
#                        - basicly this script not support full screen game yet. will try to fix this in next version
# version 1.0 2012.09.23 - finish converting + some change
#
#
#==============================================================================
# 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.
#
# o ACE version also made not only video skill but can use video item too
#
# o ACE version also can play video before title scene
#
#==============================================================================
# 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.
#
#     <now below setup can be also used for item video too>
#     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)
#
# o Playing videos before title screen
# ctrl + f this : CONFIGURATION FOR VIDEO BEFORE TITLE
# and change the
# @video_title = nil
# to
# @video_title = "yourvideonamewithoutextensionhere"
#
#==============================================================================
# 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 #disabled now since could make error
#  
#  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 = "Videos"
    # Exit video input
    EXIT_INPUT  = Input::B
    # Pause video input
    PAUSE_INPUT = Input::C
   
    IGNORE_TITLE = true
    #set to true if your title contain strange character such as é or other.   
  #--------------------------------------------------------------------------
  # End Configuration
  #--------------------------------------------------------------------------
  end
end

module SceneManager
################ CONFIGURATION FOR VIDEO BEFORE TITLE #######################  
  @video_title = nil  # "example" # FILENAME OF THE VIDEO IN VIDEO FOLDER IN QUOTES
  #IF YOU DON'T WANT TO USE THIS FEATURE JUST CHANGE TO NIL
################ END CONFIGURATION ##########################################  
  def self.run
    DataManager.init
    Audio.setup_midi if use_midi?
    if @video_title != nil
    video = Cache.video(@video_title)
    video.exitable = true # True/False
    video.pausable = true # True/False
    Video.play(video)
    end
    @Scene = first_scene_class.new
    @scene.main while @scene
  end
end

class << Graphics
  def Graphics.fullscreen? # Property
    screen_size = Win32API.new('user32', 'GetSystemMetrics', 'I', 'I')
    screen_width = screen_size.call(0);   screen_height = screen_size.call(1)   
    detect_fullscreen = false
    detect_fullscreen = true if screen_width == 640 and screen_height == 480
    return detect_fullscreen
  end
  def Graphics.toggle_fullscreen # Main function
    keybd = Win32API.new 'user32.dll', 'keybd_event', ['i', 'i', 'l', 'l'], 'v'
    keybd.call(0xA4, 0, 0, 0)
    keybd.call(13, 0, 0, 0)
    keybd.call(13, 0, 2, 0)
    keybd.call(0xA4, 0, 2, 0)   
  end
end

#==============================================================================
# Import
#------------------------------------------------------------------------------
$imported = {} if $imported == nil
$imported['Videos'] = 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
    $game_map.video = video
  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)  
      gamefullscreen = Graphics.fullscreen?
      @@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)
    return nil if variable == 'title' && SOV::Video::IGNORE_TITLE
    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::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'
    gamefullscreen = Graphics.fullscreen?
    case video.type
    when "avivideo"
      if gamefullscreen == true
      #send_command("put VIDEO window at #{x} #{y} 640 480")
      Graphics.toggle_fullscreen
      send_command("play VIDEO window")
      else
      send_command("play VIDEO window")
      end
    when "mpegvideo"
        if gamefullscreen == true
        Graphics.toggle_fullscreen
        send_command("play VIDEO window")
        else
        send_command("play VIDEO fullscreen")
        end
    else
    end
    flag = 0
    # 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 = TYPE_MPEG#''
      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_update_battle update unless $@
  alias sov_video_use_item use_item 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 use_item
    skill = @subject.current_action.item   
    if skill.video.is_a?(Video)
      execute_action_video(skill)
      sov_video_use_item
    else
      sov_video_use_item
    end
  end
  #--------------------------------------------------------------------------
  # * Execute Action Video
  #--------------------------------------------------------------------------
  def execute_action_video(skill)
    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
  end
  #ADDED UPDATE FUNCTION FROM SCENE_MAP TO SCENE_BATTLE
  def update
    if $game_map.video != nil
      play_video($game_map.video)
      $game_map.video = nil
      Input.update
    else
      sov_video_update_battle
    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

=begin
=end[/pre]

幫你拿出來了...  我人在加拿大所以可以進去

评分

参与人数 1星屑 +20 收起 理由
Jousun + 20 大恩不言谢

查看全部评分


回复

使用道具 举报

梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2013-9-1 12:07:12 | 显示全部楼层
  1.        

  2.     #==============================================================================
  3.     #
  4.     # [ACE]EST_SOV_Video_Player ++ Conversion
  5.     #
  6.     # v1.4
  7.     #==============================================================================
  8.     # Author : Estriole
  9.     # (Conversion to ace and improving)
  10.     # VX version author: SuperOverlord
  11.     #
  12.     # also credit Crystal Noel for solution for title that have encoding problem character
  13.     # also credit ruin for fixes he made to this script.
  14.     #
  15.     # History :
  16.     # version 1.4 2013.05.16 - apply fixes from ruin. typo error and ability to use
  17.     #                          play video using battle event page.
  18.     # version 1.3 2013.03.05 - create configuration for people that have encoding character
  19.     #                          problem with their title. ex: Pokémon Ace.
  20.     #                          set the IGNORE_TITLE to true inside module Sov::Video
  21.     # version 1.2 2012.09.27 - made if game at fullscreen automaticly become windowed
  22.     # version 1.1 2012.09.25 - some bug fix. now avi video can played at full screen mode(alt enter) with some position error.
  23.     #                        - can play other format such as mkv but it will play full screen and when played at full screen
  24.     #                          mode (alt enter) the size will be smaller and the game switched.
  25.     #                        - basicly this script not support full screen game yet. will try to fix this in next version
  26.     # version 1.0 2012.09.23 - finish converting + some change
  27.     #
  28.     #
  29.     #==============================================================================
  30.     # Features:
  31.     #------------------------------------------------------------------------------
  32.     # o Play video's on the map or in battle using a simple script event command.
  33.     #
  34.     # o Optionally pause or exit video's while they play.
  35.     #
  36.     # o View the video in the game window or in fullscreen.
  37.     #
  38.     # o Setup video skills, which show the video before damage effects.
  39.     #
  40.     # o ACE version also made not only video skill but can use video item too
  41.     #
  42.     # o ACE version also can play video before title scene
  43.     #
  44.     #==============================================================================
  45.     # Instructions:
  46.     #------------------------------------------------------------------------------
  47.     # o Place all videos in a folder with the same name as in configuration.
  48.     #   This folder is created automatically the first time the game is played if
  49.     #   it doesn't already exist.
  50.     #
  51.     # o Playing Videos when on the map.
  52.     #
  53.     #   - See script calls below.
  54.     #
  55.     # o Playing videos in battle.
  56.     #
  57.     #   - As when on the map the script event command can be used in battle also.
  58.     #
  59.     #   - As well as this you can setup skills as video skills which display
  60.     #     a video before damaging the enemy.
  61.     #
  62.     #     <now below setup can be also used for item video too>
  63.     #     To do this the following tags can be used in the skills notebox:
  64.     #     1) <video_name = "filename">
  65.     #        ~ name is the name of the video file. If the filename extension is
  66.     #          missing the first file matching that name is used.
  67.     #          (Quotes are necessary around the filename)
  68.     #
  69.     #      As well as the first tag 2 others are available. These tags will only
  70.     #      take effect if placed on a line below the first tag.
  71.     #      If these don't exist they are assumed true.
  72.     #
  73.     #      2) <video_exitable = n>   ~ Can the video be exited by the exit input?
  74.     #      3) <video_pausable = n>   ~ Can the video be paused?
  75.     #         ~ n is replaced with either t or f (t : true, f : false)
  76.     #
  77.     #      For other Video properties (x,y,width,height,fullscreen) the default
  78.     #      settings are used. (See script calls below)
  79.     #
  80.     # o Playing videos before title screen
  81.     # ctrl + f this : CONFIGURATION FOR VIDEO BEFORE TITLE
  82.     # and change the
  83.     # @video_title = nil
  84.     # to
  85.     # @video_title = "yourvideonamewithoutextensionhere"
  86.     #
  87.     #==============================================================================
  88.     # Script Calls:
  89.     #------------------------------------------------------------------------------
  90.     # Commands (From the script call command on page three of event commands)
  91.     #------------------------------------------------------------------------------
  92.     # o To change default values for video properties.
  93.     #
  94.     #  1) Video.default_x = n
  95.     #  2) Video.default_y = n
  96.     #  3) Video.default_width  = n
  97.     #  4) Video.default_height = n
  98.     #  5) Video.fullscreen = bool #disabled now since could make error
  99.     #  
  100.     #  In all 5 commands above:
  101.     #  ~ n is an integer value
  102.     #  ~ bool is either true or false
  103.     #
  104.     # o To play videos
  105.     #
  106.     #   play_video(filename,exitable,pausable)
  107.     #   ~ filename : name of video file             (Must be in quotes)
  108.     #   ~ exitable : Can the video be exited?       (When left out = true)
  109.     #   ~ pausable : Can the video be paused?       (When left out = true)
  110.     #  
  111.     #   For all other values the default's are used.
  112.     #==============================================================================
  113.     # Compatibility:
  114.     #------------------------------------------------------------------------------
  115.     # o Skill videos will depend on the battle system but sould work.
  116.     #==============================================================================
  117.     # Credit:
  118.     #------------------------------------------------------------------------------
  119.     # o Credit goes to Trebor and Berka whose scripts helped be figure out the
  120.     #   mci_send_stringA function.
  121.     #==============================================================================
  122.      
  123.     module SOV
  124.       module Video
  125.       #--------------------------------------------------------------------------
  126.       # Configuration
  127.       #--------------------------------------------------------------------------
  128.         # Name of folder for videos to be held in.
  129.         DIR_NAME = "Videos"
  130.         # Exit video input
  131.         EXIT_INPUT  = Input::B
  132.         # Pause video input
  133.         PAUSE_INPUT = Input::C
  134.       
  135.         IGNORE_TITLE = true
  136.         #set to true if your title contain strange character such as é or other.   
  137.       #--------------------------------------------------------------------------
  138.       # End Configuration
  139.       #--------------------------------------------------------------------------
  140.       end
  141.     end
  142.      
  143.     module SceneManager
  144.     ################ CONFIGURATION FOR VIDEO BEFORE TITLE #######################  
  145.       @video_title = nil  # "example" # FILENAME OF THE VIDEO IN VIDEO FOLDER IN QUOTES
  146.       #IF YOU DON'T WANT TO USE THIS FEATURE JUST CHANGE TO NIL
  147.     ################ END CONFIGURATION ##########################################  
  148.       def self.run
  149.         DataManager.init
  150.         Audio.setup_midi if use_midi?
  151.         if @video_title != nil
  152.         video = Cache.video(@video_title)
  153.         video.exitable = true # True/False
  154.         video.pausable = true # True/False
  155.         Video.play(video)
  156.         end
  157.         [url=home.php?mod=space&uid=420706]@Scene[/url] = first_scene_class.new
  158.         @scene.main while @scene
  159.       end
  160.     end
  161.      
  162.     class << Graphics
  163.       def Graphics.fullscreen? # Property
  164.         screen_size = Win32API.new('user32', 'GetSystemMetrics', 'I', 'I')
  165.         screen_width = screen_size.call(0);   screen_height = screen_size.call(1)   
  166.         detect_fullscreen = false
  167.         detect_fullscreen = true if screen_width == 640 and screen_height == 480
  168.         return detect_fullscreen
  169.       end
  170.       def Graphics.toggle_fullscreen # Main function
  171.         keybd = Win32API.new 'user32.dll', 'keybd_event', ['i', 'i', 'l', 'l'], 'v'
  172.         keybd.call(0xA4, 0, 0, 0)
  173.         keybd.call(13, 0, 0, 0)
  174.         keybd.call(13, 0, 2, 0)
  175.         keybd.call(0xA4, 0, 2, 0)   
  176.       end
  177.     end
  178.      
  179.     #==============================================================================
  180.     # Import
  181.     #------------------------------------------------------------------------------
  182.     $imported = {} if $imported == nil
  183.     $imported['Videos'] = true
  184.     #==============================================================================
  185.      
  186.     #==============================================================================
  187.     # ** SOV::Video::Commands
  188.     #==============================================================================
  189.      
  190.     module SOV::Video::Commands
  191.       #--------------------------------------------------------------------------
  192.       # * Play a video
  193.       #  filename : video's filename (with or without extension)
  194.       #  exitable : Can the video be exited
  195.       #  pausable : Can the video be paused
  196.       #--------------------------------------------------------------------------
  197.       def play_video(filename,exitable=true,pausable=true)
  198.         video = Cache.video(filename)
  199.         video.exitable = exitable
  200.         video.pausable = pausable
  201.         $game_map.video = video
  202.       end
  203.       #---------------------------------------------------------------------------
  204.       # Define as module function
  205.       #---------------------------------------------------------------------------
  206.       module_function :play_video
  207.     end
  208.      
  209.     #==============================================================================
  210.     # ** SOV::Video::Regexp
  211.     #==============================================================================
  212.      
  213.     module SOV::Video::Regexp
  214.       #--------------------------------------------------------------------------
  215.       # * Skill
  216.       #--------------------------------------------------------------------------
  217.       module Skill
  218.         FILENAME   = /<video[_ ]?(?:file)?name = "(.+)">/i
  219.         PAUSABLE   = /<video[_ ]?paus(?:e|able) = (t|f)>/i
  220.         EXITABLE   = /<video[_ ]?exit(?:able)? = (t|f)>/i
  221.       end
  222.     end
  223.      
  224.     #==============================================================================
  225.     # ** SOV::Game
  226.     #==============================================================================
  227.      
  228.     module SOV::Game
  229.       #--------------------------------------------------------------------------
  230.       # Constants
  231.       #--------------------------------------------------------------------------
  232.       INI = 'Game'
  233.       #--------------------------------------------------------------------------
  234.       # * Get the game windows handle
  235.       #--------------------------------------------------------------------------
  236.       def self.hwnd
  237.         unless defined?(@@hwnd)
  238.           find_window = Win32API.new('user32','FindWindow','pp','i')
  239.     #      @@hwnd = find_window.call('RGSS Player',title)  
  240.           gamefullscreen = Graphics.fullscreen?
  241.           @@hwnd = find_window.call('RGSS Player',title)  
  242.         end
  243.         return @@hwnd
  244.       end
  245.       #--------------------------------------------------------------------------
  246.       # * Get game title
  247.       #--------------------------------------------------------------------------
  248.       def self.title
  249.         unless defined?(@@title)
  250.           @@title = read_ini('title')
  251.         end
  252.         return @@title
  253.       end
  254.       #--------------------------------------------------------------------------
  255.       # * Read ini (Returns nil or match)
  256.       #--------------------------------------------------------------------------
  257.       def self.read_ini(variable,filename=INI)
  258.         return nil if variable == 'title' && SOV::Video::IGNORE_TITLE
  259.         reg = /^#{variable}=(.*)$/
  260.         File.foreach(filename+'.ini') { |line| break($1) if line =~ reg }
  261.       end
  262.     end
  263.      
  264.     #==============================================================================
  265.     # ** Cache
  266.     #==============================================================================
  267.      
  268.     module Cache
  269.       #--------------------------------------------------------------------------
  270.       # Class Variables
  271.       #--------------------------------------------------------------------------
  272.       @@vcache = {}
  273.       #--------------------------------------------------------------------------
  274.       # Define as class methods
  275.       #--------------------------------------------------------------------------
  276.       class << self
  277.         #------------------------------------------------------------------------
  278.         # Alias List
  279.         #------------------------------------------------------------------------
  280.         alias sov_video_clear clear unless $@
  281.         #------------------------------------------------------------------------
  282.         # * Get a video object
  283.         #  filename : basename of file
  284.         #------------------------------------------------------------------------
  285.         def video(filename)
  286.           # Get full filename if extension is missing
  287.           if File.extname(filename) == ''
  288.             files = Dir["#{SOV::Video::DIR_NAME}/#{filename}.*"]
  289.             filename = File.basename(files[0]) # Set as first matching file
  290.           end
  291.           # Create or get the video object.
  292.           if @@vcache.has_key?(filename)
  293.             @@vcache[filename]
  294.           else
  295.             @@vcache[filename] = Video.new(filename)
  296.           end
  297.         end
  298.         #------------------------------------------------------------------------
  299.         # * Clear
  300.         #------------------------------------------------------------------------
  301.         def clear
  302.           @@vcache.clear
  303.           sov_video_clear
  304.         end
  305.       end
  306.     end
  307.      
  308.     #==============================================================================
  309.     # ** RPG::Skill
  310.     #==============================================================================
  311.      
  312.     class RPG::UsableItem
  313.       #--------------------------------------------------------------------------
  314.       # * Determine if skill has a video skill
  315.       #--------------------------------------------------------------------------
  316.       def video
  317.         if @video == nil
  318.           @note.each_line { |line|
  319.             if @video == nil
  320.               @video = Cache.video($1) if line =~ SOV::Video::Regexp::Skill::FILENAME
  321.             else
  322.               @video.pausable = ($1 == 't') if line =~ SOV::Video::Regexp::Skill::PAUSABLE
  323.               @video.exitable = ($1 == 't') if line =~ SOV::Video::Regexp::Skill::EXITABLE
  324.             end
  325.           }
  326.           @video = :invalid if @video == nil
  327.         end
  328.         return @video
  329.       end
  330.     end
  331.      
  332.     #==============================================================================
  333.     # ** Video
  334.     #------------------------------------------------------------------------------
  335.     #  Class handling playing videos.
  336.     #==============================================================================
  337.      
  338.     class Video
  339.       #--------------------------------------------------------------------------
  340.       # Constants
  341.       #--------------------------------------------------------------------------
  342.       TYPE_AVI  = 'avivideo'
  343.       TYPE_MPEG = 'mpegvideo'
  344.       #--------------------------------------------------------------------------
  345.       # Class Variables
  346.       #--------------------------------------------------------------------------
  347.       @@default_x = 0
  348.       @@default_y = 0
  349.       @@default_width  = Graphics.width
  350.       @@default_height = Graphics.height
  351.       @@fullscreen = false
  352.       #--------------------------------------------------------------------------
  353.       # * Get and Set default_x/y/width/height
  354.       #--------------------------------------------------------------------------
  355.       for d in %w(x y width height)
  356.         # Define setter method
  357.         module_eval(%Q(def self.default_#{d}=(i); @@default_#{d} = i; end))
  358.         # Define getter method
  359.         module_eval(%Q(def self.default_#{d}; @@default_#{d}; end))
  360.       end
  361.       #--------------------------------------------------------------------------
  362.       # * Get fullscreen
  363.       #--------------------------------------------------------------------------
  364.       def self.fullscreen
  365.         @@fullscreen
  366.       end  
  367.       #--------------------------------------------------------------------------
  368.       # * Set fullscreen
  369.       #--------------------------------------------------------------------------
  370.       def self.fullscreen=(val)
  371.         @@fullscreen = val
  372.       end
  373.       #--------------------------------------------------------------------------
  374.       # * Win32API
  375.       #--------------------------------------------------------------------------
  376.       @@mciSendStringA = Win32API.new('winmm','mciSendStringA','pplp','i')
  377.       #--------------------------------------------------------------------------
  378.       # * Video Command
  379.       #  command_string : string following mci_command_string format
  380.       #  buffer : string to retrieve return data
  381.       #  buffer_size : number of characters in buffer
  382.       #  callback_handle : handle of window to callback to. Used if notify is used
  383.       #                    in the command string. (Not supported by game window)
  384.       #--------------------------------------------------------------------------
  385.       def self.send_command(cmnd_string,buffer='',buffer_size=0,callback_handle=0)
  386.         # Returns error code. No error if NULL
  387.         err = @@mciSendStringA.call(cmnd_string,buffer,buffer_size,callback_handle)
  388.         if err != 0
  389.           buffer = ' ' * 255
  390.           Win32API.new('winmm','mciGetErrorString','LPL','V').call(err,buffer,255)
  391.           raise(buffer.squeeze(' ').chomp('\000'))
  392.         end
  393.       end
  394.       
  395.       #--------------------------------------------------------------------------
  396.       # * Play a video
  397.       #--------------------------------------------------------------------------
  398.       def self.play(video)
  399.         # Make path and buffer
  400.         path = "#{SOV::Video::DIR_NAME}/#{video.filename}"
  401.         buffer = ' ' * 255
  402.         # Initialize device and dock window with game window as parent.
  403.         type = " type #{video.type}" if video.type != ''
  404.         send_command("open #{path}#{type} alias VIDEO style child parent #{SOV::Game.hwnd}")
  405.         # Display video in client rect at x,y with width and height.
  406.         x = video.x
  407.         y = video.y
  408.         width  = video.width
  409.         height = video.height
  410.         send_command("put VIDEO window at #{x} #{y} #{width} #{height}")
  411.         # Begin playing video
  412.         screen = @@fullscreen ? 'fullscreen' : 'window'
  413.         gamefullscreen = Graphics.fullscreen?
  414.         case video.type
  415.         when "avivideo"
  416.           if gamefullscreen == true
  417.           #send_command("put VIDEO window at #{x} #{y} 640 480")
  418.           Graphics.toggle_fullscreen
  419.           send_command("play VIDEO window")
  420.           else
  421.           send_command("play VIDEO window")
  422.           end
  423.         when "mpegvideo"
  424.             if gamefullscreen == true
  425.             Graphics.toggle_fullscreen
  426.             send_command("play VIDEO window")
  427.             else
  428.             send_command("play VIDEO fullscreen")
  429.             end
  430.         else
  431.         end
  432.         flag = 0
  433.         # Start Input and status processing loop
  434.         while buffer !~ /^stopped/
  435.           # Idle processing for a frame
  436.           sleep(1.0/Graphics.frame_rate)
  437.           # Get mode string
  438.           send_command('status VIDEO mode',buffer,255)
  439.           Input.update   
  440.           if Input.trigger?(SOV::Video::PAUSE_INPUT) and video.pausable?
  441.             Sound.play_cursor
  442.             if buffer =~ /^paused/                 # If already paused
  443.               send_command("resume VIDEO")         # Resume video
  444.             else                                   # Otherwise
  445.               send_command("pause VIDEO")          # Pause video
  446.             end
  447.           elsif Input.trigger?(SOV::Video::EXIT_INPUT) and video.exitable?
  448.             Sound.play_cancel
  449.             # Terminate loop on exit input
  450.             break
  451.           end
  452.         end
  453.         # Terminate the device
  454.         send_command('close VIDEO')
  455.       end
  456.       #--------------------------------------------------------------------------
  457.       # Public Instance Variables
  458.       #--------------------------------------------------------------------------
  459.       attr_accessor :x
  460.       attr_accessor :y
  461.       attr_accessor :width
  462.       attr_accessor :height
  463.       attr_writer :exitable
  464.       attr_writer :pausable
  465.       attr_reader :filename
  466.       #--------------------------------------------------------------------------
  467.       # * Initialize
  468.       #--------------------------------------------------------------------------
  469.       def initialize(filename)
  470.         unless FileTest.file?("#{SOV::Video::DIR_NAME}/#{filename}")
  471.           raise(Errno::ENOENT,filename)
  472.         end
  473.         @filename = filename
  474.         @x = @@default_x
  475.         @y = @@default_y
  476.         @width  = @@default_width
  477.         [url=home.php?mod=space&uid=291977]@height[/url] = @@default_height
  478.         @exitable = true
  479.         @pausable = true
  480.       end
  481.       #--------------------------------------------------------------------------
  482.       # * Get Type
  483.       #--------------------------------------------------------------------------
  484.       def type
  485.         if @type == nil
  486.           case File.extname(@filename)
  487.           when '.avi'; @type = TYPE_AVI
  488.           when '.mpeg'||'.mpg'; @type = TYPE_MPEG
  489.           else
  490.             @type = TYPE_MPEG#''
  491.           end
  492.         end
  493.         @type
  494.       end
  495.       #--------------------------------------------------------------------------
  496.       # * Is the video exitable?
  497.       #--------------------------------------------------------------------------
  498.       def exitable?
  499.         @exitable
  500.       end
  501.       #--------------------------------------------------------------------------
  502.       # * Is the video pausable?
  503.       #--------------------------------------------------------------------------
  504.       def pausable?
  505.         @pausable
  506.       end
  507.       #--------------------------------------------------------------------------
  508.       # Access
  509.       #--------------------------------------------------------------------------
  510.       private_class_method :send_command  
  511.     end
  512.      
  513.     #==============================================================================
  514.     # ** Game_Interpreter
  515.     #==============================================================================
  516.      
  517.     class Game_Interpreter
  518.       #--------------------------------------------------------------------------
  519.       # Import
  520.       #--------------------------------------------------------------------------
  521.       include(SOV::Video::Commands)
  522.     end
  523.      
  524.     #==============================================================================
  525.     # ** Game_Map
  526.     #==============================================================================
  527.      
  528.     class Game_Map
  529.       #--------------------------------------------------------------------------
  530.       # Public Instance Variables
  531.       #--------------------------------------------------------------------------
  532.       attr_accessor :video  
  533.     end
  534.      
  535.     #==============================================================================
  536.     # ** Scene_Map
  537.     #==============================================================================
  538.      
  539.     class Scene_Map
  540.       #--------------------------------------------------------------------------
  541.       # Alias List
  542.       #--------------------------------------------------------------------------
  543.       alias sov_video_update update unless $@
  544.       #--------------------------------------------------------------------------
  545.       # * Play Video
  546.       #--------------------------------------------------------------------------
  547.       def play_video(video)
  548.         # Memorize and stop current bgm and bgs
  549.         bgm = RPG::BGM.last
  550.         bgs = RPG::BGS.last
  551.         RPG::BGM.stop
  552.         RPG::BGS.stop
  553.         # Play video
  554.         Video.play(video)
  555.         # Restart bgm and bgs
  556.         bgm.play
  557.         bgs.play
  558.       end
  559.       #--------------------------------------------------------------------------
  560.       # * Update
  561.       #--------------------------------------------------------------------------
  562.       def update
  563.         if $game_map.video != nil
  564.           play_video($game_map.video)
  565.           $game_map.video = nil
  566.           Input.update
  567.         else
  568.           sov_video_update
  569.         end
  570.       end
  571.     end
  572.      
  573.     #==============================================================================
  574.     # ** Scene_Battle
  575.     #==============================================================================
  576.      
  577.     class Scene_Battle
  578.       #--------------------------------------------------------------------------
  579.       # * Alias list
  580.       #--------------------------------------------------------------------------
  581.       alias sov_video_update_battle update unless $@
  582.       alias sov_video_use_item use_item unless $@
  583.       #--------------------------------------------------------------------------
  584.       # * Play Video
  585.       #--------------------------------------------------------------------------
  586.       def play_video(video)
  587.         # Memorize and stop current bgm
  588.         bgm = RPG::BGM.last
  589.         RPG::BGM.stop
  590.         # Play video
  591.         Video.play(video)
  592.         # Restart bgm
  593.         bgm.play
  594.       end
  595.       #--------------------------------------------------------------------------
  596.       # * Execute Action Skill
  597.       #--------------------------------------------------------------------------
  598.       def use_item
  599.         skill = @subject.current_action.item   
  600.         if skill.video.is_a?(Video)
  601.           execute_action_video(skill)
  602.           sov_video_use_item
  603.         else
  604.           sov_video_use_item
  605.         end
  606.       end
  607.       #--------------------------------------------------------------------------
  608.       # * Execute Action Video
  609.       #--------------------------------------------------------------------------
  610.       def execute_action_video(skill)
  611.         br = Graphics.brightness
  612.         120.times { |i| Graphics.brightness = 255 - 255/60 * i; Graphics.update }
  613.         # Play video
  614.         play_video(skill.video)
  615.         # Reset brightness
  616.         Graphics.brightness = br
  617.       end
  618.       #ADDED UPDATE FUNCTION FROM SCENE_MAP TO SCENE_BATTLE
  619.       def update
  620.         if $game_map.video != nil
  621.           play_video($game_map.video)
  622.           $game_map.video = nil
  623.           Input.update
  624.         else
  625.           sov_video_update_battle
  626.         end
  627.       end
  628.      
  629.     end
  630.      
  631.      
  632.      
  633.      
  634.      
  635.     #==============================================================================
  636.     # Pre-Main Processing
  637.     #==============================================================================
  638.      
  639.     unless FileTest.directory?(SOV::Video::DIR_NAME) # If directory doesn't exist.
  640.       Dir.mkdir(SOV::Video::DIR_NAME)                # Make the directory
  641.     end
  642.      
  643.     =begin
  644.     =end

复制代码

评分

参与人数 2星屑 +95 收起 理由
熊喵酱 + 75 认可答案
Jousun + 20 这个和 2楼是一样的吗???

查看全部评分

回复

使用道具 举报

梦石
0
星屑
918
在线时间
213 小时
注册时间
2006-10-8
回帖
237
 楼主| 发表于 2013-9-1 14:44:07 | 显示全部楼层
tseyik 发表于 2013-9-1 12:07

放进去以后执行游戏一闪即退,实在不明白。。。。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部