Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/defold/extension-videoplayer-native
Videoplayer extension using native views
https://github.com/defold/extension-videoplayer-native
defold defold-game-engine defold-library video-player videoplayer-extension
Last synced: 3 months ago
JSON representation
Videoplayer extension using native views
- Host: GitHub
- URL: https://github.com/defold/extension-videoplayer-native
- Owner: defold
- License: mit
- Created: 2018-11-21T13:38:16.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-08-23T09:30:53.000Z (4 months ago)
- Last Synced: 2024-10-04T22:07:10.333Z (3 months ago)
- Topics: defold, defold-game-engine, defold-library, video-player, videoplayer-extension
- Language: C++
- Homepage:
- Size: 2.21 MB
- Stars: 10
- Watchers: 17
- Forks: 9
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-defold - VideoPlayer Native
README
# 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](http://www.defold.com/manuals/libraries/) for further info.
# Lua API
## videoplayer.create(uri, settings, callback)
Opens a video from either a uri, and returns a handle to the videoplayer.
```lua
function videoplayer_callback(self, video, event, data={})
...
endself.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.start(handle) / videoplayer.stop(handle) / videoplayer.pause(handle)
# Example
*[player.gui_script](main/player.gui_script):*
```lualocal 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
endlocal function window_callback(self, event, data)
if not self.handle then
return
endif event == window.WINDOW_EVENT_FOCUS_LOST then
videoplayer.pause(self.handle)
elseif event == window.WINDOW_EVENT_FOCUS_GAINED then
videoplayer.start(self.handle)
end
endfunction 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](https://developer.android.com/reference/android/media/MediaPlayer) in combination with a [SurfaceView](https://developer.android.com/reference/android/view/SurfaceView) to display the video.
Here's a list of [Supported Video Formats](https://developer.android.com/guide/topics/media/media-formats)
# iOS
TODO