- Print
- PDF
For web
- Print
- PDF
Available in Classic and VPC
Web environment describes how to apply players of Video Player Enhancement and setting options in the web environment.
The following environment is required to apply and set the player in a web environment:
- Environment that can communicate externally
- Browser following web standard based on Chrome (see web browser support specifications)
Apply player
The following shows how to apply a player to a web page:
To apply a player to a web page, at least 1 player must exist. To create a player, see Create a player.
- Click the environment you are using in the Region menu and the Platform menu on the NAVER Cloud Platform console.
- Click Services > Media > Video Player Enhancement.
- Click the Video Player Management menu.
- Click the [SDK address] button for the player to apply to the web environment in the player’s list.
- Click the [Copy] button under SDK address after choosing a service environment that applies a player to.
- The SDK address of the player is copied to the clipboard.
- Add the copied SDK address to the HTML of the web page as follows:
Set up player
Player options can be easily preset in NAVER Cloud Platform console (See Player settings.), and you can also customize the player by setting each property.
The basic structure of the player is as follows:
new ncplayer("HTMLElement id" , {
playlist:[
{ file:"http://example.com/myVideo.mp4" } // a playback source
]
});
Player option
The customizable options are as follows:
Configurable options may vary depending on the current pricing plan.
Pricing plan | Property | Type | Description | Default value | Option value | Required status |
---|---|---|---|---|---|---|
Basic/Standard | playlist | array | Playlist | - | - | O |
autostart | boolean | Autoplay | true | - | X | |
muted | boolean | Mute | false | - | X | |
keyboardShortcut | boolean | Keyboard shortcut | true | - | X | |
controls | boolean | Whether to use control bar | true | - | X | |
ui | string | UI settings | all | X | ||
aspectRatio | string | Aspect ratio | 16/9 | 16/9, 4/3, 1/1, 9/16, 21/9 | X | |
objectFit | string | Customized screen | contain | X | ||
autoPause | boolean | Auto stop when the tab is disabled | false | - | X | |
repeat | boolean | Repeated playback | false | - | X | |
lang | string | UI language settings | auto | - | ||
Standard | controlBtn | array | Set the following options:
| controlBtn: {
fullscreen: true, volume: true, times: true, pictureInPicture: true, setting: true | - | X |
customBtns | array | Set the following options:
| - |
| X | |
progressBarColor | string | Color of control bar | #4299f5 | - | X | |
controlActiveTime | number | Control bar active time (ms) | 3000 | - | X | |
startMutedInfoNotVisible | boolean | Mute notifications | false | - | X | |
playRateSetting | array | Speed options | [0.5,0.75,1,1.5,2] | - | X | |
seekingPreview | boolean | Preview video section movement | true | - | X | |
touchGestures | boolean | Touch gestures | true | - | X | |
descriptionNotVisible | boolean | Metadata | false | - | X | |
lowLatencyMode | boolean | CMAF LL-HLS | false | - | X | |
watermarkConfig | array | Set the following options:
| randPositionInterVal number: 3000 | - | X |
Change Basic Icons
You can edit script code to change basic icons. Examples are as follows:
// Video (MP4)
const player = new ncplayer('video', {
playlist: [
{
file: 'https://CDNdomain/example_video_01.mp4',
poster: 'https://CDNdomain/example_image_01.png',
}
],
controlBtn:{
play:true,
fullscreen:true,
volume:true,
times:true,
pictureInPicture:true,
setting:true,
subtitle:true,
},
icon:{
bigPlay:"https://CDNdomain/icon/play-circle-fill.svg", // Big play button before autoplay
play:"https://CDNdomain/icon/play-fill.svg", // Playback
use:"https://CDNdomain/icon/pause-fill.svg", // Pause
prev:"https://CDNdomain/icon/skip-back-fill.svg", // the previous video
next:"https://CDNdomain/icon/skip-forward-fill.svg", // the next video
replay:"https://CDNdomain/icon/arrow-clockwise-fill.svg", // Replay
subtitle:"https://CDNdomain/icon/closed-captioning-fill.svg", // Subtitle on
subtitleOff:"https://CDNdomain/icon/closed-captioning.svg", // Subtitle off
fullscreen:"https://CDNdomain/icon/corners-out.svg", // Switch to full screen
fullscreenExit:"https://CDNdomain/icon/corners-in.svg", // Exit full screen
volumeFull:"https://CDNdomain/icon/speaker-simple-high-fill.svg", // Maximum volume
volumeMute:"https://CDNdomain/icon/speaker-simple-x-fill.svg", // Volume 0 , Mute
volumeMid:"https://CDNdomain/icon/speaker-simple-low-fill.svg", // Medium volume
pip:"https://CDNdomain/icon/picture-in-picture-fill.svg", // PIP
setting:"https://CDNdomain/icon/gear-fill.svg", // Settings
}
});
Property | Description |
---|---|
bigPlay | Big play button before autoplay |
play | Playback |
pause | Pause |
prev | Play the previous video |
next | Play the next video |
replay | Replay |
subtitle | Subtitle On |
subtitleOff | Subtitle Off |
fullscreen | Switch to full screen |
fullscreenExit | Exit full screen |
volumeFull | Maximum volume |
volumeMute | Volume 0, mute |
volumeMid | Medium volume |
pip | PIP |
setting | Settings |
Redefinition of Picture In Picture feature (Override)
You can change the provided PIP features to floating player features within the website. Examples are as follows:
// Video (MP4)
const player = new ncplayer('video', {
playlist: [
{
file: 'https://CDNdomain/example_video_01.mp4',
poster: 'https://CDNdomain/example_image_01.png',
}
],
override:{
pip:{
on(){
window.player.uiHidden(); // Hide all UI of player
// Write an executable code for customer’s floating player
// \<example> floatingModeStart()
},
off(){
window.player.uiVisible(); // Display all UI of player
// Write a completion code for customer’s floating player
// \<example> floatingModeStop()
}
}
}
});
Hide UI of floating player
If PIP features are changed to floating player, you can set whether to display control UI of floating display.
This feature is the method that you must consider when implementing a floating player, other than the controlBarActive
/controlBarDeactive
methods, you can use the uiHidden
method to hide all UI or the uiVisible
method to display all UI.
Examples are as follows:
// Video (MP4)
const player = new ncplayer('video', {
playlist: [
{
file: 'https://CDNdomain/example_video_01.mp4',
poster: 'https://CDNdomain/example_image_01.png',
}
]
});
// Hide control bar UI
player.uiHidden();
// Display control bar UI
player.uiVisible();
Playlist
The property information to set the playback source is as follows:
Pricing plan | Property | Type | Description | Option examples | Required status |
---|---|---|---|---|---|
Basic/Standard | file | string |
| playlist: [
| O |
sources | array |
| - | X | |
poster | string | Image to be displayed before video playback | - | X | |
Standard | description | array | Metadata to be displayed at the top of the player, with the following properties:
| description: {
created_at: "Date", profile_name: "Uploader nickname", profile_image: "Channel image", callback(){
| X |
Method
The Video Player Enhancement service provides various methods to play a video and implement various functions.
You can call a method after you Create a player.
The script to create and play the player is as follows:
let player = new ncplayer('myElement', {
playlist: [
{
file:"http://example.com/myVideo.mp4",
poster:"http://example.com/myVideoThumb.png"
}
]
});
player.play();
Supported Methods
Methods to support in the Video Player Enhancement service are as follows:
Method | Description |
---|---|
ncplayer.play() | Play a video |
ncplayer.pause() | Pause a video |
ncplayer.prev() | If there is the previous video, play the previous video |
ncplayer.next() | If there is the next video, play the next video |
ncplayer.mute() | Mute video |
ncplayer.controlBarActive() | Enable player control bar UI |
ncplayer.controlBarDeactive() | Disable player control bar UI |
ncplayer.fullscreen() | Switch to full screen |
ncplayer.pip() | Switch to mini player |
ncplayer.volume(value) | Set volume control to a value
|
ncplayer.currentTime(value) | Change the time of the video currently playing
|
ncpplayer.on(type, listner) | Receive event
|
Event
The Video Player Enhancement service provides various events and configures events occurring when clicking metadata.
Event features are only provided in the Standard plan.
Events can be received as follows:
let player = new ncplayer('myElement', {
playlist: [
{
file:"http://example.com/myVideo.mp4",
poster:"http://example.com/myVideoThumb.png"
}
]
});
player.on('play',(e)=>{
console.log('Played.',e);
})
Supported events
The events to support in the Video Player Enhancement are as follows:
Event | Description |
---|---|
play | Event that occurs when video playback request is successful |
pause | Event that occurs when a video pauses |
ready | Event that occurs when a player is ready to play |
ended | Event that occurs when playback is completed to the end |
seeking | Event that occurs when the seek action starts |
seeked | Event that occurs when the seek action is completed |
waiting | Event that occurs when buffering occurs |
volumechange | Event that occurs when the volume changes (including mute) |
controlbarActive | Event that occurs when the control bar has been enabled |
controlbarDeactive | Event that occurs when the control bar has been disabled |
fullscreen | Event that occurs when full screen state changes |
fullscreen_on | Event that occurs when full screen is on |
fullscreen_off | Events that occur when full screen is off
|
timeupdate | Event that occurs when current play time changes (see timeupdate script) |
prevTrack | Event that occurs when moving to the previous video (see prevTrack script) |
nextTrack | Event that occurs when moving to the next video (see nextTrack script) |
timeupdate script
The followings are the explanation on script and properties for the timeupdate event:
let player = new ncplayer('myElement', {
playlist: [
{
file:"http://example.com/myVideo.mp4",
poster:"http://example.com/myVideoThumb.png"
}
]
});
player.on('timeupdate',(data)=>{
console.log('Total duration of the video (duration): ',data.duration);
console.log('Current playback position (currentTime): ',data.currentTime);
console.log('Current playback percentage (percent): ',data.percent);
console.log('Accumulated playback time (viewingTime): ',data.viewingTime);
Console.log('playback source type (sourceType): ',data.sourceType); // Playback source type(vod, live)
})
Property | Type | Description |
---|---|---|
duration | int | Total duration of the video |
currentTime | int | Current playback position |
percent | int | Current playback rate |
viewingTime | int | Accumulated playback time |
sourceType | string | Playback source type |
prevTrack script
The followings are the details on scripts and each property for prevTrack event:
let player = new ncplayer('myElement', {
playlist: [
{
file:"http://example.com/myVideo.mp4",
poster:"http://example.com/myVideoThumb.png"
},
{
file:"http://example.com/myVideo2.mp4",
poster:"http://example.com/myVideoThumb2.png"
}
]
});
player.on('prevTrack',(data)=>{
console.log('prevTrack' , data);
})
Property | Type | Description |
---|---|---|
file | string | Video URL |
poster | string | Thumbnail image |
title | string | Video title |
created_at | string | Video date |
profile_name | string | Profile name |
profile_image | string | Profile image |
nextTrack script
The following are the explanation on script and each property for the nextTrack event:
let player = new ncplayer('myElement', {
playlist: [
{
file:"http://example.com/myVideo.mp4",
poster:"http://example.com/myVideoThumb.png"
},
{
file:"http://example.com/myVideo2.mp4",
poster:"http://example.com/myVideoThumb2.png"
}
]
});
player.on('nextTrack',(data)=>{
console.log('nextTrack' , data);
})
Property | Type | Description |
---|---|---|
file | string | Video URL |
poster | string | Thumbnail image |
title | string | Video title |
created_at | string | Video date |
profile_name | string | Profile name |
profile_image | string | Profile image |