new videoJSPlugin(player, config) → {videoJSPlugin}
constructor - VideoJS upscaler plugin. The plugin is registered with name vectorlyPlugin
using videojs.registerPlugin
. The plugin is accessible at vectorlyUpscaler.videoJSPlugin
from vectorly-videojs.js
library. See examples below for usage.
Parameters
-
player
videojs.Player
VideoJS player instance
-
config
vectorlyUpscaler~config
Configuration for upscaler. Only
token
is required. See upscaler config for more optionsProperties
-
token
string
required; Token used to fetch models from server; Signup on Upscaler dashboard to get the token
-
token
Returns
-
videoJSPlugin
instance of videoJSPlugin
Examples
<script src="https://vjs.zencdn.net/7.11.4/video.min.js"></script>
// Make sure to load videojs script before loading vectorly-videojs.js
<script src="https://cdn.vectorly.io/upscaler/v2/latest/vectorly-videojs.js"> </script>
<video id="my-video" class="video-js" src="your-video-src" controls width="426" height="240" data-setup="{}" crossorigin="anonymous">
<script>
player = videojs('my-video')
const vjsUpscaler = player.vectorlyPlugin({token: '<your-token-here>'})
// vjsUpscaler is videoJSPlugin instance
</script>
import videojs from 'video.js'
import vectorlyUpscaler from '@vectorly-io/ai-upscaler/videojs'
// If using webpack 4, import using complete path
// import vectorlyUpscaler from '@vectorly-io/ai-upscaler/dist/vectorly-videojs.js'
vectorlyUpscaler.register(videojs) // Register the plugin
player = videojs('my-video')
const vjsUpscaler = player.vectorlyPlugin({token: '<your-token-here>'})
// vjsUpscaler is videoJSPlugin instance
Methods
addEventListener(event, callback)
addEventListener - description
Parameters
-
event
string
-
callback
function
Function to be called on event fired
Example
vjsUpscaler.addEventListener('load', function() {
console.log('Vectorly Upscaler loaded')
})
vjsUpscaler.addEventListener('error', function(){
console.log('Error in upscaling')
// add code to handle error eg: fallback to no upscaling
})
vjsUpscaler.addEventListener('start', function(){
console.log('Starting upscaler')
})
vjsUpscaler.addEventListener('stop', function(){
console.log('Stopping upscaler')
})
Listens to events
changeNetwork(networkParams)
async changeNetwork - Change the model network and parameters being used to render
This method is still WIP. Expect some lag when changing the networks
Parameters
-
networkParams
NetworkParams
description
disable()
disable - Disables upscaler
enable()
enable - Enables upscaler