Code Monkey home page Code Monkey logo

extension-videoplayer-native's Introduction

extension-videoplayer-native

This is a fullscreen videoplayer extension for iOS and Android using native OS functionality and components for videoplayback.

Usage

Add the package link (https://github.com/defold/extension-videoplayer-native/archive/master.zip) to the project setting project.dependencies, and you should be good to go.

See the manual for further info.

Lua API

videoplayer.create(uri, settings, callback)

Opens a video from either a uri, and returns a handle to the videoplayer.

function videoplayer_callback(self, video, event, data={})
    ...
end

self.handle = videoplayer.create("/assets/big_buck_bunny_720p_1mb.mp4", {play_sound = true}, videoplayer_callback)

videoplayer.destroy(handle)

Destroys the video

videoplayer.set_visible(handle, visible)

Shows or hides the video player view

videoplayer.play(handle) / videoplayer.stop(handle) / videoplayer.pause(handle)

Example

player.gui_script:

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

Limitations

Android

The android implementation uses the MediaPlayer in combination with a SurfaceView to display the video.

Here's a list of Supported Video Formats

iOS

TODO

extension-videoplayer-native's People

Contributors

andsveking avatar britzl avatar husenap avatar jcash avatar nwestberg avatar simonjacobyking avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

extension-videoplayer-native's Issues

Desktop platform support

I'd like to be able to play videos on the desktop platforms (Win/Mac/Linux).

For me the use case would primarily be for cutscenes, so sound would be important.

I haven't verified the behaviour on Android/iOS, but for my use case I wouldn't want playback controls visible to the end user.

For cutscenes, full screen projection makes most sense. There are probably use cases for projecting video onto a surface.

Document supported video formats

We should either document the supported video formats or list the components/views/classes used for video playback per platform so that the user can look up this information.

HTML5 support

I would like to be able to incorporate videos into a game.

Fullscreen support might be sufficent enough for what I have in mind right now, but being able to overlay gui elements would be crucial.
So maybe a surface projection or as a gui Node would work better.

With enough success other target platforms might be interesting as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.