Web environment

Prev Next

Available in Classic and VPC

The Web environment describes how to apply players of Video Player Enhancement and set player options in the web environment.

Note

The following environment is required to apply and set the player in a web environment:

Apply player

To apply a player to a web page, follow these steps:

Note

To apply a player to a web page, at least 1 player must exist. To create a player, see Create a player.

  1. Click the environment you are using in the Region menu and the Platform menu on the NAVER Cloud Platform console.
  2. Click Services > Media > Video Player Enhancement in order.
  3. Click the Video Player Management menu.
  4. Click the [SDK address] button for the player to apply to the web environment in the player’s list.
  5. 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.
  6. Add the copied SDK address to the HTML of the web page as follows:
    
    

Set up player

Player options can be easily preset on the 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:

Note

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
keyboardShortcut boolean Keyboard shortcuts true - X
controls boolean Whether to use control bar true - X
ui string UI settings all
  • all: automatic conversion
  • pc: PC-only UI fixed
  • mobile: mobile-only UI fixed
  • X
    aspectRatio string Aspect ratio 16/9 16/9, 4/3, 1/1, 9/16, 21/9 X
    objectFit string Customized screen contain
  • contain: proportion fit
  • cover: proportion fit + full
  • fill: ignoring proportion + full
  • X
    autoPause boolean Auto stop when the tab is disabled false - X
    repeat boolean Repeated playback false - X
    lang string UI language settings auto
  • auto: language recognition
  • ko: Korean
  • en: English
  • ja: Japanese
  • zh: Chinese
  • -
    Standard controlBtn array Set the following options:
    • play boolean: play button
    • fullscreen boolean: switch to full screen
    • volume boolean: volume control
    • times boolean: time information UI
    • pictureInPicture boolean: mini player
    • setting boolean: setting button
    • progressBar boolean: enable playback bar
    controlBtn: {
      play: true,
      fullscreen: true,
      volume: true,
      times: true,
      pictureInPicture: true,
      setting: true,
      progressBar : true
    },
    - X
    customBtns array Set the following options:
    • ui string: UI installed
    • id string: DOM ID of a button
    • position string: button position in a player
    • icon string: button image URL
    • flow string: button creation location in a position (based on default button)
    • callback function: event occurring when clicking a button
    -
  • ui
      • pc: pc preference settings
      • mobile: mobile configuration settings
  • position
      • right-top: top right
      • right-bottom: bottom right
      • Left-top: top left
      • left-bottom: bottom left
  • flow
      • right
      • left
    X
    progressBarColor string Color of control bar #4299f5 - X
    controlActiveTime number Control bar active time (ms) 3000 - X
    startMutedInfoNotVisible boolean Mute indication 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:
    • randPosition boolean: to enable watermark random position (true: random, false: fixed)
    • randPositionInterVal number: random change time of watermark position (1000=1 second)
    • x number: horizontal position %
    • y number: vertical position %
    • opacity number: transparency (0.1 to 1)
    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://CDN도메인/example_video_01.mp4',
                poster: 'https://CDN도메인/example_image_01.png',
            }
        ],
        controlBtn:{
        play:true,
        fullscreen:true,
        volume:true,
        times:true,
        pictureInPicture:true,
        setting:true,
        subtitle:true,
    },
    
    icon:{
            bigPlay:"https://CDN도메인/icon/play-circle-fill.svg", // Big play button before autoplay
            play:"https://CDN도메인/icon/play-fill.svg", // Playback
            use:"https://CDN도메인/icon/pause-fill.svg", // Pause
            prev:"https://CDN도메인/icon/skip-back-fill.svg", // Previous video
            next:"https://CDN도메인/icon/skip-forward-fill.svg", // Next video
            replay:"https://CDN도메인/icon/arrow-clockwise-fill.svg", // Replay
            subtitle:"https://CDN도메인/icon/closed-captioning-fill.svg", // Subtitle on
            subtitleOff:"https://CDN도메인/icon/closed-captioning.svg", // Subtitle off
            fullscreen:"https://CDN도메인/icon/corners-out.svg", // Switch to full screen
            fullscreenExit:"https://CDN도메인/icon/corners-in.svg", // Exit full screen
            volumeFull:"https://CDN도메인/icon/speaker-simple-high-fill.svg", // Maximum volume
            volumeMute:"https://CDN도메인/icon/speaker-simple-x-fill.svg", // Volume 0 , Mute
            volumeMid:"https://CDN도메인/icon/speaker-simple-low-fill.svg", // Medium volume
            pip:"https://CDN도메인/icon/picture-in-picture-fill.svg", // PIP
            setting:"https://CDN도메인/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://CDN도메인/example_video_01.mp4',
                poster: 'https://CDN도메인/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://CDN도메인/example_video_01.mp4',
                poster: 'https://CDN도메인/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
    Basic/Standard file string
    • Video information that you want to play
      • Supports hls, dash, and mp4
    • Can be replaced with sources
    playlist: [
      {
        file: 'https://CDNdomain/example_video_01.mp4',
      }
    ]
    O
    sources array
    • Use when providing various resolutions for the video, and has the following properties:
      • file string: path to the video file for each resolution
      • label string: text displayed on the resolution adjustment control
      • default boolean: apply default resolution
    • Can be replaced with file
    - 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:
    • title string: title
    • created_at string: date
    • profile_name string: channel name or uploader nickname
    • profile_image string: channel image or uploader profile image
    • callback function: event that occurs when metadata is clicked
    description: {
      title: "title",
      created_at: "Date",
      profile_name: "Uploader nickname",
      profile_image: "Channel image",
      callback(){
        location.href='...'
      }
    }
    X

    Method

    The Video Player Enhancement service provides various methods to play a video and implement various functions.

    Note

    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) Adjust the volume
    • Set between 0.0 and 1
    ncplayer.currentTime(value) Change the time of the video currently playing
    • Change the playback time of the video currently playing by setting it in seconds
      <example> 3 minutes 20 seconds -> 200
    ncpplayer.on(type, listner) Receive event
    • type string: name of the event to receive, event list (see Supported Events)
    • listner function: send function to call when an event occurs

    Event

    The Video Player Enhancement service provides various events and configures events occurring when clicking metadata.

    Note

    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 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
    • Not available on iOS (iPhone) mobile web
    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 is 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