Available in Classic and VPC
This section explains how to apply the Video Player Enhancement player and configure player options in a web environment.
The following environment is required to apply and configure the player in a web environment:
- An environment capable of external communication.
- A Chromium-based browser that complies with web standards (see web browser support specifications).
Apply player
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.
- Navigate toMenu > Services > Media > Video Player Enhancement from the NAVER Cloud Platform console.
- Click the Video Player Management menu.
- In the player list, click the [SDK address] button of the player you want to apply to the web environment.
- Select the service environment to apply the player to, and then click the [Copy] button next to SDK address.
- 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:
<script src="플레이어의 SDK 주소"></script>
Set up player
Player options can be easily configured in the NAVER Cloud Platform console (see Player settings), or you can customize the player by configuring individual properties.
The basic structure of the player is as follows:
new ncplayer("HTMLElement id" , {
playlist:[
{ file:"http://example.com/myVideo.mp4" } // Playback source
]
});
Player options
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 |
|---|---|---|---|---|---|---|
| Basic/Standard | playlist | array | Playlist | - | - | O |
| autostart | boolean | Autoplay | true | - | X | |
| muted | boolean | Mute | false | - | X | |
| controls | boolean | Enable 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 | Screen fit | contain |
|
X | |
| autoPause | boolean | Auto-pause when the tab is inactive | false | - | X | |
| repeat | boolean | Loop 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, progressBar : true |
- | X |
| customBtns | array | Set the following options:
|
- |
|
X | |
| keyboardShortcut | boolean | Keyboard shortcuts | true | - | X | |
| progressBarColor | string | Control bar color | #4299f5 | - | X | |
| controlActiveTime | number | Control bar display duration (ms) | 3000 | - | X | |
| startMutedInfoNotVisible | boolean | Mute indication | false | - | X | |
| playRateSetting | array | Playback speed options | [0.5,0.75,1,1.5,2] | - | X | |
| seekingPreview | boolean | Video thumbnail preview | 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 default icon
You can modify the script code to change default icons. The example is 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", // Play
use:"https://CDNdomain/icon/pause-fill.svg", // Pause
prev:"https://CDNdomain/icon/skip-back-fill.svg", // Previous video
next:"https://CDNdomain/icon/skip-forward-fill.svg", // 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 | Play. |
| pause | Pause. |
| prev | Play previous video. |
| next | Play next video. |
| replay | Replay. |
| subtitle | Subtitle on. |
| subtitleOff | Subtitle off. |
| fullscreen | Full screen toggle. |
| fullscreenExit | Exit full screen. |
| volumeFull | Maximum volume. |
| volumeMute | Volume 0, mute. |
| volumeMid | Medium volume. |
| pip | PIP |
| setting | Settings. |
Override Picture In Picture feature
You can replace the provided PIP feature with a floating player feature within the website. The example is 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 player UI
// Write code to execute the custom floating player
// Example: floatingModeStart()
},
off(){
window.player.uiVisible(); // Show all player UI
// Write code to stop the custom floating player
// Example: floatingModeStop()
}
}
}
});
Hide floating player UI
If the PIP feature is replaced with a floating player, you can set whether to display the floating player's control UI.
This is a mandatory method to consider when implementing a floating player. In addition to the controlBarActive/controlBarDeactive methods, you can use the uiHidden method to hide all UI or the uiVisible method to display all UI.
The example is 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();
// Show control bar UI
player.uiVisible();
Playlist
The properties for setting the playback source are as follows:
| Pricing plan | Property | Type | Description | Option example | Required |
|---|---|---|---|---|---|
| Basic/Standard | file | string |
|
playlist: [
|
O |
| sources | array |
|
- | X | |
| poster | string | Image displayed before video playback. | - | X | |
| Standard | description | array | Metadata displayed at the top of the player, consisting of 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 features.
You can call a method after you create a player.
The script to create a player and play video 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 supported by the Video Player Enhancement service are as follows:
| Method | Description |
|---|---|
| ncplayer.play() | Play a video. |
| ncplayer.pause() | Pause a video. |
| ncplayer.prev() | If a previous video exists, play the previous video. |
| ncplayer.next() | If a next video exists, 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) | Adjust the volume.
|
| ncplayer.destroy() | Remove the player. |
| ncplayer.uiHidden() | Hide all player UIs. |
| ncplayer.uiVisible() | Show all player UIs. |
| ncplayer.fullscreenOn() | Launch full screen (control full screen from outside). |
| ncplayer.fullScreenOff() | Exit full screen (control full screen from outside). |
| ncplayer.currentTime(value) | Change the time of the currently playing video.
|
| ncpplayer.on(type, listner) | Receive event.
|
Event
The Video Player Enhancement service provides various events, and allows you to configure events triggered when clicking metadata.
Event features are only provided in the Standard pricing 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 supported by the Video Player Enhancement service are as follows:
| Event | Description |
|---|---|
| play | Event that occurs when a 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 completes. |
| 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 mode starts. |
| fullscreen_off | Event that occurs when full screen mode ends.
|
| 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 script for the timeupdate event, along with descriptions of each property, is as follows:
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 script for the prevTrack event, along with descriptions of each property, is as follows:
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 script for the nextTrack event, along with descriptions of each property, is as follows:
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 |