The @capgo/capacitor-video-player package provides native video playback capabilities for your Capacitor mobile applications on iOS and Android. This tutorial covers integrating full-featured video playback into your iOS and Android mobile apps built with Capacitor or Cordova, including fullscreen mode, subtitles, and comprehensive playback controls.
The @capgo/capacitor-video-player plugin brings native video playback to your iOS and Android mobile apps. Unlike web-based video players, this Capacitor plugin uses native iOS AVPlayer and Android ExoPlayer for optimal performance and battery efficiency on mobile devices. This works seamlessly in both Capacitor and Cordova mobile applications.
Native video playback is essential for professional iOS and Android mobile applications:
To install the @capgo/capacitor-video-player package for your Capacitor mobile app:
npm install @capgo/capacitor-video-player
npx cap sync
This syncs the video player with your native iOS and Android projects.
import { CapacitorVideoPlayer } from '@capgo/capacitor-video-player';
// Initialize video player for iOS and Android
const result = await CapacitorVideoPlayer.initPlayer({
mode: 'fullscreen',
url: 'https://example.com/video.mp4',
playerId: 'myPlayer',
subtitle: 'https://example.com/subtitles.vtt'
});
console.log('Video player ready for mobile device');
// Play video on iOS or Android
await CapacitorVideoPlayer.play({ playerId: 'myPlayer' });
// Pause video on mobile device
await CapacitorVideoPlayer.pause({ playerId: 'myPlayer' });
// Seek to position in mobile app
await CapacitorVideoPlayer.setCurrentTime({
playerId: 'myPlayer',
seektime: 30 // seconds
});
// Adjust volume on iOS or Android
await CapacitorVideoPlayer.setVolume({
playerId: 'myPlayer',
volume: 0.8
});
You have successfully integrated native video playback into your Capacitor mobile application for iOS and Android. This plugin provides professional-grade video playback using native iOS and Android video players.
For detailed API documentation, visit the GitHub repository.