Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/defold/extension-videoplayer
Videoplayer for the Defold engine
https://github.com/defold/extension-videoplayer
defold
Last synced: 3 months ago
JSON representation
Videoplayer for the Defold engine
- Host: GitHub
- URL: https://github.com/defold/extension-videoplayer
- Owner: defold
- License: mit
- Created: 2017-02-27T07:59:30.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-04-17T16:58:20.000Z (8 months ago)
- Last Synced: 2024-10-04T22:07:32.664Z (3 months ago)
- Topics: defold
- Language: C
- Homepage:
- Size: 37.7 MB
- Stars: 9
- Watchers: 22
- Forks: 6
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
NOTE: This is an example extension, with no sound support.
To use a native videoplayer (Android/iOS), we recommend [extension-videoplayer-native](https://github.com/defold/extension-videoplayer-native) instead.# extension-videoplayer
Example of creating a videoplayer (.webm) through native extensions.
# Disclaimer
Although we aim to provide good example functionality in this example, we cannot guarantee the quality/stability at all times.
Please regard it as just that, an example, and don't rely on this as a dependency for your production code.# How to build the libraries
[Instructions here](videoplayer/utils/README.md)
# FAQ
## How do I use this extension?
Add the package link (https://github.com/defold/extension-videoplayer/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.open(videoresource)
Opens a video resource, and returns a handle to the instance.
local videoresource = resource.load("/videos/big_buck_bunny.webm")
self.video = videoplayer.open(videoresource)## videoplayer.get_info(video)
Gets the info about the video:
* width - in pixels
* height - in pixels
* bytes_per_pixel
* frame - current frame
* time - current time in seconds
* eos - true if end of stream was reached## videoplayer.get_frame(video)
Gets the video buffer. This is allocated when opening the video.
The buffer has one stream, with signature `{hash("rgb"), buffer.VALUE_TYPE_UINT8, 3}`.self.videoframe = videoplayer.get_frame(self.video)
## videoplayer.update(video, dt)
Updates the video with a delta time
# Example
*[main.script](main/main.script):*
function init(self)
local logosize = 128
local screen_width = sys.get_config("display.width", 600)
local screen_height = sys.get_config("display.height", 800)
local scale_width = screen_width / logosize
local scale_height = screen_height / logosizego.set("#sprite", "scale", vmath.vector3(scale_width, scale_height, 1) )
if videoplayer ~= nil then
local videoresource = resource.load("/videos/big_buck_bunny.webm")
self.video = videoplayer.open(videoresource)
self.videoinfo = videoplayer.get_info(self.video)
self.videoheader = { width=self.videoinfo.width, height=self.videoinfo.height, type=resource.TEXTURE_TYPE_2D, format=resource.TEXTURE_FORMAT_RGB, num_mip_maps=1 }
self.videoframe = videoplayer.get_frame(self.video)
else
print("Could not initialize videoplayer")
end
endfunction update(self, dt)
if videoplayer ~= nil then
videoplayer.update(self.video, dt)
local path = go.get("#sprite", "texture0")
resource.set_texture(path, self.videoheader, self.videoframe)
end
end