【Defold】ビデオ再生に「Videoplayer – native」アセット

Defold, DEVELOP

“Videoplayer – native" は Android, iOS 端末でビデオ再生ができる様になるアセットです。

目次

アセットページ

https://defold.com/assets/videoplayernative/

ライブラリのURL

https://github.com/defold/extension-videoplayer-native/archive/master.zip

サンプル

local function video_callback(self, video, event, data)
    if event == videoplayer.VIDEO_EVENT_READY then
        videoplayer.start(video)
 
    elseif event == videoplayer.VIDEO_EVENT_FINISHED then
        videoplayer.destroy(video)
        self.handle = nil
    end
end
 
local function window_callback(self, event, data)
    if not self.handle then
        return
    end
 
    if event == window.WINDOW_EVENT_FOCUS_LOST then
        videoplayer.pause(self.handle)
    elseif event == window.WINDOW_EVENT_FOCUS_GAINED then
        videoplayer.start(self.handle)
    end
end
 
function init(self)
    window.set_listener(window_callback)
    if videoplayer then
        self.handle = videoplayer.create("video.mp4", {play_sound = true}, video_callback)
    end
end

お知らせ

Posted by kazupon