Web
    • PDF

    Web

    • PDF

    Article Summary

    Classic/VPC 환경에서 이용 가능합니다.

    Web에서는 웹 환경에서 Video Player Enhancement의 플레이어를 적용하는 방법과 플레이어 옵션을 설정하는 방법을 설명합니다.

    참고

    웹 환경에서 플레이어를 적용하고 설정하려면 다음과 같은 환경이 요구됩니다.

    플레이어 적용

    웹 페이지에 플레이어를 적용하는 방법은 다음과 같습니다.

    참고

    웹 페이지에 플레이어를 적용하려면 1개 이상의 플레이어가 존재해야 합니다.

    1. 네이버 클라우드 플랫폼 콘솔의 Region 메뉴와 Platform 메뉴에서 이용 중인 환경을 클릭해 주십시오.
    2. Services > Media > Video Player Enhancement 메뉴를 차례대로 클릭해 주십시오.
    3. Video Player Management 메뉴를 클릭해 주십시오.
    4. 적용할 플레이어의 [SDK 주소] 버튼을 클릭해 주십시오.
    5. SDK 주소[복사] 버튼을 클릭해 주십시오.
      • 해당 플레이어의 SDK 주소가 클립보드에 복사됩니다.
    6. 복사한 SDK 주소를 다음과 같이 웹 페이지의 HTML에 추가해 주십시오.
      <script src="player 목록의 Player SDK URL"></script>
      

    플레이어 설정

    플레이어의 옵션은 네이버 클라우드 플랫폼 콘솔에서 손쉽게 미리 설정할 수 있으며(플레이어 설정 참고), 각각의 속성을 설정하여 플레이어를 커스터마이징할 수도 있습니다.
    플레이어의 기본 구조는 다음과 같습니다.

    new ncplayer("HTMLElement id" , {
        playlist:[                
            { file:"http://example.com/myVideo.mp4" }
        ]
    });
    

    플레이어 옵션

    커스터마이징할 수 있는 옵션은 다음과 같습니다.

    참고

    이용 중인 요금제에 따라 설정할 수 있는 옵션에 차이가 있습니다.

    요금제프로퍼티(속성)유형설명기본값옵션값필수 여부
    Basic / Standardplaylistarray플레이리스트--O
    autostartboolean자동 재생true-X
    mutedboolean음소거false-X
    keyboardShortcutboolean키보드 단축키true-X
    controlsboolean컨트롤바 사용 여부true-X
    uistringUI 설정all
  • all: 자동 변환
  • pc: PC 전용 UI 고정
  • mobile: 모바일 전용 UI 고정
  • X
    aspectRatiostring화면 비율16/916/9, 4/3, 1/1, 9/16, 21/9X
    objectFitstring화면 맞춤contain
  • contain: 비율 맞춤
  • cover: 비율 맞춤 + 꽉 채움
  • fill: 비율 무시 + 꽉 채움
  • X
    autoPauseboolean탭 비활성화 시 자동 멈춤false-X
    repeatboolean반복 재생false-X
    langstringUI 언어 설정auto
  • auto: 언어 감지
  • ko: 한국어
  • en: 영어
  • ja: 일본어
  • zh: 중국어
  • StandardcontrolBtnarray다음과 같은 옵션 설정
    • play boolean: 플레이 버튼
    • fullscreen boolean: 전체화면 전환
    • volume boolean: 볼륨 컨트롤
    • times boolean: 시간 정보 UI
    • pictureInPicture boolean: 미니 플레이어
    • setting boolean: 세팅 버튼
    controlBtn: {
      play: true,
      fullscreen: true,
      volume: true,
      itmes: true,
      pictureInPicture: true,
      setting: true
    },
    -X
    progressBarColorstring컨트롤바 색상#4299f5-X
    controlActiveTimenumber컨트롤바 활성 시간(ms)3000-X
    startMutedInfoNotVisibleboolean음소거 알림false-X
    playRateSettingarray배속 선택 옵션[0.5,0.75,1,1.5,2]-X
    seekingPreviewboolean영상 구간 이동 미리 보기true-X
    touchGesturesboolean터치 제스처true-X
    descriptionNotVisibleboolean메타데이터false-X
    lowLatencyModebooleanCMAF LL-HLSfalse-X

    Playlist

    재생 소스 설정에 대한 속성 정보는 다음과 같습니다.

    요금제프로퍼티(속성)유형설명옵션 예제필수 여부
    Basic / Standardfilestring재생하고자 하는 영상 정보
    • hls, dash, mp4 지원
    sources로 대체 가능O
    sourcesarray영상에 여러 가지 해상도를 제공하는 경우 사용하며, 다음과 같은 속성을 가짐
    • file string: 해상도별 영상 파일 경로
    • label string: 해상도 조절 컨트롤에 표시되는 텍스트
    • default boolean: 기본 해상도 적용
    file로 대체 가능O
    posterstring영상 재생 전 표시할 이미지-X
    Standarddescriptionarray플레이어 상단에 표시할 메타데이터로, 다음과 같은 속성을 가짐
    • title string: 제목
    • created_at string: 날짜
    • profile_name string: 채널명 또는 업로더 닉네임
    • profile_image string: 채널 이미지 또는 업로더 프로필 이미지
    • callback function: 메타데이터 클릭 시 발생하는 이벤트
    description: {
      title: "제목",
      created_at: "날짜",
      profile_name: "업로더 닉네임",
      profile_image: "채널 이미지",
      callback(){
        location.href='...'
      }
    }
    X

    Method

    Video Player Enhancement는 영상을 재생하고 다양한 기능을 구현할 수 있는 여러 가지 메소드를 제공합니다.

    참고

    ncplayer 객체가 만들어진 상태에서만 메소드를 호출할 수 있습니다.

    플레이어를 생성하고 재생하는 스크립트는 다음과 같습니다.

    let player = new ncplayer('myElement', {
        playlist: [
            { 
                file:"http://example.com/myVideo.mp4",
                poster:"http://example.com/myVideoThumb.png" 
            }
        ]
    });
    player.play();
    

    지원하는 Method

    Video Player Enhancement에서 지원하는 메소드는 다음과 같습니다.

    메소드설명
    ncplayer.play()영상 재생
    ncplayer.pause()영상 일시정지
    ncplayer.prev()이전 영상이 있는 경우, 이전 영상 재생
    ncplayer.next()다음 영상이 있는 경우, 다음 영상 재생
    ncplayer.mute()영상 음소거
    ncplayer.controlBarActive()플레이어 컨트롤바 UI 활성화
    ncplayer.controlBarDeactive()플레이어 컨트롤바 UI 비활성화
    ncplayer.fullscreen()전체화면으로 전환
    ncplayer.pip()미니 플레이어로 전환
    ncplayer.volume(value)볼륨 조절
    • 0.0~1 사잇값으로 설정
    ncplayer.currentTime(value)현재 재생 중인 영상의 시간을 변경
    • 현재 재생 중인 영상의 재생 시간을 초 단위로 설정하여 변경
      <예시> 3분 20초 -> 200
    ncpplayer.on(type, listner)이벤트 수신
    • type string: 수신할 이벤트명, 이벤트 목록(지원하는 이벤트 참고)
    • listner function: 이벤트가 발생하면 호출시킬 함수 전달

    이벤트

    Video Player Enhancement는 사용자를 위한 여러 가지 이벤트를 제공하며, 메타데이터 클릭 시 발생시킬 이벤트를 설정할 수 있습니다.

    참고

    이벤트 기능은 Standard 요금제에서만 제공됩니다.

    이벤트는 다음과 같이 수신할 수 있습니다.

    let player = new ncplayer('myElement', {
        playlist: [
            { 
                file:"http://example.com/myVideo.mp4",
                poster:"http://example.com/myVideoThumb.png" 
            }
        ]
    });
    
    player.on('play',(e)=>{
        console.log('Play 되었습니다.',e);
    })
    

    지원하는 이벤트

    Video Player Enhancement에서 지원하는 이벤트는 다음과 같습니다.

    Event설명
    play영상 재생 요청이 성공하였을 때 발생하는 이벤트
    pause영상이 일시정지되었을 때 발생하는 이벤트
    ready플레이어가 재생할 준비가 완료되었을 때 발생하는 이벤트
    ended재생이 끝까지 완료되었을 때 발생하는 이벤트
    seekingseek 동작을 시작할 때 발생하는 이벤트
    seekedseek 동작이 완료되었을 때 발생하는 이벤트
    waiting버퍼링이 발생하였을 때 발생하는 이벤트
    volumechange볼륨이 변경될 때 발생하는 이벤트(음소거 포함)
    controlbarActive컨트롤바가 활성화되었을 때 발생하는 이벤트
    controlbarDeactive컨트롤바가 비활성화되었을 때 발생하는 이벤트
    fullscreen전체화면 상태가 변경되었을 때 발생하는 이벤트
    fullscreen_on전체화면이 시작되었을 때 발생하는 이벤트
    fullscreen_off전체화면이 종료되었을 때 발생하는 이벤트
    • iOS(iPhone) 모바일웹에서는 사용 불가
    timeupdate현재 재생 시간이 변경될 때 발생하는 이벤트(timeupdate 스크립트 참고)
    nextTrack다음 영상으로 넘어갈 때 발생하는 이벤트(nextTrack 스크립트 참고)
    prevTrack이전 영상으로 넘어갈 때 발생하는 이벤트(prevTrack 스크립트 참고)

    timeupdate 스크립트

    let player = new ncplayer('myElement', {
        playlist: [
            { 
                file:"http://example.com/myVideo.mp4",
                poster:"http://example.com/myVideoThumb.png" 
            }
        ]
    });
    
    player.on('timeupdate',(data)=>{
        console.log('영상 전체 길이 (duration) : ',data.duration);
        console.log('현재 재생 위치 (currentTime) : ',data.currentTime);
        console.log('현재 재생 퍼센트 (percent) : ',data.percent);
        console.log('누적 재생 시간 (viewingTime) : ',data.viewingTime);
        console.log('재생소스 타입 (sourceType) : ',data.sourceType); //재생소스 타입 (vod , live)
    })
    

    각 속성에 대한 설명은 다음과 같습니다.

    프로퍼티(속성)유형설명
    durationint영상 전체 길이
    currentTimeint현재 재생 위치
    percentint현재 재생 퍼센트
    viewingTimeint누적 재생 시간
    sourceTypestring재생 소스 타입

    nextTrack 스크립트

    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);
    })
    

    각 속성에 대한 설명은 다음과 같습니다.

    프로퍼티(속성)유형설명
    filestring영상 URL
    posterstring썸네일 이미지
    titlestring영상 제목
    created_atstring영상 날짜
    profile_namestring프로필 이름
    profile_imagestring프로필 이미지

    prevTrack 스크립트

    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);
    })
    

    각 속성에 대한 설명은 다음과 같습니다.

    프로퍼티(속성)유형설명
    filestring영상 URL
    posterstring썸네일 이미지
    titlestring영상 제목
    created_atstring영상 날짜
    profile_namestring프로필 이름
    profile_imagestring프로필 이미지

    이 문서가 도움이 되었습니까?

    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.