For web
    • PDF

    For web

    • PDF

    Article Summary

    Available in Classic and VPC

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

    Note

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

    Apply player

    The following shows how to apply a player to a web page:

    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.
    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 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:

    Note

    Configurable options may vary depending on the current pricing plan.

    Pricing planPropertyTypeDescriptionDefault valueOption valueRequired status
    Basic/StandardplaylistarrayPlaylist--O
    autostartbooleanAutoplaytrue-X
    mutedbooleanMutefalse-X
    keyboardShortcutbooleanKeyboard shortcuttrue-X
    controlsbooleanWhether to use control bartrue-X
    uistringUI settingsall
  • all: automatic conversion
  • pc: PC-only UI fixed
  • mobile: mobile-only UI fixed
  • X
    aspectRatiostringAspect ratio16/916/9, 4/3, 1/1, 9/16, 21/9X
    objectFitstringCustomized screencontain
  • contain: proportion fit
  • cover: proportion fit + full
  • fill: ignoring proportion + full
  • X
    autoPausebooleanAuto stop when the tab is disabledfalse-X
    repeatbooleanRepeated playbackfalse-X
    langstringUI language settingsauto
  • auto: language recognition
  • ko: Korean
  • en: English
  • ja: Japanese
  • zh: Chinese
  • -
    StandardcontrolBtnarraySet 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
    controlBtn: {
      play: true,
      fullscreen: true,
      volume: true,
      times: true,
      pictureInPicture: true,
      setting: true
    },
    -X
    customBtnsarraySet 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
    progressBarColorstringColor of control bar#4299f5-X
    controlActiveTimenumberControl bar active time (ms)3000-X
    startMutedInfoNotVisiblebooleanMute notificationsfalse-X
    playRateSettingarraySpeed options[0.5,0.75,1,1.5,2]-X
    seekingPreviewbooleanPreview video section movementtrue-X
    touchGesturesbooleanTouch gesturestrue-X
    descriptionNotVisiblebooleanMetadatafalse-X
    lowLatencyModebooleanCMAF LL-HLSfalse-X
    watermarkConfigarraySet 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 of (0.1 ~ 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://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
       }
    });
    
    PropertyDescription
    bigPlayBig play button before autoplay
    playPlayback
    pausePause
    prevPlay the previous video
    nextPlay the next video
    replayReplay
    subtitleSubtitle On
    subtitleOffSubtitle Off
    fullscreenSwitch to full screen
    fullscreenExitExit full screen
    volumeFullMaximum volume
    volumeMuteVolume 0, mute
    volumeMidMedium volume
    pipPIP
    settingSettings

    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 planPropertyTypeDescriptionOption examplesRequired status
    Basic/Standardfilestring
    • Video information that you want to play
      • Supports hls, dash, and mp4
    • Can be replaced withsources
    playlist: [
      {
        file: 'https://CDNdomain/example_video_01.mp4',
      }
    ]
    O
    sourcesarray
    • 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 withfile
    -X
    posterstringImage to be displayed before video playback-X
    StandarddescriptionarrayMetadata 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:

    MethodDescription
    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
    • 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 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:

    EventDescription
    playEvent that occurs when video playback request is successful
    pauseEvent that occurs when a video pauses
    readyEvent that occurs when a player is ready to play
    endedEvent that occurs when playback is completed to the end
    seekingEvent that occurs when the seek action starts
    seekedEvent that occurs when the seek action is completed
    waitingEvent that occurs when buffering occurs
    volumechangeEvent that occurs when the volume changes (including mute)
    controlbarActiveEvent that occurs when the control bar has been enabled
    controlbarDeactiveEvent that occurs when the control bar has been disabled
    fullscreenEvent that occurs when full screen state changes
    fullscreen_onEvent that occurs when full screen is on
    fullscreen_offEvents that occur when full screen is off
    • aren’t available on iOS mobile web
    timeupdateEvent that occurs when current play time changes (see timeupdate script)
    prevTrackEvent that occurs when moving to the previous video (see prevTrack script)
    nextTrackEvent 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)
    })
    
    PropertyTypeDescription
    durationintTotal duration of the video
    currentTimeintCurrent playback position
    percentintCurrent playback rate
    viewingTimeintAccumulated playback time
    sourceTypestringPlayback 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);
    })
    
    PropertyTypeDescription
    filestringVideo URL
    posterstringThumbnail image
    titlestringVideo title
    created_atstringVideo date
    profile_namestringProfile name
    profile_imagestringProfile 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);
    })
    
    PropertyTypeDescription
    filestringVideo URL
    posterstringThumbnail image
    titlestringVideo title
    created_atstringVideo date
    profile_namestringProfile name
    profile_imagestringProfile image

    Was this article helpful?

    What's Next
    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.