From 68cc0171894a6d36c589974c737bb88d0e68f0db Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Thu, 11 Apr 2024 22:43:48 +0900 Subject: [PATCH] Revert "examples/video: reduce video FPS" This reverts commit 6f3f58cb32fb0dde78220aba7fe2f287e6c9197f. Reason: decoding the video already follows the framerate of the MPEG data and skips rendering when necessary, so there is no need to adjust FPS from Update. --- examples/video/main.go | 8 -------- examples/video/mpegplayer.go | 4 +++- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/examples/video/main.go b/examples/video/main.go index 90a16979c..d202fa96b 100644 --- a/examples/video/main.go +++ b/examples/video/main.go @@ -31,17 +31,9 @@ var shibuya_mpg []byte type Game struct { player *mpegPlayer - - counter int } func (g *Game) Update() error { - // Update the video player once per two ticks. - // This indicates to play the video in 30 FPS. - if g.counter % 2 == 0 { - g.player.Update() - } - g.counter++ return nil } diff --git a/examples/video/mpegplayer.go b/examples/video/mpegplayer.go index 2c7ebb974..44926932c 100644 --- a/examples/video/mpegplayer.go +++ b/examples/video/mpegplayer.go @@ -85,7 +85,8 @@ func newMPEGPlayer(src io.Reader) (*mpegPlayer, error) { return p, nil } -func (p *mpegPlayer) Update() { +// updateFrame upadtes the current video frame. +func (p *mpegPlayer) updateFrame() { p.m.Lock() defer p.m.Unlock() @@ -118,6 +119,7 @@ func (p *mpegPlayer) Update() { // Draw draws the current frame onto the given screen. func (p *mpegPlayer) Draw(screen *ebiten.Image) { + p.updateFrame() frame := p.currentFrame sw, sh := screen.Bounds().Dx(), screen.Bounds().Dy() fw, fh := frame.Bounds().Dx(), frame.Bounds().Dy()