Day.png);">
Apprendre


Vous êtes
nouveau sur
Oniromancie?

Visite guidée
du site


Découvrir
RPG Maker


Apprendre
RPG Maker

Tutoriels
Guides
Making-of

Dans le
Forum

Section Entraide

Scripts: Système de vol pour RPG Maker (...) / Jeux: Onsen RPG - A Tale of Yu / Jeux: Final Destiny / Jeux: puie z / Jeux: Citymaime - Chapitre 1 / Chat

Bienvenue
visiteur !





Désactiver
la neige


publicité RPG Maker!

Statistiques

Liste des
membres


Contact

Mentions légales

324 connectés actuellement

30765482 visiteurs
depuis l'ouverture

2220 visiteurs
aujourd'hui



Barre de séparation

Partenaires

Indiexpo

Akademiya RPG Maker

Blog Alioune Fall

Fairy Tail Constellations

ConsoleFun

Level Up!

Planète Glutko

Tous nos partenaires

Devenir
partenaire



Zeus Video Player 3.0

Permet de lire des vidéo sur RMXP sans bug. Ccompatible avec VX et VX Ace.

Script pour RPG Maker XP
Ecrit par Zeus81
Publié par zeus81 (lui envoyer un message privé)
Signaler un script cassé

❤ 0

Auteur : Zeus81
Logiciel : RPG Maker XP, VX et Ace

Il existe déjà plusieurs scripts pour lire des vidéo sur RMXP mais la petite particularité de celui-ci est qu'il fonctionne aussi en plein écran...
A placer au-dessus de Main.

Version 3.0 (recommandée)

Portion de code : Tout sélectionner

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
# Zeus Video Player v3.0.0 for XP, VX and VXace by Zeus81
# Free for commercial use
# Licence MIT
# Contact : zeusex81@gmail.com
#
#Aliased methods :
#  Graphics::update
#
# How to Use :
#   Video.play( filename, cancellable, stretch )
#   - filename = path of the video file, extension may be omitted on vxace
#                but is needed otherwise for unicode support.
#   - cancellable = false if you don't want to allow the player to stop the video.
#                   :Pause if you want to pause by pressing Enter or Escape.
#                   :Stop if you want to stop by pressing Enter or Escape.
#                   :Menu if you want to pause and open menu which let you choose Resume or Stop.
#                   This option can be omitted and default value is :Menu
#   - stretch = :FitIn if you want the video to be stretched to fit the max screen
#                      surface possible keeping ratio.
#               :FitOut if you want the video to truncate in order to fill the entire
#                       screen but still keeping ratio.
#               :Fill if you want the video to fill the entire screen without keeping ratio.
#               :Center if you want the video to center without ever resizing.
#               This option can be omitted and default value is :FitIn
#   ex : Video.play( "Movies/my video.avi", :Menu, :FitIn )
#   or   Video.play( "Movies/my video.avi" )
#
# Codec choice :
#   I haven't tested all of them but I guess wmv9 (standard) would be a good choice.
#   You can find a list of codecs installed by default on windows here :
#   https://support.microsoft.com/kb/899113
#
# Customizing :
#   You can choose the background image of the player with Video.back_picture = filename,
#   the cancellable :Pause image with Video.pause_picture = filename,
#   and the :Menu images with Video.resume_picture = filename and Video.stop_picture = filename
#   - filename = path of the image which must be in the Pictures folder, extension may be omitted.
#   ex : Video.back_picture = "my video background"
#
# Known bugs :
#  - With some video codecs stretching video doesn't work.
#  - Fullscreen mode is the source of various bugs.
#    You can choose to disable it bellow by settings the NoFullscreen variable to true.
#    The game will automatically quit fullscreen and block it until video has finished playing.
#
# OldAviMode :
#   Just bellow you can enable this mode by setting the variable to true.
#   Advantages :
#     - More stable, no known bugs.
#     - You can use Video.play_to_bitmap
#   Drawbacks :
#     - It can only play avi files.
#     - You must use vfw codecs for video, and windows defaults vfw codecs are very limited.
#       Exhaustive list : MS RLE, MS Video 1, Cinepak, i420, iyuv. And they all sucks.
#       Any other codec will require to be installed on user side to ensure that it's supported.
#       But if it's not a problem then you can find very nice vfw codecs on the internet, eg x264vfw.
#     - You must use acm codecs for audio.
#       Windows defaults : mp3, pcm.
#       You can also find better codecs like aac acm.
 
module Video
  OldAviMode = false
  NoFullscreen = false
  CancelKeys = [Input::B, Input::C]
end
 
$imported ||= {}
$imported[:Zeus_Video_Player] = __FILE__
 
def xp?() false end; alias vx? xp?; alias vxace? xp?
RUBY_VERSION == '1.8.1' ? defined?(Hangup) ?
def xp?() true end : def vx?() true end : def vxace?() true end
 
$imported[:Zeus_Frame_Dropped] ||= __FILE__
if $imported[:Zeus_Frame_Dropped] == __FILE__
  module Graphics #2.0.0
    unless @frame_time
      @frame_time, @frame_dropped = Time.now, false
    end
    class << self
      attr_accessor :frame_time, :frame_dropped
      alias zeus_frame_dropped_update update unless method_defined?(:zeus_frame_dropped_update)
      def update
        @frame_time = Time.now
        zeus_frame_dropped_update
        @frame_dropped = Time.now - @frame_time < 0.005
        nil
      end
    end
  end
end
 
class << Graphics
  def width()  640 end unless method_defined?(:width)
  def height() 480 end unless method_defined?(:height)
  def hwnd() @hwnd ||= Zeus::DLL.User32.FindWindow('RGSS Player', nil) end
  alias zeus_video_update update unless method_defined?(:zeus_video_update)
  def update
    zeus_video_update
    Video.update
  end
end
 
Cache = RPG::Cache if xp?
 
class Object
  alias msgbox   print
  alias msgbox_p p
  def instance_variable_defined?(var) instance_variables.include?(var) end
end unless vxace?
 
class String
  alias getbyte  []
  alias setbyte  []=
  alias bytesize size
  def start_with?(*args)
    args.any? {|str| str.is_a?(String) and index(str) == 0}
  end
  def end_with?(*args)
    args.any? {|str| str.is_a?(String) and rindex(str) == size-str.size}
  end
end unless vxace?
 
class Bitmap
  def last_row_address
    Zeus::DLL.Kernel32.RtlMoveMemory(buf=[0].pack('L'), __id__*2+16, 4)
    Zeus::DLL.Kernel32.RtlMoveMemory(buf, buf.unpack('L')[0]+8 , 4)
    Zeus::DLL.Kernel32.RtlMoveMemory(buf, buf.unpack('L')[0]+16, 4)
    buf.unpack('L')[0]
  end
end
 
module Sound
  def self.play_ok()     $game_system.se_play($data_system.decision_se) end
  def self.play_cancel() $game_system.se_play($data_system.cancel_se)   end
  def self.play_cursor() $game_system.se_play($data_system.cursor_se)   end
  def self.play_buzzer() $game_system.se_play($data_system.buzzer_se)   end
end if xp?
 
module Zeus
  class DLL #2.0.0
    def initialize(dll)
      @dll = dll.to_s.dup
    end
    def [](api_name, var_name=api_name)
      var_name = "@#{var_name}" unless var_name.to_s.start_with?('@')
      if instance_variable_defined?(var_name)
      then instance_variable_get(var_name)
      else create_api!(api_name, var_name)
      end
    rescue raise($!, $!.message, caller(vxace? ? 2 : 1))
    end
    def create_api!(api_name, var_name=api_name)
      var_name = "@#{var_name}" unless var_name.to_s.start_with?('@')
      function, types = *api_name.split('§', 2)
      api = Win32API.new(@dll, function, types, 'i') rescue
      api = Win32API.new("System/#@dll", function, types, 'i') rescue
      api = nil
      instance_variable_set(var_name, api)
    rescue raise($!, $!.message, caller(vxace? ? 2 : 1))
    end
    def create_method!(method, args, api_name=nil)
      var_name, args_names, args_convert = method.to_s[/\w+/], '', ''
      var_name << '§' unless args.empty?
      args.each_with_index do |arg,id|
        args_names << "#{', ' if id > 0}arg#{id}"
        case arg
        when Float; args_convert << "arg#{id} = [arg#{id}].pack('f').unpack('L')[0]\n"
        when TrueClass, FalseClass; args_convert << "arg#{id} = arg#{id} ? 1 : 0\n"
        end
        case arg
        when Numeric, TrueClass, FalseClass; var_name << 'i'
        when String , NilClass             ; var_name << 'p'
        else var_name << (arg.respond_to?(:to_int) ? 'i' : 'p')
        end
      end
      instance_eval("
      def #{method}(#{args_names})
        #{args_convert}
        @#{var_name}.call(#{args_names})#{' != 0' if method.to_s.end_with?('?')}
      rescue raise($!, $!.message, caller(vxace? ? 2 : 1))
      end")
      create_api!(api_name || var_name, var_name)
    rescue raise($!, $!.message, caller(vxace? ? 2 : 1))
    end
    def method_missing(method, *args)
      create_method!(method, args)
      send(method, *args)
    rescue raise($!, $!.message, caller(vxace? ? 2 : 1))
    end
    def self.create_dll!(dll_name, var_name=dll_name)
      var_name = var_name.to_s[1..-1] if var_name.to_s.start_with?('@')
      instance_eval("class << self; attr_reader :#{var_name} end")
      instance_variable_set("@#{var_name}", new(dll_name))
    rescue raise($!, $!.message, caller(vxace? ? 2 : 1))
    end
    def self.method_missing(method, *args)
      create_dll!(method)
      send(method, *args)
    rescue raise($!, $!.message, caller(vxace? ? 2 : 1))
    end
  end
  module Encode #1.6.0
    CodePages = {
      'ANSI'=>0, 'OEM'=>1, 'MAC'=>2, 'THREAD_ANSI'=>3, 'SYMBOL'=>42,
      'WINDOWS874'=>874, 'SHIFT_JIS'=>932, 'BIG5'=>950, 'WINDOWS1250'=>1250,
      'WINDOWS1251'=>1251, 'WINDOWS1252'=>1252, 'WINDOWS1253'=>1253,
      'WINDOWS1254'=>1254, 'WINDOWS1255'=>1255, 'WINDOWS1256'=>1256,
      'WINDOWS1257'=>1257, 'WINDOWS1258'=>1258, 'US_ASCII'=>20127,
      'ISO8859_1'=>28591, 'ISO8859_2'=>28592, 'ISO8859_3'=>28593,
      'ISO8859_4'=>28594, 'ISO8859_5'=>28595, 'ISO8859_6'=>28596,
      'ISO8859_7'=>28597, 'ISO8859_8'=>28598, 'ISO8859_9'=>28599,
      'ISO8859_13'=>28603, 'ISO8859_15'=>28605, 'ISO8859_8I'=>38598,
      'ISO2022_JP'=>50220, 'ISO2022_KR'=>50225, 'ISO2022_CN'=>50227,
      'EUC_JP'=>51932, 'EUC_CN'=>51936, 'EUC_KR'=>51949, 'GB2312'=>52936,
      'UTF7'=>65000, 'UTF8'=>65001, 'UTF16'=>-1
    }
    def self.encode(str, from, to, dchar=nil, dflag=nil)
      from, to = CodePages[from.upcase], CodePages[to.upcase]
      if from != -1
        l = DLL.Kernel32.MultiByteToWideChar(from, 0, str, str.bytesize, nil, 0)
        utf16 = [].pack("x#{l*2}")
        DLL.Kernel32.MultiByteToWideChar(from, 0, str, str.bytesize, utf16, l)
      else utf16 = str
      end
      if to != -1
        l = DLL.Kernel32.WideCharToMultiByte(to, 0, utf16, utf16.bytesize/2, nil, 0, dchar, dflag)
        str = [].pack("x#{l}")
        DLL.Kernel32.WideCharToMultiByte(to, 0, utf16, utf16.bytesize/2, str, l, dchar, dflag)
      else str = utf16
      end
      case to
      when 20127; str.force_encoding('US-ASCII')
      when 65001; str.force_encoding('UTF-8')
      when    -1; str.force_encoding('UTF-16LE')
      end if vxace?
      str
    rescue raise($!, $!.message, caller(vxace? ? 2 : 1))
    end
    def self.encode!(str, from, to, dchar=nil, dflag=nil)
      str.replace(encode(str, from, to, dchar, dflag))
    rescue raise($!, $!.message, caller(vxace? ? 2 : 1))
    end
    def self.method_missing(method, str, *options)
      method = method.to_s.upcase
      ex_mark = method.slice!('!')
      from, to = *method.split('_TO_', 2)
      send("encode#{ex_mark}", str, from, to, *options)
    rescue raise($!, $!.message, caller(vxace? ? 2 : 1))
    end
  end
  module OS #1.1.0
    def self.version
      ver = DLL.Kernel32.GetVersion
      (ver&0xFF)*10 + (ver>>8&0xFF)
    end
    def self.windows2000_or_greater?()  version >=  5_0 end
    def self.windowsXP_or_greater?()    version >=  5_1 end
    def self.windowsXP_64_or_greater?() version >=  5_2 end
    def self.windowsVista_or_greater?() version >=  6_0 end
    def self.windows7_or_greater?()     version >=  6_1 end
    def self.windows8_or_greater?()     version >=  6_2 end
    def self.windows8_1_or_greater?()   version >=  6_3 end
    def self.windows10_or_greater?()    version >= 10_0 end
    def self.windows2000?()  version ==  5_0 end
    def self.windowsXP?()    version ==  5_1 end
    def self.windowsXP_64?() version ==  5_2 end
    def self.windowsVista?() version ==  6_0 end
    def self.windows7?()     version ==  6_1 end
    def self.windows8?()     version ==  6_2 end
    def self.windows8_1?()   version ==  6_3 end
    def self.windows10?()    version == 10_0 end
    def self.wow64?
      process = DLL.Kernel32.GetCurrentProcess || -1
      DLL.Kernel32.IsWow64Process(process, bool=[].pack('x4'))
      bool.unpack('L')[0] == 1
    end
    def self.dwm_composition_enabled?
      DLL.Dwmapi.DwmIsCompositionEnabled(bool=[].pack('x4'))
      bool.unpack('L')[0] == 1
    end
    def self.dwm_enable_composition(bool)
      DLL.Dwmapi.DwmEnableComposition(bool)
    end
    def self.documents_path
      DLL.Shell32.SHGetFolderPathW(0, 5, 0, 0, path=[].pack('x520'))#CSIDL_MYDOCUMENTS, SHGFP_TYPE_CURRENT
      path = Encode.utf16_to_utf8(path)
      path[0, path.index("\0")]
    end
    def self.create_directory(path)
      DLL.Kernel32.CreateDirectoryW(Zeus::Encode.utf8_to_utf16("#{path}\0"), nil)
    end
  end
end
 
module Video
  unless @buffer
    @buffer, @back_picture, @pause_picture, @resume_picture, @stop_picture, @no_fullscreen =
    [].pack('x1024'), '', '', '', '', false
  end
  class << self
    attr_accessor :back_picture, :pause_picture, :resume_picture, :stop_picture, :no_fullscreen
    def play(filename, cancellable=:Menu, stretch=:FitIn)
      init_data_system if cancellable and cancellable != :Stop
      quit_fullscreen if @no_fullscreen = NoFullscreen
      if $imported[:Zeus_Fullscreen]
        Fullscreen.video = true
        Fullscreen.update_window(Fullscreen.mode != 0)
      end
      create_back_sprite
      close
      wait while cancel_trigger? if cancellable
      open(filename, 0, false) and playback(filename, cancellable, stretch)
      wait while cancel_trigger? if cancellable
    ensure
      @no_fullscreen = false
      if $imported[:Zeus_Fullscreen]
        Fullscreen.video = false
        Fullscreen.update_window(Fullscreen.mode != 0)
      end
      close
      dispose_back_sprite
    end
    def play_to_bitmap(filename, bitmap, repeat=true)
      return unless OldAviMode and Zeus::OS.windowsVista_or_greater?
      close
      @hwnd = Zeus::DLL.User32.CreateWindowEx(0x08000000 | 0x00000080,#WS_EX_NOACTIVATE | WS_EX_TOOLWINDOW
                  'Static', nil, 0x10000000 | 0x80000000 | 0x0000000D,#WS_VISIBLE | WS_POPUP | SS_OWNERDRAW
                  0, 0, 0, 0, 0, 0, 0, nil)
      return close unless open(filename, 0, repeat)
      mci_silent("where ZeusVideoPlayer source")
      _, _, w, h = *mci_result.split(' ', 4).map! {|s| s.to_i}
      @bitmap = bitmap
      exstyle = Zeus::DLL.User32.GetWindowLong(@hwnd, -20)#GWL_EXSTYLE
      Zeus::DLL.User32.SetWindowLong(@hwnd, -20, exstyle | 0x00080000)#WS_EX_LAYERED
      Zeus::DLL.User32.SetLayeredWindowAttributes(@hwnd, 0, 0, 2)#LWA_ALPHA
      Zeus::DLL.User32.SetWindowPos(@hwnd, 1,#HWND_BOTTOM
                          0, 0, w, h, 2 | 16)#SWP_NOMOVE | SWP_NOACTIVATE
      Zeus::DLL.User32.SetActiveWindow(Graphics.hwnd)
      hdc  = Zeus::DLL.User32.GetDC(@hwnd)
      @hdc = Zeus::DLL.Gdi32.CreateCompatibleDC(hdc)
      @hbm = Zeus::DLL.Gdi32.CreateCompatibleBitmap(hdc, @bitmap.width, @bitmap.height)
      Zeus::DLL.User32.ReleaseDC(@hwnd, hdc)
      update
    end
    def update
      close if @bitmap and (@bitmap.disposed? or stopped?)
      return if !@bitmap or Graphics.frame_dropped
      info = [40,@bitmap.width,@bitmap.height,1,32].pack('Ll2S2x24')
      hdc  = Zeus::DLL.User32.GetDC(@hwnd)
      obj  = Zeus::DLL.Gdi32.SelectObject(@hdc, @hbm)
      Zeus::DLL.User32.GetClientRect(@hwnd, @buffer)
      w, h = *@buffer.unpack('x8L2')
      Zeus::DLL.Gdi32.BitBlt(@hdc, 0, 0, w, h, hdc, 0, 0, 0x00CC0020)#SRCCOPY
      Zeus::DLL.Gdi32.GetDIBits(@hdc, @hbm, 0, @bitmap.height, @bitmap.last_row_address, info, 0)#DIB_RGB_COLORS
      Zeus::DLL.Gdi32.SelectObject(@hdc, obj)
      Zeus::DLL.User32.ReleaseDC(@hwnd, hdc)
      @bitmap.fill_rect(0, 0, 0, 0, Color.new(0,0,0,0)) # set updated flag
      nil
    end
    def stop()     mci_silent("stop ZeusVideoPlayer")                                end
    def pause()    mci_silent("pause ZeusVideoPlayer")                               end
    def resume()   mci_silent("resume ZeusVideoPlayer")                              end
    def mode()     mci_silent("status ZeusVideoPlayer mode")     and mci_result      end
    def length()   mci_silent("status ZeusVideoPlayer length")   and mci_result.to_i end
    def position() mci_silent("status ZeusVideoPlayer position") and mci_result.to_i end
    def playing?() mode == 'playing'                                                 end
    def paused?()  mode == 'paused'                                                  end
    def stopped?() mode == 'stopped'                                                 end
    def wait(frame=1)
      frame.times do
        Graphics.update
        Graphics.frame_count -= 1
        Input.update
      end
      nil
    end
    def init_data_system
      if xp?
        $data_system ||= load_data("Data/System.rxdata")
        $game_system ||= Game_System.new
      elsif vx?
        $data_system ||= load_data("Data/System.rvdata")
      else
        $data_system ||= load_data("Data/System.rvdata2")
      end
      nil
    end
    def rgss_fullscreen?
      exstyle = Zeus::DLL.User32.GetWindowLong(Graphics.hwnd, -20)#GWL_EXSTYLE
      exstyle & 0x00000008 != 0#WS_EX_TOPMOST
    end
    def quit_fullscreen
      if rgss_fullscreen?
        inputs = [1,18,0, 1,13,0, 1,13,2, 1,18,2].pack('LSx2Lx16'*4)
        Zeus::DLL.User32.SendInput(4, inputs, 28)
        wait(10)
      end
    end
    def create_back_sprite
      @back_sprite = Sprite.new
      @back_sprite.z = 0xFFFF
      if @back_picture.empty?
        @back_sprite.bitmap = Bitmap.new(1, 1)
        @back_sprite.bitmap.set_pixel(0, 0, Color.new(0,0,0))
      else
        @back_sprite.bitmap = Cache.picture(@back_picture)
      end
      @back_sprite.zoom_x = Graphics.width  / @back_sprite.bitmap.width.to_f
      @back_sprite.zoom_y = Graphics.height / @back_sprite.bitmap.height.to_f
      Graphics.transition(0)
      Graphics.frame_reset
    end
    def dispose_back_sprite
      @back_sprite.bitmap.dispose if @back_sprite and @back_sprite.bitmap
      @back_sprite.dispose if @back_sprite
      @back_sprite = nil
    end
    def mci(command)
      error = mci_silent(command)
      return true if error == 0
      Zeus::DLL.Winmm.mciGetErrorStringW(error, @buffer, @buffer.bytesize/2)
      msgbox(mci_result, "\nCommand : ", command)
      return false
    end
    def mci_silent(command)
      command = Zeus::Encode.utf8_to_utf16("#{command}\0")
      Zeus::DLL.Winmm.mciSendStringW(command, @buffer, @buffer.bytesize/2, Graphics.hwnd)
    end
    def mci_result
      str = Zeus::Encode.utf16_to_utf8(@buffer)
      str[0, str.index("\0")]
    end
    def open(filename, pos, repeat)
      filename = Dir["#{filename}.*"][0] || filename
      type = OldAviMode ? 'AVIVideo' : 'MPEGVideo'
      mci("open \"#{filename}\" type #{type} alias ZeusVideoPlayer") and
      mci("window ZeusVideoPlayer handle #{@hwnd || Graphics.hwnd}") and
      mci("play ZeusVideoPlayer from #{pos} #{'repeat' if repeat}")
    end
    def close
      stop
      if !OldAviMode and rgss_fullscreen?
        mci_silent("window ZeusVideoPlayer handle 0")
        mci_silent("status ZeusVideoPlayer window handle")
        Zeus::DLL.User32.DestroyWindow(mci_result.to_i)
      end
      mci_silent("close ZeusVideoPlayer")
      Zeus::DLL.User32.DestroyWindow(@hwnd) if @hwnd
      Zeus::DLL.Gdi32.DeleteObject(@hbm) if @hbm
      Zeus::DLL.Gdi32.DeleteDC(@hdc) if @hdc
      @bitmap = @hwnd = @hbm = @hdc = nil
    end
    def resize(stretch)
      wait
      mci_silent("where ZeusVideoPlayer source")
      _, _, w, h = *mci_result.split(' ', 4).map! {|s| s.to_i}
      Zeus::DLL.User32.GetClientRect(Graphics.hwnd, @buffer)
      client_w, client_h = *@buffer.unpack('x8L2')
      case stretch
      when :Center;
      when :FitIn ; w, h = client_w, client_w * h / w
                    h, w = client_h, client_h * w / h if h > client_h
      when :FitOut; w, h = client_w, client_w * h / w
                    h, w = client_h, client_h * w / h if h < client_h
      else          w, h = client_w, client_h
      end
      x, y = (client_w-w)/2, (client_h-h)/2
      mci_silent("put ZeusVideoPlayer destination at #{x} #{y} #{w} #{h-1}")#bugfix cropped window
      mci_silent("put ZeusVideoPlayer destination at #{x} #{y} #{w} #{h}")
      nil
    end
    def playback(filename, cancellable, stretch)
      fullscreen, focus = rgss_fullscreen?, false
      loop do
        Zeus::DLL.User32.GetMessage(@buffer, 0, 0, 0)
        Zeus::DLL.User32.DefWindowProc(*msg = @buffer.unpack('L4'))
        if focus != (Zeus::DLL.User32.GetForegroundWindow == Graphics.hwnd)
          focus = !focus
          focus ? resume : pause
          resize(stretch)
        end
        next unless focus
        if !OldAviMode and fullscreen != rgss_fullscreen?
          fullscreen, pos = !fullscreen, position
          close
          wait(10)
          break unless open(filename, pos, false)
          resize(stretch)
        end
        Input.update
        if stopped? or position >= length
          break
        elsif cancellable and cancel_trigger?
          case cancellable
          when :Stop ; break
          when :Pause; pause_menu
          else         cancel_menu
          end
          resize(stretch)
        elsif $imported[:Zeus_Fullscreen] and
          (Fullscreen.inputs.any? {|input,| input.call} or
           Fullscreen.zoom.zero? != Fullscreen.maximized?)
        then
          resize(stretch)
        end
        case msg[1]
        when 0x0012 #WM_QUIT
          exit
        when 0x0100, 0x0104 #WM_KEYDOWN, WM_SYSKEYDOWN
          if msg[3][30] == 0 and (msg[1] == 0x0104 ? #trigger?
            (!@no_fullscreen and msg[2] == 0x0D) : #ALT + VK_RETURN
            (msg[2] == 0x70 or msg[2] == 0x7B)) #VK_F1 or VK_F12
          then
            pause
            Zeus::DLL.User32.PostMessage(*msg)
            wait(10)
            resume
            resize(stretch)
          end
        end
      end
      nil
    end
    if xp?
      alias anti_hangup_playback playback
      def playback(cancellable, stretch)
        anti_hangup_playback(filename, cancellable, stretch)
      rescue Hangup
        retry
      end
    end
    def cancel_trigger?
      CancelKeys.any? {|k| Input.trigger?(k)}
    end
    def cancel_menu
      Sound.play_ok
      pause
      sprite = Sprite.new
      sprite.z = @back_sprite.z + 1
      if @resume_picture.empty?
        resume_bmp = Bitmap.new(Graphics.width, Graphics.height)
        resume_bmp.font.size = 64
        resume_bmp.draw_text(0, 0, Graphics.width/2, Graphics.height, 'Resume', 1)
        resume_bmp.font.color.alpha /= 2
        resume_bmp.draw_text(Graphics.width/2, 0, Graphics.width/2, Graphics.height, 'Stop', 1)
      else
        sprite.bitmap = Cache.picture(@resume_picture)
      end
      if @stop_picture.empty?
        stop_bmp = Bitmap.new(Graphics.width, Graphics.height)
        stop_bmp.font.size = 64
        stop_bmp.draw_text(Graphics.width/2, 0, Graphics.width/2, Graphics.height, 'Stop', 1)
        stop_bmp.font.color.alpha /= 2
        stop_bmp.draw_text(0, 0, Graphics.width/2, Graphics.height, 'Resume', 1)
      else
        sprite.bitmap = Cache.picture(@stop_picture)
      end
      sprite.bitmap = resume_bmp
      cancel = false
      wait while cancel_trigger?
      loop do
        Graphics.update
        Input.update
        if [Input::DOWN, Input::LEFT, Input::RIGHT, Input::UP].any? {|k| Input.trigger?(k)}
          Sound.play_cursor
          cancel = !cancel
          sprite.bitmap = cancel ? stop_bmp : resume_bmp
        elsif Input.trigger?(Input::B)
          Sound.play_cancel
          cancel = false
          break
        elsif Input.trigger?(Input::C)
          Sound.play_ok
          break
        end
      end
      resume_bmp.dispose
      stop_bmp.dispose
      sprite.dispose
      wait while cancel_trigger?
      cancel ? stop : resume
      nil
    end
    def pause_menu
      Sound.play_ok
      pause
      sprite = Sprite.new
      sprite.z = @back_sprite.z + 1
      if @pause_picture.empty?
        sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)
        sprite.bitmap.font.size = 64
        sprite.bitmap.draw_text(sprite.bitmap.rect, 'Pause', 1)
      else
        sprite.bitmap = Cache.picture(@pause_picture)
      end
      wait while cancel_trigger?
      loop do
        Graphics.update
        Input.update
        if cancel_trigger?
          Sound.play_cancel
          break
        end
      end
      sprite.bitmap.dispose
      sprite.dispose
      wait while cancel_trigger?
      resume
      nil
    end
  end
end



Version 2.3 (archive)

Spoiler (cliquez pour afficher)



Version 1.0 (archive)

Spoiler (cliquez pour afficher)




Mis à jour le 29 décembre 2020.






zeus81 - posté le 27/03/2014 à 16:39:18 (11071 messages postés)

❤ 0

Mise à jour : https://www.dropbox.com/s/q933du4ix2r0cep/Zeus%20Video%20Player.rb
Log change v2.1 :
- compatibilité VX.
- compatibilité VXace (ça remplace le player par défaut).
- la vidéo est mise en pause quand le jeu perd le focus.
- support des noms de fichiers unicodes.
- on peut utiliser F1 et F12 comme Alt+Enter pendant une vidéo.
- meilleure compatibilité avec Fullscreen++
- messages d'erreurs plus précis.
- on peut choisir une image de fond pour le player (dans le cas où la vidéo ne remplit pas toute la fenêtre).
L'image doit s'appeler "ZeusVideoPlayer" et se trouver dans le dossier Pictures, elle sera chargée automatiquement si trouvée.
- on peut lire tous types de fichiers (plus seulement les avi).
Cela dit ça peut créer quelques bugs liés au mode plein écran.
J'ai rajouté une option ZVP_OldAviMode pour rétablir le fonctionnement de la v1.
- bugs divers corrigés.


Kreiss - posté le 25/10/2014 à 18:42:37 (46 messages postés)

❤ 0

C'est un très bon script, tout fonctionne très bien.

Seul problème, c'est qu'une fois le jeu crypter avec le dossier vidéo dans graphics.
Le script ne le trouve plus...
Il y a un moyen de régler le problème sans devoir déplacer le dossier vidéo à la racine ?


zeus81 - posté le 26/10/2014 à 04:12:24 (11071 messages postés)

❤ 0

Non, il ne faut simplement pas mettre les vidéos dans les dossiers Graphics et Data.
Ça sera pas crypté mais tant pis, c'est déjà le cas des Audios.


Gari - posté le 29/12/2020 à 20:32:42 (5901 messages postés) - honor

❤ 0

Quand y en a plus, y en a encore...

Version 3.0 du script, qui ne corrige pas le bug de plein écran sur certains ordinateurs, mais force le passage en fenêtré lorsqu'une vidéo joue :

Portion de code : Tout sélectionner

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
# Zeus Video Player v3.0.0 for XP, VX and VXace by Zeus81
# Free for commercial use
# Licence MIT
# Contact : zeusex81@gmail.com
#
#Aliased methods :
#  Graphics::update
#
# How to Use :
#   Video.play( filename, cancellable, stretch )
#   - filename = path of the video file, extension may be omitted on vxace
#                but is needed otherwise for unicode support.
#   - cancellable = false if you don't want to allow the player to stop the video.
#                   :Pause if you want to pause by pressing Enter or Escape.
#                   :Stop if you want to stop by pressing Enter or Escape.
#                   :Menu if you want to pause and open menu which let you choose Resume or Stop.
#                   This option can be omitted and default value is :Menu
#   - stretch = :FitIn if you want the video to be stretched to fit the max screen
#                      surface possible keeping ratio.
#               :FitOut if you want the video to truncate in order to fill the entire
#                       screen but still keeping ratio.
#               :Fill if you want the video to fill the entire screen without keeping ratio.
#               :Center if you want the video to center without ever resizing.
#               This option can be omitted and default value is :FitIn
#   ex : Video.play( "Movies/my video.avi", :Menu, :FitIn )
#   or   Video.play( "Movies/my video.avi" )
#
# Codec choice :
#   I haven't tested all of them but I guess wmv9 (standard) would be a good choice.
#   You can find a list of codecs installed by default on windows here :
#   https://support.microsoft.com/kb/899113
#
# Customizing :
#   You can choose the background image of the player with Video.back_picture = filename,
#   the cancellable :Pause image with Video.pause_picture = filename,
#   and the :Menu images with Video.resume_picture = filename and Video.stop_picture = filename
#   - filename = path of the image which must be in the Pictures folder, extension may be omitted.
#   ex : Video.back_picture = "my video background"
#
# Known bugs :
#  - With some video codecs stretching video doesn't work.
#  - Fullscreen mode is the source of various bugs.
#    You can choose to disable it bellow by settings the NoFullscreen variable to true.
#    The game will automatically quit fullscreen and block it until video has finished playing.
#
# OldAviMode :
#   Just bellow you can enable this mode by setting the variable to true.
#   Advantages :
#     - More stable, no known bugs.
#     - You can use Video.play_to_bitmap
#   Drawbacks :
#     - It can only play avi files.
#     - You must use vfw codecs for video, and windows defaults vfw codecs are very limited.
#       Exhaustive list : MS RLE, MS Video 1, Cinepak, i420, iyuv. And they all sucks.
#       Any other codec will require to be installed on user side to ensure that it's supported.
#       But if it's not a problem then you can find very nice vfw codecs on the internet, eg x264vfw.
#     - You must use acm codecs for audio.
#       Windows defaults : mp3, pcm.
#       You can also find better codecs like aac acm.
 
module Video
  OldAviMode = false
  NoFullscreen = false
  CancelKeys = [Input::B, Input::C]
end
 
$imported ||= {}
$imported[:Zeus_Video_Player] = __FILE__
 
def xp?() false end; alias vx? xp?; alias vxace? xp?
RUBY_VERSION == '1.8.1' ? defined?(Hangup) ?
def xp?() true end : def vx?() true end : def vxace?() true end
 
$imported[:Zeus_Frame_Dropped] ||= __FILE__
if $imported[:Zeus_Frame_Dropped] == __FILE__
  module Graphics #2.0.0
    unless @frame_time
      @frame_time, @frame_dropped = Time.now, false
    end
    class << self
      attr_accessor :frame_time, :frame_dropped
      alias zeus_frame_dropped_update update unless method_defined?(:zeus_frame_dropped_update)
      def update
        @frame_time = Time.now
        zeus_frame_dropped_update
        @frame_dropped = Time.now - @frame_time < 0.005
        nil
      end
    end
  end
end
 
class << Graphics
  def width()  640 end unless method_defined?(:width)
  def height() 480 end unless method_defined?(:height)
  def hwnd() @hwnd ||= Zeus::DLL.User32.FindWindow('RGSS Player', nil) end
  alias zeus_video_update update unless method_defined?(:zeus_video_update)
  def update
    zeus_video_update
    Video.update
  end
end
 
Cache = RPG::Cache if xp?
 
class Object
  alias msgbox   print
  alias msgbox_p p
  def instance_variable_defined?(var) instance_variables.include?(var) end
end unless vxace?
 
class String
  alias getbyte  []
  alias setbyte  []=
  alias bytesize size
  def start_with?(*args)
    args.any? {|str| str.is_a?(String) and index(str) == 0}
  end
  def end_with?(*args)
    args.any? {|str| str.is_a?(String) and rindex(str) == size-str.size}
  end
end unless vxace?
 
class Bitmap
  def last_row_address
    Zeus::DLL.Kernel32.RtlMoveMemory(buf=[0].pack('L'), __id__*2+16, 4)
    Zeus::DLL.Kernel32.RtlMoveMemory(buf, buf.unpack('L')[0]+8 , 4)
    Zeus::DLL.Kernel32.RtlMoveMemory(buf, buf.unpack('L')[0]+16, 4)
    buf.unpack('L')[0]
  end
end
 
module Sound
  def self.play_ok()     $game_system.se_play($data_system.decision_se) end
  def self.play_cancel() $game_system.se_play($data_system.cancel_se)   end
  def self.play_cursor() $game_system.se_play($data_system.cursor_se)   end
  def self.play_buzzer() $game_system.se_play($data_system.buzzer_se)   end
end if xp?
 
module Zeus
  class DLL #2.0.0
    def initialize(dll)
      @dll = dll.to_s.dup
    end
    def [](api_name, var_name=api_name)
      var_name = "@#{var_name}" unless var_name.to_s.start_with?('@')
      if instance_variable_defined?(var_name)
      then instance_variable_get(var_name)
      else create_api!(api_name, var_name)
      end
    rescue raise($!, $!.message, caller(vxace? ? 2 : 1))
    end
    def create_api!(api_name, var_name=api_name)
      var_name = "@#{var_name}" unless var_name.to_s.start_with?('@')
      function, types = *api_name.split('§', 2)
      api = Win32API.new(@dll, function, types, 'i') rescue
      api = Win32API.new("System/#@dll", function, types, 'i') rescue
      api = nil
      instance_variable_set(var_name, api)
    rescue raise($!, $!.message, caller(vxace? ? 2 : 1))
    end
    def create_method!(method, args, api_name=nil)
      var_name, args_names, args_convert = method.to_s[/\w+/], '', ''
      var_name << '§' unless args.empty?
      args.each_with_index do |arg,id|
        args_names << "#{', ' if id > 0}arg#{id}"
        case arg
        when Float; args_convert << "arg#{id} = [arg#{id}].pack('f').unpack('L')[0]\n"
        when TrueClass, FalseClass; args_convert << "arg#{id} = arg#{id} ? 1 : 0\n"
        end
        case arg
        when Numeric, TrueClass, FalseClass; var_name << 'i'
        when String , NilClass             ; var_name << 'p'
        else var_name << (arg.respond_to?(:to_int) ? 'i' : 'p')
        end
      end
      instance_eval("
      def #{method}(#{args_names})
        #{args_convert}
        @#{var_name}.call(#{args_names})#{' != 0' if method.to_s.end_with?('?')}
      rescue raise($!, $!.message, caller(vxace? ? 2 : 1))
      end")
      create_api!(api_name || var_name, var_name)
    rescue raise($!, $!.message, caller(vxace? ? 2 : 1))
    end
    def method_missing(method, *args)
      create_method!(method, args)
      send(method, *args)
    rescue raise($!, $!.message, caller(vxace? ? 2 : 1))
    end
    def self.create_dll!(dll_name, var_name=dll_name)
      var_name = var_name.to_s[1..-1] if var_name.to_s.start_with?('@')
      instance_eval("class << self; attr_reader :#{var_name} end")
      instance_variable_set("@#{var_name}", new(dll_name))
    rescue raise($!, $!.message, caller(vxace? ? 2 : 1))
    end
    def self.method_missing(method, *args)
      create_dll!(method)
      send(method, *args)
    rescue raise($!, $!.message, caller(vxace? ? 2 : 1))
    end
  end
  module Encode #1.6.0
    CodePages = {
      'ANSI'=>0, 'OEM'=>1, 'MAC'=>2, 'THREAD_ANSI'=>3, 'SYMBOL'=>42,
      'WINDOWS874'=>874, 'SHIFT_JIS'=>932, 'BIG5'=>950, 'WINDOWS1250'=>1250,
      'WINDOWS1251'=>1251, 'WINDOWS1252'=>1252, 'WINDOWS1253'=>1253,
      'WINDOWS1254'=>1254, 'WINDOWS1255'=>1255, 'WINDOWS1256'=>1256,
      'WINDOWS1257'=>1257, 'WINDOWS1258'=>1258, 'US_ASCII'=>20127,
      'ISO8859_1'=>28591, 'ISO8859_2'=>28592, 'ISO8859_3'=>28593,
      'ISO8859_4'=>28594, 'ISO8859_5'=>28595, 'ISO8859_6'=>28596,
      'ISO8859_7'=>28597, 'ISO8859_8'=>28598, 'ISO8859_9'=>28599,
      'ISO8859_13'=>28603, 'ISO8859_15'=>28605, 'ISO8859_8I'=>38598,
      'ISO2022_JP'=>50220, 'ISO2022_KR'=>50225, 'ISO2022_CN'=>50227,
      'EUC_JP'=>51932, 'EUC_CN'=>51936, 'EUC_KR'=>51949, 'GB2312'=>52936,
      'UTF7'=>65000, 'UTF8'=>65001, 'UTF16'=>-1
    }
    def self.encode(str, from, to, dchar=nil, dflag=nil)
      from, to = CodePages[from.upcase], CodePages[to.upcase]
      if from != -1
        l = DLL.Kernel32.MultiByteToWideChar(from, 0, str, str.bytesize, nil, 0)
        utf16 = [].pack("x#{l*2}")
        DLL.Kernel32.MultiByteToWideChar(from, 0, str, str.bytesize, utf16, l)
      else utf16 = str
      end
      if to != -1
        l = DLL.Kernel32.WideCharToMultiByte(to, 0, utf16, utf16.bytesize/2, nil, 0, dchar, dflag)
        str = [].pack("x#{l}")
        DLL.Kernel32.WideCharToMultiByte(to, 0, utf16, utf16.bytesize/2, str, l, dchar, dflag)
      else str = utf16
      end
      case to
      when 20127; str.force_encoding('US-ASCII')
      when 65001; str.force_encoding('UTF-8')
      when    -1; str.force_encoding('UTF-16LE')
      end if vxace?
      str
    rescue raise($!, $!.message, caller(vxace? ? 2 : 1))
    end
    def self.encode!(str, from, to, dchar=nil, dflag=nil)
      str.replace(encode(str, from, to, dchar, dflag))
    rescue raise($!, $!.message, caller(vxace? ? 2 : 1))
    end
    def self.method_missing(method, str, *options)
      method = method.to_s.upcase
      ex_mark = method.slice!('!')
      from, to = *method.split('_TO_', 2)
      send("encode#{ex_mark}", str, from, to, *options)
    rescue raise($!, $!.message, caller(vxace? ? 2 : 1))
    end
  end
  module OS #1.1.0
    def self.version
      ver = DLL.Kernel32.GetVersion
      (ver&0xFF)*10 + (ver>>8&0xFF)
    end
    def self.windows2000_or_greater?()  version >=  5_0 end
    def self.windowsXP_or_greater?()    version >=  5_1 end
    def self.windowsXP_64_or_greater?() version >=  5_2 end
    def self.windowsVista_or_greater?() version >=  6_0 end
    def self.windows7_or_greater?()     version >=  6_1 end
    def self.windows8_or_greater?()     version >=  6_2 end
    def self.windows8_1_or_greater?()   version >=  6_3 end
    def self.windows10_or_greater?()    version >= 10_0 end
    def self.windows2000?()  version ==  5_0 end
    def self.windowsXP?()    version ==  5_1 end
    def self.windowsXP_64?() version ==  5_2 end
    def self.windowsVista?() version ==  6_0 end
    def self.windows7?()     version ==  6_1 end
    def self.windows8?()     version ==  6_2 end
    def self.windows8_1?()   version ==  6_3 end
    def self.windows10?()    version == 10_0 end
    def self.wow64?
      process = DLL.Kernel32.GetCurrentProcess || -1
      DLL.Kernel32.IsWow64Process(process, bool=[].pack('x4'))
      bool.unpack('L')[0] == 1
    end
    def self.dwm_composition_enabled?
      DLL.Dwmapi.DwmIsCompositionEnabled(bool=[].pack('x4'))
      bool.unpack('L')[0] == 1
    end
    def self.dwm_enable_composition(bool)
      DLL.Dwmapi.DwmEnableComposition(bool)
    end
    def self.documents_path
      DLL.Shell32.SHGetFolderPathW(0, 5, 0, 0, path=[].pack('x520'))#CSIDL_MYDOCUMENTS, SHGFP_TYPE_CURRENT
      path = Encode.utf16_to_utf8(path)
      path[0, path.index("\0")]
    end
    def self.create_directory(path)
      DLL.Kernel32.CreateDirectoryW(Zeus::Encode.utf8_to_utf16("#{path}\0"), nil)
    end
  end
end
 
module Video
  unless @buffer
    @buffer, @back_picture, @pause_picture, @resume_picture, @stop_picture, @no_fullscreen =
    [].pack('x1024'), '', '', '', '', false
  end
  class << self
    attr_accessor :back_picture, :pause_picture, :resume_picture, :stop_picture, :no_fullscreen
    def play(filename, cancellable=:Menu, stretch=:FitIn)
      init_data_system if cancellable and cancellable != :Stop
      quit_fullscreen if @no_fullscreen = NoFullscreen
      if $imported[:Zeus_Fullscreen]
        Fullscreen.video = true
        Fullscreen.update_window(Fullscreen.mode != 0)
      end
      create_back_sprite
      close
      wait while cancel_trigger? if cancellable
      open(filename, 0, false) and playback(filename, cancellable, stretch)
      wait while cancel_trigger? if cancellable
    ensure
      @no_fullscreen = false
      if $imported[:Zeus_Fullscreen]
        Fullscreen.video = false
        Fullscreen.update_window(Fullscreen.mode != 0)
      end
      close
      dispose_back_sprite
    end
    def play_to_bitmap(filename, bitmap, repeat=true)
      return unless OldAviMode and Zeus::OS.windowsVista_or_greater?
      close
      @hwnd = Zeus::DLL.User32.CreateWindowEx(0x08000000 | 0x00000080,#WS_EX_NOACTIVATE | WS_EX_TOOLWINDOW
                  'Static', nil, 0x10000000 | 0x80000000 | 0x0000000D,#WS_VISIBLE | WS_POPUP | SS_OWNERDRAW
                  0, 0, 0, 0, 0, 0, 0, nil)
      return close unless open(filename, 0, repeat)
      mci_silent("where ZeusVideoPlayer source")
      _, _, w, h = *mci_result.split(' ', 4).map! {|s| s.to_i}
      @bitmap = bitmap
      exstyle = Zeus::DLL.User32.GetWindowLong(@hwnd, -20)#GWL_EXSTYLE
      Zeus::DLL.User32.SetWindowLong(@hwnd, -20, exstyle | 0x00080000)#WS_EX_LAYERED
      Zeus::DLL.User32.SetLayeredWindowAttributes(@hwnd, 0, 0, 2)#LWA_ALPHA
      Zeus::DLL.User32.SetWindowPos(@hwnd, 1,#HWND_BOTTOM
                          0, 0, w, h, 2 | 16)#SWP_NOMOVE | SWP_NOACTIVATE
      Zeus::DLL.User32.SetActiveWindow(Graphics.hwnd)
      hdc  = Zeus::DLL.User32.GetDC(@hwnd)
      @hdc = Zeus::DLL.Gdi32.CreateCompatibleDC(hdc)
      @hbm = Zeus::DLL.Gdi32.CreateCompatibleBitmap(hdc, @bitmap.width, @bitmap.height)
      Zeus::DLL.User32.ReleaseDC(@hwnd, hdc)
      update
    end
    def update
      close if @bitmap and (@bitmap.disposed? or stopped?)
      return if !@bitmap or Graphics.frame_dropped
      info = [40,@bitmap.width,@bitmap.height,1,32].pack('Ll2S2x24')
      hdc  = Zeus::DLL.User32.GetDC(@hwnd)
      obj  = Zeus::DLL.Gdi32.SelectObject(@hdc, @hbm)
      Zeus::DLL.User32.GetClientRect(@hwnd, @buffer)
      w, h = *@buffer.unpack('x8L2')
      Zeus::DLL.Gdi32.BitBlt(@hdc, 0, 0, w, h, hdc, 0, 0, 0x00CC0020)#SRCCOPY
      Zeus::DLL.Gdi32.GetDIBits(@hdc, @hbm, 0, @bitmap.height, @bitmap.last_row_address, info, 0)#DIB_RGB_COLORS
      Zeus::DLL.Gdi32.SelectObject(@hdc, obj)
      Zeus::DLL.User32.ReleaseDC(@hwnd, hdc)
      @bitmap.fill_rect(0, 0, 0, 0, Color.new(0,0,0,0)) # set updated flag
      nil
    end
    def stop()     mci_silent("stop ZeusVideoPlayer")                                end
    def pause()    mci_silent("pause ZeusVideoPlayer")                               end
    def resume()   mci_silent("resume ZeusVideoPlayer")                              end
    def mode()     mci_silent("status ZeusVideoPlayer mode")     and mci_result      end
    def length()   mci_silent("status ZeusVideoPlayer length")   and mci_result.to_i end
    def position() mci_silent("status ZeusVideoPlayer position") and mci_result.to_i end
    def playing?() mode == 'playing'                                                 end
    def paused?()  mode == 'paused'                                                  end
    def stopped?() mode == 'stopped'                                                 end
    def wait(frame=1)
      frame.times do
        Graphics.update
        Graphics.frame_count -= 1
        Input.update
      end
      nil
    end
    def init_data_system
      if xp?
        $data_system ||= load_data("Data/System.rxdata")
        $game_system ||= Game_System.new
      elsif vx?
        $data_system ||= load_data("Data/System.rvdata")
      else
        $data_system ||= load_data("Data/System.rvdata2")
      end
      nil
    end
    def rgss_fullscreen?
      exstyle = Zeus::DLL.User32.GetWindowLong(Graphics.hwnd, -20)#GWL_EXSTYLE
      exstyle & 0x00000008 != 0#WS_EX_TOPMOST
    end
    def quit_fullscreen
      if rgss_fullscreen?
        inputs = [1,18,0, 1,13,0, 1,13,2, 1,18,2].pack('LSx2Lx16'*4)
        Zeus::DLL.User32.SendInput(4, inputs, 28)
        wait(10)
      end
    end
    def create_back_sprite
      @back_sprite = Sprite.new
      @back_sprite.z = 0xFFFF
      if @back_picture.empty?
        @back_sprite.bitmap = Bitmap.new(1, 1)
        @back_sprite.bitmap.set_pixel(0, 0, Color.new(0,0,0))
      else
        @back_sprite.bitmap = Cache.picture(@back_picture)
      end
      @back_sprite.zoom_x = Graphics.width  / @back_sprite.bitmap.width.to_f
      @back_sprite.zoom_y = Graphics.height / @back_sprite.bitmap.height.to_f
      Graphics.transition(0)
      Graphics.frame_reset
    end
    def dispose_back_sprite
      @back_sprite.bitmap.dispose if @back_sprite and @back_sprite.bitmap
      @back_sprite.dispose if @back_sprite
      @back_sprite = nil
    end
    def mci(command)
      error = mci_silent(command)
      return true if error == 0
      Zeus::DLL.Winmm.mciGetErrorStringW(error, @buffer, @buffer.bytesize/2)
      msgbox(mci_result, "\nCommand : ", command)
      return false
    end
    def mci_silent(command)
      command = Zeus::Encode.utf8_to_utf16("#{command}\0")
      Zeus::DLL.Winmm.mciSendStringW(command, @buffer, @buffer.bytesize/2, Graphics.hwnd)
    end
    def mci_result
      str = Zeus::Encode.utf16_to_utf8(@buffer)
      str[0, str.index("\0")]
    end
    def open(filename, pos, repeat)
      filename = Dir["#{filename}.*"][0] || filename
      type = OldAviMode ? 'AVIVideo' : 'MPEGVideo'
      mci("open \"#{filename}\" type #{type} alias ZeusVideoPlayer") and
      mci("window ZeusVideoPlayer handle #{@hwnd || Graphics.hwnd}") and
      mci("play ZeusVideoPlayer from #{pos} #{'repeat' if repeat}")
    end
    def close
      stop
      if !OldAviMode and rgss_fullscreen?
        mci_silent("window ZeusVideoPlayer handle 0")
        mci_silent("status ZeusVideoPlayer window handle")
        Zeus::DLL.User32.DestroyWindow(mci_result.to_i)
      end
      mci_silent("close ZeusVideoPlayer")
      Zeus::DLL.User32.DestroyWindow(@hwnd) if @hwnd
      Zeus::DLL.Gdi32.DeleteObject(@hbm) if @hbm
      Zeus::DLL.Gdi32.DeleteDC(@hdc) if @hdc
      @bitmap = @hwnd = @hbm = @hdc = nil
    end
    def resize(stretch)
      wait
      mci_silent("where ZeusVideoPlayer source")
      _, _, w, h = *mci_result.split(' ', 4).map! {|s| s.to_i}
      Zeus::DLL.User32.GetClientRect(Graphics.hwnd, @buffer)
      client_w, client_h = *@buffer.unpack('x8L2')
      case stretch
      when :Center;
      when :FitIn ; w, h = client_w, client_w * h / w
                    h, w = client_h, client_h * w / h if h > client_h
      when :FitOut; w, h = client_w, client_w * h / w
                    h, w = client_h, client_h * w / h if h < client_h
      else          w, h = client_w, client_h
      end
      x, y = (client_w-w)/2, (client_h-h)/2
      mci_silent("put ZeusVideoPlayer destination at #{x} #{y} #{w} #{h-1}")#bugfix cropped window
      mci_silent("put ZeusVideoPlayer destination at #{x} #{y} #{w} #{h}")
      nil
    end
    def playback(filename, cancellable, stretch)
      fullscreen, focus = rgss_fullscreen?, false
      loop do
        Zeus::DLL.User32.GetMessage(@buffer, 0, 0, 0)
        Zeus::DLL.User32.DefWindowProc(*msg = @buffer.unpack('L4'))
        if focus != (Zeus::DLL.User32.GetForegroundWindow == Graphics.hwnd)
          focus = !focus
          focus ? resume : pause
          resize(stretch)
        end
        next unless focus
        if !OldAviMode and fullscreen != rgss_fullscreen?
          fullscreen, pos = !fullscreen, position
          close
          wait(10)
          break unless open(filename, pos, false)
          resize(stretch)
        end
        Input.update
        if stopped? or position >= length
          break
        elsif cancellable and cancel_trigger?
          case cancellable
          when :Stop ; break
          when :Pause; pause_menu
          else         cancel_menu
          end
          resize(stretch)
        elsif $imported[:Zeus_Fullscreen] and
          (Fullscreen.inputs.any? {|input,| input.call} or
           Fullscreen.zoom.zero? != Fullscreen.maximized?)
        then
          resize(stretch)
        end
        case msg[1]
        when 0x0012 #WM_QUIT
          exit
        when 0x0100, 0x0104 #WM_KEYDOWN, WM_SYSKEYDOWN
          if msg[3][30] == 0 and (msg[1] == 0x0104 ? #trigger?
            (!@no_fullscreen and msg[2] == 0x0D) : #ALT + VK_RETURN
            (msg[2] == 0x70 or msg[2] == 0x7B)) #VK_F1 or VK_F12
          then
            pause
            Zeus::DLL.User32.PostMessage(*msg)
            wait(10)
            resume
            resize(stretch)
          end
        end
      end
      nil
    end
    if xp?
      alias anti_hangup_playback playback
      def playback(cancellable, stretch)
        anti_hangup_playback(filename, cancellable, stretch)
      rescue Hangup
        retry
      end
    end
    def cancel_trigger?
      CancelKeys.any? {|k| Input.trigger?(k)}
    end
    def cancel_menu
      Sound.play_ok
      pause
      sprite = Sprite.new
      sprite.z = @back_sprite.z + 1
      if @resume_picture.empty?
        resume_bmp = Bitmap.new(Graphics.width, Graphics.height)
        resume_bmp.font.size = 64
        resume_bmp.draw_text(0, 0, Graphics.width/2, Graphics.height, 'Resume', 1)
        resume_bmp.font.color.alpha /= 2
        resume_bmp.draw_text(Graphics.width/2, 0, Graphics.width/2, Graphics.height, 'Stop', 1)
      else
        sprite.bitmap = Cache.picture(@resume_picture)
      end
      if @stop_picture.empty?
        stop_bmp = Bitmap.new(Graphics.width, Graphics.height)
        stop_bmp.font.size = 64
        stop_bmp.draw_text(Graphics.width/2, 0, Graphics.width/2, Graphics.height, 'Stop', 1)
        stop_bmp.font.color.alpha /= 2
        stop_bmp.draw_text(0, 0, Graphics.width/2, Graphics.height, 'Resume', 1)
      else
        sprite.bitmap = Cache.picture(@stop_picture)
      end
      sprite.bitmap = resume_bmp
      cancel = false
      wait while cancel_trigger?
      loop do
        Graphics.update
        Input.update
        if [Input::DOWN, Input::LEFT, Input::RIGHT, Input::UP].any? {|k| Input.trigger?(k)}
          Sound.play_cursor
          cancel = !cancel
          sprite.bitmap = cancel ? stop_bmp : resume_bmp
        elsif Input.trigger?(Input::B)
          Sound.play_cancel
          cancel = false
          break
        elsif Input.trigger?(Input::C)
          Sound.play_ok
          break
        end
      end
      resume_bmp.dispose
      stop_bmp.dispose
      sprite.dispose
      wait while cancel_trigger?
      cancel ? stop : resume
      nil
    end
    def pause_menu
      Sound.play_ok
      pause
      sprite = Sprite.new
      sprite.z = @back_sprite.z + 1
      if @pause_picture.empty?
        sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)
        sprite.bitmap.font.size = 64
        sprite.bitmap.draw_text(sprite.bitmap.rect, 'Pause', 1)
      else
        sprite.bitmap = Cache.picture(@pause_picture)
      end
      wait while cancel_trigger?
      loop do
        Graphics.update
        Input.update
        if cancel_trigger?
          Sound.play_cancel
          break
        end
      end
      sprite.bitmap.dispose
      sprite.dispose
      wait while cancel_trigger?
      resume
      nil
    end
  end
end



Zeus, en 2016 a dit:

Dix ans plus tard, alors en fait je sais pas pourquoi ça fait ça, y'a plein de bug liés au plein écran et j'y peux rien. Je peux toujours te passer la dernière version, à priori je pense pas que ça corrigera le bug par contre t'as une nouvelle option NoFullscreen pour bloquer le plein écran, bon c'est pas terrible d'avoir un jeu qui quitte le mode plein écran de lui même juste pour lire une vidéo mais c'est mieux qu'un bug. Sinon faut utiliser le OldAviMode, y'a quelques contraintes mais au moins ça marche même en plein écran.
Le script est légèrement différent donc faut relire la notice.



Source : https://www.rpg-maker.fr/index.php?page=forum&id=25738

Suite à de nombreux abus, le post en invités a été désactivé. Veuillez vous inscrire si vous souhaitez participer à la conversation.

Haut de page

Merci de ne pas reproduire le contenu de ce site sans autorisation.
Contacter l'équipe - Mentions légales

Plan du site

Communauté: Accueil | Forum | Chat | Commentaires | News | Flash-news | Screen de la semaine | Sorties | Tests | Gaming-Live | Interviews | Galerie | OST | Blogs | Recherche
Apprendre: Visite guidée | RPG Maker 95 | RPG Maker 2003 | RPG Maker XP | RPG Maker VX | RPG Maker MV | Tutoriels | Guides | Making-of
Télécharger: Programmes | Scripts/Plugins | Ressources graphiques / sonores | Packs de ressources | Midis | Eléments séparés | Sprites
Jeux: Au hasard | Notre sélection | Sélection des membres | Tous les jeux | Jeux complets | Le cimetière | RPG Maker 95 | RPG Maker 2000 | RPG Maker 2003 | RPG Maker XP | RPG Maker VX | RPG Maker VX Ace | RPG Maker MV | Autres | Proposer
Ressources RPG Maker 2000/2003: Chipsets | Charsets | Panoramas | Backdrops | Facesets | Battle anims | Battle charsets | Monstres | Systems | Templates
Ressources RPG Maker XP: Tilesets | Autotiles | Characters | Battlers | Window skins | Icônes | Transitions | Fogs | Templates
Ressources RPG Maker VX: Tilesets | Charsets | Facesets | Systèmes
Ressources RPG Maker MV: Tilesets | Characters | Faces | Systèmes | Title | Battlebacks | Animations | SV/Ennemis
Archives: Palmarès | L'Annuaire | Livre d'or | Le Wiki | Divers