Envision, Create, Share

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

Problem with avi script

Hi all,

I recently came across a script that lets you play avi videos in your rmxp game...

Almost everything about it works perfectly... Just that when I press enter to skip the video.... It doesn't skip it. It just stops it. Is there any way to fix this? There are files that are needed to make this work, so if you can't just look at the code and fix it I'll have to email you the files or something.

But yeah, please take a look and see what's up.

Code:
#==============================================================================#

#                                                                 Version 0.3  #

#                         RPG Maker XP Flash Player                            #

#                                                                              #

#  Author: 灼眼的夏娜                     Updated by: Dark_Wolf_Warrior/Dahrkael #

#                                                                              #

#  How to Use:                                                                 #

#                                      Graphics.freeze                         #

#  1. Go to Main Script and add ---->  $flash = Play.new                       #

#                                      $scene = Scene_Title.new                #

#                                                                              #

#  2. Copy the .dll and the .ocx to the game folder                            #

#                                                                              #

#  3. Make a folder called "Flash" in the folder "Graphics" -> Graphics/Flash/ #

#                                                                              #

#  4. To play a flash file use:                                                #

#    $flash.play("file.swf", button)                                           #

#                                                                              #

#    button can be 0 or 1, if 1 you can skip the flash using "Enter"           #

#                                                                              #

#                                                                              #

#                                                                              #

#  Interactive flashes requires RGSS knownledge to make they work              #

#                                                                              #

#  Original Keyb module by HoundNinja                                          #

#                                                                              #

#==============================================================================#

 

 

 

class String

  

  CP_ACP = 0

  CP_UTF8 = 65001

  

  def u2s

    m2w = Win32API.new("kernel32", "MultiByteToWideChar", "ilpipi", "i")

    w2m = Win32API.new("kernel32", "WideCharToMultiByte", "ilpipipp", "i")

    

    len = m2w.call(CP_UTF8, 0, self, -1, nil, 0)

    buf = "\0" * (len*2)

    m2w.call(CP_UTF8, 0, self, -1, buf, buf.size/2)

    

    len = w2m.call(CP_ACP, 0, buf, -1, nil, 0, nil, nil)

    ret = "\0" * len

    w2m.call(CP_ACP, 0, buf, -1, ret, ret.size, nil, nil)

    

    return ret

  end

  

  def s2u

    m2w = Win32API.new("kernel32", "MultiByteToWideChar", "ilpipi", "i")

    w2m = Win32API.new("kernel32", "WideCharToMultiByte", "ilpipipp", "i")

  

    len = m2w.call(CP_ACP, 0, self, -1, nil, 0);

    buf = "\0" * (len*2)

    m2w.call(CP_ACP, 0, self, -1, buf, buf.size/2);

  

    len = w2m.call(CP_UTF8, 0, buf, -1, nil, 0, nil, nil);

    ret = "\0" * len

    w2m.call(CP_UTF8, 0, buf, -1, ret, ret.size, nil, nil);

     

    return ret

  end

 

  def s2u!

    self[0, length] = s2u

  end  

  

  def u2s!

    self[0, length] = u2s

  end

  

end

 

class Bitmap

  

  RtlMoveMemory_pi = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')

  RtlMoveMemory_ip = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i')

 

  def address

    buffer, ad = "xxxx", object_id * 2 + 16

    RtlMoveMemory_pi.call(buffer, ad, 4); ad = buffer.unpack("L")[0] + 8

    RtlMoveMemory_pi.call(buffer, ad, 4); ad = buffer.unpack("L")[0] + 16

    RtlMoveMemory_pi.call(buffer, ad, 4); return buffer.unpack("L")[0]

  end

  

end 

 

class RMFlash

 

    API_NEW           = Win32API.new("RMFlash", "_new", "piil", "l")

    API_UPDATE      = Win32API.new("RMFlash", "_update", "l", "v")

    API_FREE          = Win32API.new("RMFlash", "_free", "l", "v")

    API_PLAYING     = Win32API.new("RMFlash", "_is_playing", "l", "i")

    API_PAUSE         = Win32API.new("RMFlash", "_pause", "l", "v")

    API_RESUME      = Win32API.new("RMFlash", "_resume", "l", "v")

    API_BACK          = Win32API.new("RMFlash", "_back", "l", "v")

    API_REWIND      = Win32API.new("RMFlash", "_rewind", "l", "v")

    API_FORWARD     = Win32API.new("RMFlash", "_forward", "l", "v")

    API_CURFRAME      = Win32API.new("RMFlash", "_cur_frame", "l", "i")

    API_TOTALFRAME  = Win32API.new("RMFlash", "_total_frames", "l", "i")

    API_GOTOFRAME     = Win32API.new("RMFlash", "_goto_frame", "li", "v")

    API_GETLOOP       = Win32API.new("RMFlash", "_get_loop", "l", "i")

    API_SETLOOP       = Win32API.new("RMFlash", "_set_loop", "li", "v")

    API_CLEARALL      = Win32API.new("RMFlash", "_clear_all", "v", "v")

  API_VALID       = Win32API.new("RMFlash", "_valid", "l", "i")

  API_SENDMSG     = Win32API.new("RMFlash", "_send_message", "liii", "l")

    

  CUR_PATH        = Dir.pwd

  

    def self.get_version

 

    end

 

    def self.clear_all

        API_CLEARALL.call

    end

  

  def self.load(name, width, height, v = nil)

    new("#{CUR_PATH}/Graphics/Flash/#{name}".u2s, width, height, v)

  end

  

  attr_reader   :valid

 

    def initialize(flash_name, flash_width, flash_height, viewport = nil)

        @sprite = Sprite.new(viewport)

        @sprite.bitmap = Bitmap.new(flash_width, flash_height)

        @value = API_NEW.call(flash_name, flash_width, flash_height, @sprite.bitmap.address)

        @loop = API_GETLOOP.call(@value) > 0

    @valid = API_VALID.call(@value) > 0

    end

 

    def viewport

        @sprite.viewport

    end

 

    def update

        API_UPDATE.call(@value)

    end

 

    def dispose

        API_FREE.call(@sprite.bitmap.address)

    end

 

    def playing?

        API_PLAYING.call(@value) > 0

    end

 

    def pause

        API_PAUSE.call(@value)

    end

 

    def resume

        API_RESUME.call(@value)

    end

 

    def back

        API_BACK.call(@value)

    end

 

    def rewind

        API_REWIND.call(@value)

    end

 

    def forward

        API_FORWARD.call(@value)

    end

 

    def current_frame

        API_CURFRAME.call(@value)

    end

 

    def total_frames

        API_TOTALFRAME.call(@value)

    end

 

    def goto_frame(goal_frame)

        API_GOTOFRAME.call(@value, goal_frame)

    end

 

    def x

        @sprite.x

    end

 

    def x=(v)

        @sprite.x = v

    end

 

    def y

        @sprite.y

    end

 

    def y=(v)

        @sprite.y = v

    end

 

    def z

        @sprite.z

    end

 

    def z=(v)

        @sprite.z = v

    end

 

    def width

        @sprite.bitmap.width

    end

 

    def height

        @sprite.bitmap.height

    end

 

    def loop?

        @loop

    end

 

    def loop=(v)

        if @loop != v

            @loop = v

            API_SETLOOP.call(@value, v)

        end

    end

  

  def msg_to_flash(msg, wParam, lParam)

    return API_SENDMSG.call(@value, msg, wParam, lParam)

  end

  

  #  例

  WM_MOUSEMOVE  = 0x0200

  

  def make_long(a, b)

    return (a & 0xffff ) | (b & 0xffff) << 16

  end

  

  def on_mouse_move(x, y)

    return msg_to_flash(WM_MOUSEMOVE, 0, make_long(x, y))

  end

 

end

 

module Kernel

 

  alias origin_exit exit unless method_defined? :exit

  

  def exit(*args)

    RMFlash.clear_all

    origin_exit(*args)

  end

  

end

 

module Keyb

  $keys = {}

  $keys["Enter"] = 0x0D

  GetKeyState = Win32API.new("user32","GetAsyncKeyState",['i'],'i')

  module_function 

  def trigger(rkey) 

    GetKeyState.call(rkey) & 0x01 == 1

  end

end

 

class Play

  

  def play(filename, button)

    fondo = Sprite.new

    fondo.bitmap = Bitmap.new(640, 480)

    fondo.bitmap.fill_rect(0, 0, 640, 480, Color.new(0,0,0,255))

    fls = RMFlash.load(filename, 640, 480)

    fls.loop = 1

    fls.z = 9999

    @button = button

    @fr = Graphics.frame_rate

    Graphics.frame_rate = 40

 

    while true

      Graphics.update

      #Input.update

      fls.update

      break if @button == 1 and Keyb.trigger($keys["Enter"]) 

      break if !fls.playing?

      end

    fls.dispose

    Graphics.frame_rate = @fr

    fondo.dispose

  end

end

 

It should be something in there. Whenever I play the video and run it as an event by calling $flash.play("miku.swf", 1) It will stop the vid when I press enter but not end it.

Thanks!
 
You have to make it call $scene = Scene_Map.new right before fls.dispose in class Play. (Or if you want the title scree, you call $scene = Scene_Title.new instead)Just to note, this is a horribly designed script, with very little in the way of legibility and proper commenting. Also, I have to ask. Why are you playing a Vocaloid video?
 
I put the $scene = Scene_Map.new directly above the fls.dispose and it didn't do anything. It still had the video up wherever I stopped it at. The game works but the vid is stuck there.

This is the only script I could find that lets you play avi vids.

Voc-what video? If you're referring to the content of it, I don't know. It's the vid they included. I'm going to change it around to the type of vid I want when I get things going.
 
Lol, I herd u liek vocaloidz... JK, sorry I couldn't help myself.
But I have to note on personal opinion...don't use a video script unlessy ou really need to...not only are they glitchy, their also mostly unsupported too.
 
:(

I don't need to, but I really would like to. It would be awesome to have an intro movie come in, and then have the title of the game show up and transition smoothly into my title screen. Like in Chrono Cross.

I'll just stick with the evented title I have now.
 

Thank you for viewing

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

Discord

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

Content

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