-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Gosu::Video #595
base: master
Are you sure you want to change the base?
Add Gosu::Video #595
Conversation
…to read streaminfo from a video file
… and implement more of interface
@jlnr What do you think of this approach? TODO:
Video support is behind the Working example: require_relative "ffi-gosu/lib/gosu"
require_relative "ffi-gosu/lib/gosu/video"
class Window < Gosu::Window
def initialize
super(800, 600, false, 16.6667, true, false)
@video = Gosu::Video.new("/home/cyberarm/Downloads/big-buck-bunny_trailer.webm")
pp @video.width, @video.height, @video.length, @video.position
calculate_scale
end
def draw
Gosu.draw_rect(0, 0, width, height, Gosu::Color::WHITE)
@video.draw(0, 0, 0, @scale, @scale)
end
def update
calculate_scale
end
def button_down(id)
@video.play if id == Gosu::KB_SPACE
@video.stop if id == Gosu::KB_LEFT_CONTROL
end
def calculate_scale
@scale = [
[
width / @video.width.to_f,
height / @video.height.to_f
].min,
[
width / @video.width.to_f,
height / @video.height.to_f
].max
].min
end
end
Window.new.show |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, thanks for this. I didn't review all of it, but I left a couple of code comments.
My biggest worry with video support is shippability. ImageMagick seemed like a similar swiss army knife as VLC, but then packaging a Ruby/Gosu game with ImageMagick for Windows turned out to be a huge timesink. (I vaguely remember wrestling with ImageMagick "all in one" builds...)
Is VLC a single DLL that we can ship?
There was also an issue with example code for libtheora, I'm not sure how it compares to libvlc in terms of self-containedness: #349
(As long as it is hidden behind a compiler flag, this is not really a blocker. If video support is only a couple of extra files, why not!)
For libvlc we'd need to include
The gists @Dahrkael linked to for libtheoraplayer are returning 404s and the waybackmachine doesn't have them. |
Okay, that sounds good 👍 I was worried that we might need to ship a whole zoo of Unix-ish libraries. |
…r checking, pruned Video.hpp includes
Currently a stub.
An ffmpeg/libvlc backed implementation that'll emulate the
Gosu::Image
andGosu::Song
public interfaces.Gosu::Window::tick()
will likely need to callGosu::Video::update()
on all videos; A static vector inGosu::Video
can host and maintain the list.The implementation is wrapped in an
#ifdef
to allowGosu::Video
to be an optional feature.