berka's Video script II reloaded!

berka's Video script II reloaded!


Version: 1.2 # updated 25/02/2009
By: berka

Introduction
This is my ultimate version of video script. I saw that there are so many questions about the video scripts. I tried to make it as simple as possible.

Features
-fullscreen mode
-audio settings
-video resizing
-advanced video types support
-use is easier
-choice of the scene back
-film can be launched in a script or in an event

Screenshots
none

Demo
the demo

Script
rmvx & rmxp Show
  1. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  2. #                            -  Game_Film II - reloaded ^^
  3. #  par berka
  4. #                          www.rpgmakervx-fr.com                                          
  5. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  6. #  Rgss 1&2                  v 1.2
  7. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  8. #                          -Utilisation-
  9. # write in an event, "call script" command
  10. #
  11. # #minimum required:
  12. # [film]                    # essential !
  13. # film = myfilm.avi         # or mpg... name of file to read
  14. #
  15. # #optional configuration, order doesn't matter
  16. # Put 4 coordinates or none!
  17. # x = 12                    # horizontal position
  18. # y = 1                     # vertical position
  19. # w = 150                   # film resizing: width
  20. # h = 150                   # film resizing: height
  21. #
  22. # full = true               # fullscreen or not
  23. # vol = 750                 # between 0 & 1000 audio volume
  24. # bass = 999                # between 0 & 1000 basses volume
  25. # aig = 250                 # between 0 & 1000 trebble volume
  26. # ret = Scene_Map           # return to Scene_XXX when the films ends
  27. # #commands:
  28. # key B to quit, C to pause the film
  29. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  30.  
  31. class Game_Film
  32.   def initialize(hash)
  33.     hash.has_key?(:film) ? film=hash[:film] : return
  34.     hash.has_key?(:x) ? @x=hash[:x]+" " : @x="0"
  35.     hash.has_key?(:y) ? @y=hash[:y]+" " : @y="0"
  36.     hash.has_key?(:w) ? @w=hash[:w]+" " : @w=""
  37.     hash.has_key?(:h) ? @h=hash[:h]+" " : @h=""
  38.     hash.has_key?(:vol) ? @vol=hash[:vol]+" " : @vol="1000"
  39.     hash.has_key?(:bass) ? @bass=hash[:bass]+" " : @bass="1000"
  40.     hash.has_key?(:aig) ? @aig=hash[:aig]+" " : @aig="1000"
  41.     hash.has_key?(:pos) ? @pos="at pos #{hash[:pos].to_i*1000} " : @pos="at pos 0 "
  42.     @ret='$scene='<<hash[:ret]<<'.new' if hash.has_key?(:ret)
  43.     @full=hash[:full] if hash.has_key?(:full)
  44.     @full&&dim_ecran !=[640,480] ? @plee="fullscreen " : @plee=""
  45.     @type=" "
  46.     @type=" type mpegvideo" if File.extname(film)==(".mpg"||".mpeg")
  47.     @type=" type avivideo" if File.extname(film)==".avi"
  48.     @nom='./Films/'+film
  49.     (p "fichier #{@nom} non trouvé";return) if !FileTest.exist?(@nom)
  50.     @film=Win32API.new('winmm','mciSendString','ppll','v')
  51.     lecture
  52.   end
  53.   def handle
  54.     jeu="\0"*256
  55.     ini=Win32API.new('kernel32','GetPrivateProfileStringA','pppplp', 'l')
  56.     ini.call('Game','Title','',jeu,255,".\\Game.ini")
  57.     return Win32API.new('user32','FindWindowEx','llpp','l').call(0,0,nil,jeu.delete!("\0"))
  58.   end
  59.   def lecture
  60.     v,t,status,pause=version,Time.now," "*255,false
  61.     @film.call("open #{@nom} alias FILE#{@type} style child parent "+handle.to_s,0,0,0)
  62.     @film.call("put FILE window at #{@x}#{@y}#{@w}#{@h}",status,255,0)
  63.     @film.call("setaudio File volume to #{@vol}",status,255,0)
  64.     @film.call("setaudio File bass to #{@bass}",status,255,0)
  65.     @film.call("setaudio File trebble to #{@aig}",status,255,0)
  66.     @film.call("play FILE #{@plee} notify",status,255,handle)
  67.     loop{sleep(0.1)
  68.       Input.update
  69.       @film.call("status FILE mode notify",status,255,0)
  70.       break if status.unpack("aaaa")=="stop".split(//)||Input.trigger?(Input::B)
  71.       if Input.trigger?(Input::C)
  72.         if !pause;@film.call("pause FILE notify",status,255,handle);pause=true
  73.         else;@film.call("play FILE #{@plee} notify",status,255,handle);pause=false
  74.         end      
  75.       end
  76.       (t=maj(t))if v=='xp'}
  77.     @film.call("close FILE notify",0,0,handle)
  78.     @ret.nil? ? $scene=Scene_Map.new : eval(@ret)
  79.   end
  80.   def dim_ecran
  81.     lw=Win32API.new('user32','GetSystemMetrics','i','i')
  82.     return lw.call(0),lw.call(1)
  83.   end
  84.   def maj(t)
  85.     (Graphics.update;return Time.now)if t.sec<=Time.now.sec-9||t.min !=Time.now.min
  86.     return t
  87.   end
  88. end
  89. Dir.open("./Films") rescue Dir::mkdir("./Films",0777)
  90. class Game_Interpreter;def eval(script);cmd_eval(script);end;end#rmvx
  91. class Interpreter;def eval(script);cmd_eval(script);end;end#rmxp
  92. def cmd_eval(script)
  93.   if script.include?("[film]")
  94.     hash={}
  95.     script.gsub!("[film]"){}
  96.     list=script.split("\n")
  97.     list.each{|e|e.gsub!(" "){};f=e.split("=");hash[f[0].to_sym]=f[1] if !f[1].nil?}
  98.     Game_Film.new(hash)
  99.   else;return Kernel.eval(script)
  100.   end
  101. end
  102. def version;FileTest.exist?('./Data/scripts.rvdata') ? 'vx': 'xp';end
  103. def call_film(script)
  104.   version=='vx' ? i=Game_Interpreter : i=Interpreter
  105.   i.new.cmd_eval(script)
  106. end
Expand to see the code.


Instructions
puts this script above main and run the game first: a Videos directory will be created !
then add your videos files into.
and call the video with an event (call script) like this:

FAQ
example in an event's call script command
  1. [film]
  2. film = test.avi
  3. aig = 999
  4. bass = 0
Expand to see the code.

in a script:
  1. script=<<__END__
  2.  
  3. [film]
  4. film=test.avi
  5. ret=Scene_Map
  6. full=false
  7.  
  8. __END__
  9. call_film(script)
Expand to see the code.


Compatibility
I really don't know !

Credits and Thanks
Corwin & squall for the basic video script

Terms and Conditions
Free for using, but I need credits. Do not post this script anywhere without my permission !

enjoy,
berka
Cool script, i was testing it a moment ago but im not sure if the sound works as i only got a non sound one. I hope it can also run other video files extension aside from .avi, really rocks. :haha:
It does not work for me. I get an error. Demo please?
:shock: ok...
Ya...aim go to play the demo..
Nice script berkaa
This is nice, well done! Does anyone have performance problems with this? I don't.

Une bonne main d'applaudissements.
Quote:
Une bonne main d'applaudissements.

lol 😀

thanks guys !
I did a video of my own on their, on your demo, the "test" one, but it was just standing there still (the video was frozen in one picture)
sorry, I think I do not understand your issue...

does the video hang ?
you have any sound ?
the video des not play fluently ?
What is your file's format ?
New version: window's hangup killed ! 😀
code cleaned,

best regards,
berka
wheres the script??
Have you tried the demo? 😉
sorry, my demo wasn't updated, it's all right now!

berka

:
the demo
how would you make an intro using the script?
you create a first empty map, width an event which calls the video, and then, you teleport to another map
Your script is pretty cool berka. I like it.
However, your topic doesn't meet the requirements for a Submitted script.
I'd like you to read and follow the guidelines here viewtopic.php?f=11&t=4113 and update your topic please.

Thank you
-Dargor
done.
sorry for the inconvenience.
berka
mmm, berka, I know this man.....
wait a minute ! you'r berka, isn' it ?
well.. I'll speak french with you, this'll be easy.
berka mon ami ! c'est moi Yagami, de rmxpstudio !
Ton script est cool, tu sais. Bah, pour moi j'ai testé la démo, et ça marche trés bien.
If I wanted to add a video before the titles?
Insert this below the video script:

  1. begin
  2.   film = {
  3.     # Name of video file
  4.     :film => 'Name.avi',
  5.     # Video Dimensions & Posiiton
  6.     :x => 'x',
  7.     :y => 'y',
  8.     :w => 'width',
  9.     :h => 'height',
  10.     # Volume, Bass & Trebble
  11.     :vol => 'vol',
  12.     :bass => 'bass',
  13.     :aig => 'treb',
  14.     # For full screen
  15.     :full => true
  16.   }
  17.   Game_Film.new(film)
  18. end
Expand to see the code.


I am not really familiar with this script, but that should be all you need to do.


@berka: Shouldn't that instance be @aig?
  1.     @film.call("setaudio File trebble to #{@bass}",status,255,0)
Expand to see the code.


I could be wrong.
Thanks !
I'll correct the script now !

berka
If I insert a video before the title screen, can I set a button that once pressed skip the video and go to the title screen?
first, you add this in main after 'begin'
  1. hash={"film"=>"my_film.avi"} # settings in hash
  2. game_film=Game_Film.new(hash)
Expand to see the code.

and replace in the script
  1. $scene=Scene_Map.new
Expand to see the code.
line 76
with
  1. $scene=Scene_Title.new
Expand to see the code.


not tested !
berka
Maybe it'll work
If it wont works, put this :

if Input.trigger?(Input::C)
$scene = Scene_Title.new
end

juste after what berka said :

hash={"film"=>"my_film.avi"} # settings in hash
game_film=Game_Film.new(hash)

I think it'll work too (Not tested too)
Nice Nice, Congrats! but i have a challenge!

is it possible to execute a video inside ZTBS?

For example, using Videos for Skills.

pd:
ZTBS is Zenith Tactical Battle System. I hope you Know, I am working on Saint Seiya Tactical game.

Thanks, merci boucoup! Viva la france.
huh ! de rien.

I dont think that this version of script cab do this..... because it returns to Scene_Map .
But, with a litle edite by berka, it can do more.

Let's hope. Espéran
Hey Amine, if you want to write in French, do not make spelling mistakes. Bang! (trop tentant) 😀
I will add a new command, which will select the scene back!

regards,
berka


edited: done.
Hi! I put a big video but he dosnt apear (and no message whit any error)

My video it HD and during 4 min. did it cause a prob?
Why if I upload a file.mov (Quicktime) the game freezes and appears a black screen?
Hi,

first of all I would like to thank you for this script. It's the first one I found that really is working. Great!

But still I have a problem with it. By starting the video using an event, I type in the script "full = true". But when I start the video in the game (the game is also fullscreen) then the window resizes to the resolution of 640x480. I don't know where my mistake is. Can someone help me?

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=60944