메뉴로 바로가기

Getting Started

GitHub

__CAPGO_KEEP_10__

설치 및 동기화

AI-Assisted 설치를 사용하여 플러그인을 설치할 수 있습니다. 다음 명령어를 사용하여 Capgo 기능을 AI 도구에 추가하세요:

터미널 창
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

다음과 같은 프롬프트를 사용하세요:

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-youtube-player` plugin in my project.

만약 Manual Setup을 선호한다면, 플러그인을 설치하기 위해 다음 명령어를 실행하고 아래의 플랫폼별 지침을 따르세요:

터미널 창
bun add @capgo/capacitor-youtube-player
bunx cap sync
import { YoutubePlayer } from '@capgo/capacitor-youtube-player';

메인 웹뷰에서 YouTube Referer 차단을 고치세요

Section titled “YouTube 메인 WebView에서 블록킹을 해결하세요”

YouTube가 플러그인 내에서 작동하지만 동일한 앱이 YouTube 페이지, 임베드, 또는 Capacitor의 메인 WebView를 통해 로드하거나 API를 호출할 때 실패하는 경우, patchRefererHeader Capacitor 설정에서

When enabled, the plugin patches Capacitor during sync/update so intercepted YouTube requests include a valid Referer 활성화하면 플러그인이 __CAPGO_KEEP_0__을 sync/update 중에 패치하여 유투브 요청에 유효한

{
"plugins": {
"YoutubePlayer": {
"patchRefererHeader": true,
"refererHeader": "https://www.youtube.com"
}
}
}
  • 클립보드에 복사 youtube.com, youtube-nocookie.comOnly youtu.be ,
  • 요청만 영향을 받습니다. Referer 이미
  • refererHeader 헤더를 정의한 요청은 원래 값이 유지됩니다. https://www.youtube.com.
  • Capacitor 8.x iOS 및 Android 플랫폼에 설치된 경우 지원됩니다.

새로운 YouTube 플레이어 인스턴스를 초기화합니다.

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.initialize({
playerId: 'my-player',
videoId: 'dQw4w9WgXcQ',
playerSize: { width: 640, height: 360 },
privacyEnhanced: true
});

플레이어 인스턴스를 소멸시키고 자원들을 해제합니다.

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.destroy({} as PlayerIdOptions);

__CAPGO_KEEP_0__

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.stopVideo({} as PlayerIdOptions);

__CAPGO_KEEP_2__

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.playVideo({} as PlayerIdOptions);

__CAPGO_KEEP_3__

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.pauseVideo({} as PlayerIdOptions);

__CAPGO_KEEP_0__

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.seekTo({} as SeekToOptions);

loadVideoById

__CAPGO_KEEP_0__

__CAPGO_KEEP_6__

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.loadVideoById({} as VideoByIdMethodOptions);

ID로 비디오를 큐합니다. (재생하지 않음). 썸네일을 로드하고 플레이어를 준비하지만, 비디오를 요청할 때까지 playVideo()를 호출합니다.

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.cueVideoById({} as VideoByIdMethodOptions);

URL로 비디오를 로드하고 재생합니다.

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.loadVideoByUrl({} as VideoByUrlMethodOptions);

URL로 비디오를 큐합니다. (재생하지 않음).

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.cueVideoByUrl({} as VideoByUrlMethodOptions);

플레이리스트를 큐합니다. (재생하지 않음). 플레이리스트를 로드하고 첫 번째 비디오를 준비합니다.

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.cuePlaylist({} as PlaylistMethodOptions);

__CAPGO_KEEP_2__을 불러와 재생합니다.

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.loadPlaylist({} as PlaylistMethodOptions);

재생목록에서 다음 비디오를 재생합니다.

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.nextVideo({} as PlayerIdOptions);

재생목록에서 이전 비디오를 재생합니다.

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.previousVideo({} as PlayerIdOptions);

재생목록에서 특정 비디오를 인덱스에 따라 재생합니다.

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.playVideoAt({} as PlayVideoAtOptions);

__CAPGO_KEEP_2__

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.mute({} as PlayerIdOptions);

__CAPGO_KEEP_3__

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.unMute({} as PlayerIdOptions);

__CAPGO_KEEP_4__

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.isMuted({} as PlayerIdOptions);

__CAPGO_KEEP_5__

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.setVolume({} as SetVolumeOptions);

__CAPGO_KEEP_2__

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.getVolume({} as PlayerIdOptions);

__CAPGO_KEEP_0__

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.setSize({} as SetSizeOptions);

getPlaybackRate

__CAPGO_KEEP_0__

__CAPGO_KEEP_5__

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.getPlaybackRate({} as PlayerIdOptions);

setPlaybackRate

__CAPGO_KEEP_6__

__CAPGO_KEEP_0__

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.setPlaybackRate({} as SetPlaybackRateOptions);

getAvailablePlaybackRates

getAvailablePlaybackRates 섹션

현재 비디오의 사용 가능한 재생 속도 목록을 가져옵니다.

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.getAvailablePlaybackRates({} as PlayerIdOptions);

재생 목록을 반복할지 여부를 설정합니다. 반복이 활성화되면 마지막 비디오 후에 재생 목록은 처음부터 다시 시작됩니다.

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.setLoop({} as SetLoopOptions);

재생 목록을 무작위로 재생할지 여부를 설정합니다.

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.setShuffle({} as SetShuffleOptions);

getVideoLoadedFraction

getVideoLoadedFraction 섹션

비디오가 버퍼링된 비율을 가져옵니다. getVideoBytesLoaded/getVideoBytesTotal과 같은 deprecated 함수보다 더 신뢰할 수 있습니다.

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.getVideoLoadedFraction({} as PlayerIdOptions);

플레이어의 현재 상태를 가져옵니다.

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.getPlayerState({} as PlayerIdOptions);

활성 플레이어의 여러 인스턴스 추적을 위해 이벤트 상태를 가져옵니다.

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.getAllPlayersEventsState();

재생 중인 현재 위치를 초 단위로 가져옵니다.

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.getCurrentTime({} as PlayerIdOptions);

전체 화면 모드가 켜져 있으면 끄고, 끌려면 켭니다.

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.toggleFullScreen({} as ToggleFullScreenOptions);

getPlaybackQuality

재생 품질 가져오기

현재 재생 품질을 가져옵니다.

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.getPlaybackQuality({} as PlayerIdOptions);

setPlaybackQuality

재생 품질 설정

권장된 재생 품질을 설정합니다. 네트워크 상황에 따라 실제 품질이 다를 수 있습니다.

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.setPlaybackQuality({} as SetPlaybackQualityOptions);

복사

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.getAvailableQualityLevels({} as PlayerIdOptions);

getDuration

복사

현재 비디오의 길이를 초 단위로 가져옵니다.

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.getDuration({} as PlayerIdOptions);

getVideoUrl

getVideoUrl

현재 동영상의 YouTube.com URL을 가져옵니다.

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.getVideoUrl({} as PlayerIdOptions);

getVideoEmbedCode

getVideoEmbedCode

현재 동영상의 임베드 code을 가져옵니다. HTML iframe 임베드 code을 반환합니다.

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.getVideoEmbedCode({} as PlayerIdOptions);

getPlaylist

getPlaylist

현재 플레이리스트의 동영상 ID 배열을 가져옵니다.

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.getPlaylist({} as PlayerIdOptions);

getPlaylistIndex

getPlaylistIndex

현재 플레이리스트에서 재생 중인 동영상의 인덱스를 가져옵니다.

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.getPlaylistIndex({} as PlayerIdOptions);

__CAPGO_KEEP_2__

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.getIframe({} as PlayerIdOptions);

addEventListener

__CAPGO_KEEP_1__

__CAPGO_KEEP_3__

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
YoutubePlayer.addEventListener({
playerId: 'my-player',
eventName: 'onStateChange',
listener: (event) => {
console.log('Player state:', event.data);
},
});

removeEventListener

__CAPGO_KEEP_1__

__CAPGO_KEEP_4__

import { YoutubePlayer } from '@capgo/capacitor-youtube-player';
await YoutubePlayer.removeEventListener({} as PlayerEventListenerOptions<TEvent>);

__CAPGO_KEEP_5__

__CAPGO_KEEP_1__
export interface PlayerIdOptions {
playerId: string;
}
export interface SeekToOptions extends PlayerIdOptions {
playerId: string;
seconds: number;
allowSeekAhead: boolean;
}
export interface VideoByIdMethodOptions extends PlayerIdOptions {
playerId: string;
options: IVideoOptionsById;
}
export interface VideoByUrlMethodOptions extends PlayerIdOptions {
playerId: string;
options: IVideoOptionsByUrl;
}
export interface PlaylistMethodOptions extends PlayerIdOptions {
playerId: string;
playlistOptions: IPlaylistOptions;
}
export interface PlayVideoAtOptions extends PlayerIdOptions {
playerId: string;
index: number;
}

SetVolumeOptions

SetVolumeOptions
export interface SetVolumeOptions extends PlayerIdOptions {
playerId: string;
volume: number;
}

SetSizeOptions

SetSizeOptions
export interface SetSizeOptions extends PlayerIdOptions {
playerId: string;
width: number;
height: number;
}

SetPlaybackRateOptions

SetPlaybackRateOptions
export interface SetPlaybackRateOptions extends PlayerIdOptions {
playerId: string;
suggestedRate: number;
}

SetLoopOptions

SetLoopOptions
export interface SetLoopOptions extends PlayerIdOptions {
playerId: string;
loopPlaylists: boolean;
}

SetShuffleOptions

SetShuffleOptions
export interface SetShuffleOptions extends PlayerIdOptions {
playerId: string;
shufflePlaylist: boolean;
}

ToggleFullScreenOptions

ToggleFullScreenOptions
export interface ToggleFullScreenOptions extends PlayerIdOptions {
playerId: string;
isFullScreen: boolean | null | undefined;
}

원본

원본

이 페이지는 플러그인의 src/definitions.ts공개 API이 업스트림에서 변경될 때 다시 싱크를 실행하세요.

시작부터 계속

시작부터 계속

이 플러그인을 사용하는 경우 시작 대시보드와 API 운영을 계획하려면 Using @capgo/capacitor-youtube-player Using @capgo/capacitor-youtube-player API 개요 API 개요에 대한 구현 세부 정보를 위해 소개 __CAPGO_KEEP_0__ 키에 대한 구현 세부 정보를 위해 API 키 API 키 및 장치에 대한 구현 세부 정보를 위해 장치 __CAPGO_KEEP_0__에 대한 구현 세부 정보를 위해