@capgo/capacitor-video-player 사용
네이티브 플레이어로 비디오를 재생하는 Capacitor 플러그인.
설치
bun add @capgo/capacitor-video-player
bunx cap sync
bunx cap sync 플러그인의 네이티브 code를 네이티브 프로젝트에 복사합니다. 플러그인을 업그레이드할 때마다 다시 실행하세요.
가져오기
import { VideoPlayer } from '@capgo/capacitor-video-player';
API 한눈에 보기
| 메서드 | 설명 |
|---|---|
initPlayer |
비디오 플레이어를 초기화합니다. |
isPlaying |
지정된 playerId가 재생 중인지 확인합니다. |
play |
지정된 playerId의 현재 비디오를 재생합니다. |
pause |
지정된 playerId의 현재 비디오를 일시 정지합니다. |
getDuration |
지정된 playerId의 현재 비디오 재생 시간을 가져옵니다. |
getCurrentTime |
지정된 playerId의 현재 비디오 재생 위치를 가져옵니다. |
setCurrentTime |
지정된 playerId의 비디오 재생 위치를 설정합니다. |
getVolume |
지정된 playerId의 현재 비디오 볼륨을 가져옵니다. |
setVolume |
지정된 playerId의 현재 비디오 볼륨을 설정합니다. |
getMuted |
지정된 playerId의 현재 비디오 음소거 여부를 가져옵니다. |
setMuted |
지정된 playerId의 현재 비디오 음소거 여부를 설정합니다. |
setRate |
지정된 playerId의 현재 비디오 재생 속도를 설정합니다. |
getRate |
지정된 playerId의 현재 비디오 재생 속도를 가져옵니다. |
stopAllPlayers |
재생 중인 모든 플레이어를 중지합니다. |
showController |
컨트롤러를 표시합니다. |
isControllerIsFullyVisible |
컨트롤러가 완전히 보이는지 여부. |
exitPlayer |
플레이어를 종료합니다. |
hidePlayer |
재생을 중단하지 않고 현재 표시된 플레이어 UI를 숨깁니다 (네이티브 전체화면). |
showPlayer |
이전에 숨겼던 플레이어 UI를 다시 표시합니다 (네이티브 전체화면). |
예시
initPlayer()
비디오 플레이어를 초기화합니다.
import { VideoPlayer } from '@capgo/capacitor-video-player';
const result = await VideoPlayer.initPlayer({ mode: 'fullscreen' });
console.log(result);
isPlaying()
지정된 playerId가 재생 중인지 여부를 반환합니다.
import { VideoPlayer } from '@capgo/capacitor-video-player';
const result = await VideoPlayer.isPlaying({ playerId: 'player-id-123' });
console.log(result);
play()
지정된 playerId의 현재 비디오를 재생합니다.
import { VideoPlayer } from '@capgo/capacitor-video-player';
const result = await VideoPlayer.play({ playerId: 'player-id-123' });
console.log(result);
pause()
지정된 playerId를 사용하여 현재 재생 중인 비디오를 일시 정지합니다.
import { VideoPlayer } from '@capgo/capacitor-video-player';
const result = await VideoPlayer.pause({ playerId: 'player-id-123' });
console.log(result);
getDuration()
지정된 playerId를 사용하여 현재 비디오의 재생 시간을 가져옵니다.
import { VideoPlayer } from '@capgo/capacitor-video-player';
const result = await VideoPlayer.getDuration({ playerId: 'player-id-123' });
console.log(result);
getCurrentTime()
지정된 playerId를 사용하여 현재 비디오의 현재 재생 시점을 가져옵니다.
import { VideoPlayer } from '@capgo/capacitor-video-player';
const result = await VideoPlayer.getCurrentTime({ playerId: 'player-id-123' });
console.log(result);
위 표에는 19개의 핵심 메서드가 나열되어 있습니다. Listener 및 버전 헬퍼, 각 메서드의 전체 계약(contract)은 다음에서 확인할 수 있습니다. GitHub 리포지토리.
전체 레퍼런스
@capgo/capacitor-video-player 사용법 계속 보기
사용 중이라면 @capgo/capacitor-video-player 사용 네이티브 미디어 및 인터페이스 동작을 계획하려면, 이를 다음 항목과 연결하세요: @capgo/capacitor-video-player @capgo/capacitor-video-player 구현 상세 정보는, 시작하기 Getting Started의 구현 상세 내용은 @capgo/capacitor-live-activities 사용 @capgo/capacitor-live-activities 사용에서의 네이티브 기능, @capgo/capacitor-live-activities @capgo/capacitor-live-activities의 구현 세부 사항은, 그리고 @capgo/capacitor-native-navigation 사용하기 @capgo/capacitor-native-navigation. 사용 시의 Native 기능