设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1351|回复: 0
打印 上一主题 下一主题

[已经过期] 如何播放视频同时显示文字,如何改变视频帧率

[复制链接]

Lv1.梦旅人

梦石
0
星屑
83
在线时间
16 小时
注册时间
2023-1-20
帖子
5
跳转到指定楼层
1
发表于 2023-1-24 09:09:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
Graphics.frame_rate应该是改变的游戏画面帧率吧,我希望改变播放视频的帧率
我an做了一个动画是4帧每秒放的,到了rm中播放时明显超过了这个帧率
这是事件中的脚本:
  1. fls = RMFlash.load("3.swf",640,480)
  2. fls.x = 0
  3. fls.y = 0
  4. fls.loop = 1
  5. while true
  6.         Graphics.update
  7. #        Input.update
  8.         fls.update
  9.         break if !fls.playing?
  10. #        break if Input.trigger?(13)
  11. end
  12. fls.dispose
复制代码

以下是用到的脚本:
  1. class String
  2.   
  3.   CP_ACP = 0
  4.   CP_UTF8 = 65001
  5.   
  6.   def u2s
  7.     m2w = Win32API.new("kernel32", "MultiByteToWideChar", "ilpipi", "i")
  8.     w2m = Win32API.new("kernel32", "WideCharToMultiByte", "ilpipipp", "i")
  9.    
  10.     len = m2w.call(CP_UTF8, 0, self, -1, nil, 0)
  11.     buf = "\0" * (len*2)
  12.     m2w.call(CP_UTF8, 0, self, -1, buf, buf.size/2)
  13.    
  14.     len = w2m.call(CP_ACP, 0, buf, -1, nil, 0, nil, nil)
  15.     ret = "\0" * len
  16.     w2m.call(CP_ACP, 0, buf, -1, ret, ret.size, nil, nil)
  17.    
  18.     return ret
  19.   end
  20.   
  21.   def s2u
  22.     m2w = Win32API.new("kernel32", "MultiByteToWideChar", "ilpipi", "i")
  23.     w2m = Win32API.new("kernel32", "WideCharToMultiByte", "ilpipipp", "i")
  24.   
  25.     len = m2w.call(CP_ACP, 0, self, -1, nil, 0);
  26.     buf = "\0" * (len*2)
  27.     m2w.call(CP_ACP, 0, self, -1, buf, buf.size/2);
  28.   
  29.     len = w2m.call(CP_UTF8, 0, buf, -1, nil, 0, nil, nil);
  30.     ret = "\0" * len
  31.     w2m.call(CP_UTF8, 0, buf, -1, ret, ret.size, nil, nil);
  32.      
  33.     return ret
  34.   end

  35.   def s2u!
  36.     self[0, length] = s2u
  37.   end  
  38.   
  39.   def u2s!
  40.     self[0, length] = u2s
  41.   end
  42.   
  43. end

  44. class Bitmap
  45.   
  46.   RtlMoveMemory_pi = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
  47.   RtlMoveMemory_ip = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i')

  48.   def address
  49.     buffer, ad = "xxxx", object_id * 2 + 16
  50.     RtlMoveMemory_pi.call(buffer, ad, 4); ad = buffer.unpack("L")[0] + 8
  51.     RtlMoveMemory_pi.call(buffer, ad, 4); ad = buffer.unpack("L")[0] + 16
  52.     RtlMoveMemory_pi.call(buffer, ad, 4); return buffer.unpack("L")[0]
  53.   end
  54.   
  55. end

  56. class RMFlash

  57.         API_NEW                      = Win32API.new("RMFlash", "_new", "piil", "l")
  58.         API_UPDATE            = Win32API.new("RMFlash", "_update", "l", "v")
  59.         API_FREE              = Win32API.new("RMFlash", "_free", "l", "v")
  60.         API_PLAYING     = Win32API.new("RMFlash", "_is_playing", "l", "i")
  61.         API_PAUSE              = Win32API.new("RMFlash", "_pause", "l", "v")
  62.         API_RESUME            = Win32API.new("RMFlash", "_resume", "l", "v")
  63.         API_BACK              = Win32API.new("RMFlash", "_back", "l", "v")
  64.         API_REWIND            = Win32API.new("RMFlash", "_rewind", "l", "v")
  65.         API_FORWARD            = Win32API.new("RMFlash", "_forward", "l", "v")
  66.         API_CURFRAME          = Win32API.new("RMFlash", "_cur_frame", "l", "i")
  67.         API_TOTALFRAME        = Win32API.new("RMFlash", "_total_frames", "l", "i")
  68.         API_GOTOFRAME          = Win32API.new("RMFlash", "_goto_frame", "li", "v")
  69.         API_GETLOOP                  = Win32API.new("RMFlash", "_get_loop", "l", "i")
  70.         API_SETLOOP                  = Win32API.new("RMFlash", "_set_loop", "li", "v")
  71.         API_CLEARALL          = Win32API.new("RMFlash", "_clear_all", "v", "v")
  72.   API_VALID       = Win32API.new("RMFlash", "_valid", "l", "i")
  73.   API_SENDMSG     = Win32API.new("RMFlash", "_send_message", "liii", "l")
  74.        
  75.   CUR_PATH        = Dir.pwd
  76.   
  77.         def self.get_version

  78.         end

  79.         def self.clear_all
  80.                 API_CLEARALL.call
  81.         end
  82.   
  83.   def self.load(name, width, height, v = nil)
  84.     new("#{CUR_PATH}/#{name}".u2s, width, height, v)
  85.   end
  86.   
  87.   attr_reader   :valid

  88.         def initialize(flash_name, flash_width, flash_height, viewport = nil)
  89.                 @sprite = Sprite.new(viewport)
  90.                 @sprite.bitmap = Bitmap.new(flash_width, flash_height)
  91.                 @value = API_NEW.call(flash_name, flash_width, flash_height, @sprite.bitmap.address)
  92.                 @loop = API_GETLOOP.call(@value) > 0
  93.     @valid = API_VALID.call(@value) > 0
  94.         end

  95.         def viewport
  96.                 @sprite.viewport
  97.         end

  98.         def update
  99.                 API_UPDATE.call(@value)
  100.         end

  101.         def dispose
  102.                 API_FREE.call(@sprite.bitmap.address)
  103.         end

  104.         def playing?
  105.                 API_PLAYING.call(@value) > 0
  106.         end

  107.         def pause
  108.                 API_PAUSE.call(@value)
  109.         end

  110.         def resume
  111.                 API_RESUME.call(@value)
  112.         end

  113.         def back
  114.                 API_BACK.call(@value)
  115.         end

  116.         def rewind
  117.                 API_REWIND.call(@value)
  118.         end

  119.         def forward
  120.                 API_FORWARD.call(@value)
  121.         end

  122.         def current_frame
  123.                 API_CURFRAME.call(@value)
  124.         end

  125.         def total_frames
  126.                 API_TOTALFRAME.call(@value)
  127.         end

  128.         def goto_frame(goal_frame)
  129.                 API_GOTOFRAME.call(@value, goal_frame)
  130.         end

  131.         def x
  132.                 @sprite.x
  133.         end

  134.         def x=(v)
  135.                 @sprite.x = v
  136.         end

  137.         def y
  138.                 @sprite.y
  139.         end

  140.         def y=(v)
  141.                 @sprite.y = v
  142.         end

  143.         def z
  144.                 @sprite.z
  145.         end

  146.         def z=(v)
  147.                 @sprite.z = v
  148.         end

  149.         def width
  150.                 @sprite.bitmap.width
  151.         end

  152.         def height
  153.                 @sprite.bitmap.height
  154.         end

  155.         def loop?
  156.                 @loop
  157.         end

  158.         def loop=(v)
  159.                 if @loop != v
  160.                         @loop = v
  161.                         API_SETLOOP.call(@value, v)
  162.                 end
  163.         end
  164.   
  165.   def msg_to_flash(msg, wParam, lParam)
  166.     return API_SENDMSG.call(@value, msg, wParam, lParam)
  167.   end
  168.   
  169.   #  例
  170.   WM_MOUSEMOVE  = 0x0200
  171.   
  172.   def make_long(a, b)
  173.     return (a & 0xffff ) | (b & 0xffff) << 16
  174.   end
  175.   
  176.   def on_mouse_move(x, y)
  177.     return msg_to_flash(WM_MOUSEMOVE, 0, make_long(x, y))
  178.   end

  179. end

  180. module Kernel

  181.   alias origin_exit exit unless method_defined? :exit
  182.   
  183.   def exit(*args)
  184.     RMFlash.clear_all
  185.     origin_exit(*args)
  186.   end
  187.   
  188. end

  189. #fls = RMFlash.load("2.swf", 640, 480)

  190. #while true
  191. #        Graphics.update
  192. #        Input.update
  193. #        fls.update
  194. #        break if Input.trigger?(13)
  195. #end
  196. #fls.dispose

  197. #exit

  198. =begin
  199. class RMFlash
  200.   API_NEW = Win32API.new("RMFlash", "_new", "piil", "l")
  201.   API_UPDATE = Win32API.new("RMFlash", "_update", "l", "v")
  202.   API_FREE = Win32API.new("RMFlash", "_free", "l", "v")
  203.   #def self.new(*args)
  204.   #  obj = super(*args)
  205.   #  obj.send :initialize, *args
  206.   #  obj
  207.   #end
  208.   
  209.   def initialize(flashname, fw, fh)
  210.    
  211.   end
  212.   
  213. end

  214. RMFlash.new
  215. exit
  216. =end
复制代码

然后如何在播放视频的同时显示对话呢(考虑对话不做在视频内的情况),我目前的思路是用开关或者变量,然后在地图上新建一个事件并行处理?但是结果很难控制,貌似会因为播放视频而将文章分成几段,前面一段,播放完了一段。如果可以的话,我希望能和视频同时并行呈现,谢谢大家了,给个解决思路就行。
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-28 21:33

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表