시작하기
이 플러그인의 설치 단계와 전체 마크다운 가이드를 포함한 설정 프롬프트를 복사하세요.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-media-session`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/media-session/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
설치
설치 제목bun add @capgo/capacitor-media-sessionbunx cap syncimport
import 제목import { MediaSession } from '@capgo/capacitor-media-session';API Overview
Section titled “API 개요”setMetadata
Section titled “메타데이터 설정”현재 재생 중인 미디어의 메타데이터를 설정합니다.
import { MediaSession } from '@capgo/capacitor-media-session';
await MediaSession.setMetadata({} as MetadataOptions);setPlaybackState
Section titled “재생 상태 설정”미디어 세션의 재생 상태를 업데이트합니다.
import { MediaSession } from '@capgo/capacitor-media-session';
await MediaSession.setPlaybackState({} as PlaybackStateOptions);setActionHandler
Section titled “액션 핸들러 등록”미디어 세션 액션에 대한 핸들러를 등록합니다.
import { MediaSession } from '@capgo/capacitor-media-session';
await MediaSession.setActionHandler({} as ActionHandlerOptions, {} as ActionHandler | null);setPositionState
Section titled “위치 상태 업데이트”활성 미디어 세션의 위치 상태를 업데이트합니다.
import { MediaSession } from '@capgo/capacitor-media-session';
await MediaSession.setPositionState({} as PositionStateOptions);타입 참조
타입 참조 섹션MetadataOptions
메타데이터 옵션 섹션export interface MetadataOptions { album?: string; artist?: string; artwork?: MediaImage[]; title?: string;}PlaybackStateOptions
재생 상태 옵션 섹션export interface PlaybackStateOptions { playbackState: MediaSessionPlaybackState;}ActionHandlerOptions
액션 핸들러 옵션 섹션export interface ActionHandlerOptions { action: MediaSessionAction;}ActionHandler
액션 핸들러 섹션export type ActionHandler = (details: ActionDetails) => void;PositionStateOptions
위치 상태 옵션 섹션export interface PositionStateOptions { duration?: number; playbackRate?: number; position?: number;}MediaImage
미디어 이미지 섹션export interface MediaImage { src: string; sizes?: string; type?: string;}MediaSessionPlaybackState
미디어 세션 재생 상태 섹션export type MediaSessionPlaybackState = 'none' | 'paused' | 'playing';MediaSessionAction
미디어 세션 액션 섹션export type MediaSessionAction = | 'play' | 'pause' | 'seekbackward' | 'seekforward' | 'previoustrack' | 'nexttrack' | 'seekto' | 'stop';진실의 근원
진실의 근원 섹션이 페이지는 플러그인의 src/definitions.tsAPI이 업스트림에서 변경될 때 다시 동기화할 수 있습니다.