はじめる
インストール
Section titled “インストール”npm install @capgo/capacitor-ricoh360-cameranpx cap syncyarn add @capgo/capacitor-ricoh360-cameranpx cap syncpnpm add @capgo/capacitor-ricoh360-cameranpx cap syncbun add @capgo/capacitor-ricoh360-cameranpx cap syncプラットフォーム構成
Section titled “プラットフォーム構成”カメラと写真ライブラリの権限を Info.plist に追加します。
<key>NSCameraUsageDescription</key><string>This app needs access to the camera to capture 360° photos and videos</string><key>NSPhotoLibraryAddUsageDescription</key><string>This app needs access to save 360° photos and videos to your library</string>Android
Section titled “Android”必要な権限を AndroidManifest.xml に追加します。
<uses-permission android:name="android.permission.CAMERA" /><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /><uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /><uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />サポートされているデバイス
Section titled “サポートされているデバイス”このプラグインは、Ricoh Theta シリーズのカメラをサポートします。
- リコー Theta V
- リコー シータ Z1
- リコー シータ SC2
- リコーシータX
import { Ricoh360Camera } from '@capgo/capacitor-ricoh360-camera';
// Initialize camera connectionawait Ricoh360Camera.initialize();
// Connect to Ricoh Theta camera via WiFiawait Ricoh360Camera.connect({ ssid: 'THETAYL12345678', password: '12345678'});
// Start live previewawait Ricoh360Camera.startPreview({ container: 'preview-container' // ID of HTML element});
// Capture a 360° photoconst result = await Ricoh360Camera.capturePhoto();console.log('Photo saved:', result.filePath);
// Start recording 360° videoawait Ricoh360Camera.startRecording();
// Stop recording after some timesetTimeout(async () => { const video = await Ricoh360Camera.stopRecording(); console.log('Video saved:', video.filePath);}, 10000);
// Stop previewawait Ricoh360Camera.stopPreview();
// Disconnect from cameraawait Ricoh360Camera.disconnect();API リファレンス
Section titled “API リファレンス”initialize() => Promise<void>カメラプラグインを初期化します。
接続(オプション)
Section titled “接続(オプション)”connect(options: ConnectOptions) => Promise<void>WiFi 経由で Ricoh Theta カメラに接続します。
| パラム | タイプ |
|---|---|
options | ConnectOptions |
disconnect() => Promise<void>カメラから切断します。
startPreview(オプション)
Section titled “startPreview(オプション)”startPreview(options: PreviewOptions) => Promise<void>ライブ 360° プレビュー ストリームを開始します。
| パラム | タイプ |
|---|---|
options | PreviewOptions |
stopPreview()
Section titled “stopPreview()”stopPreview() => Promise<void>ライブ プレビュー ストリームを停止します。
キャプチャ写真(オプション?)
Section titled “キャプチャ写真(オプション?)”capturePhoto(options?: CaptureOptions) => Promise<CaptureResult>360° 写真を撮影します。
| パラム | タイプ |
|---|---|
options | CaptureOptions (オプション) |
戻り値: Promise<CaptureResult>
startRecording(オプション?)
Section titled “startRecording(オプション?)”startRecording(options?: RecordingOptions) => Promise<void>360°ビデオの録画を開始します。
| パラム | タイプ |
|---|---|
options | RecordingOptions (オプション) |
stopRecording()
Section titled “stopRecording()”stopRecording() => Promise<CaptureResult>ビデオ録画を停止します。
戻り値: Promise<CaptureResult>
getCameraInfo()
Section titled “getCameraInfo()”getCameraInfo() => Promise<CameraInfo>カメラの情報と機能を取得します。
戻り値: Promise<CameraInfo>
setExposure(オプション)
Section titled “setExposure(オプション)”setExposure(options: ExposureOptions) => Promise<void>カメラの露出設定を設定します。
| パラム | タイプ |
|---|---|
options | ExposureOptions |
setWhiteBalance(オプション)
Section titled “setWhiteBalance(オプション)”setWhiteBalance(options: WhiteBalanceOptions) => Promise<void>ホワイトバランスモードを設定します。
| パラム | タイプ |
|---|---|
options | WhiteBalanceOptions |
インターフェース
Section titled “インターフェース”接続オプション
Section titled “接続オプション”| 小道具 | タイプ | 説明 |
|---|---|---|
ssid | string | リコーカメラのWiFi SSID |
password | string | カメラのWiFiパスワード |
プレビューオプション
Section titled “プレビューオプション”| 小道具 | タイプ | 説明 |
|---|---|---|
container | string | HTML プレビュー コンテナーの要素 ID |
キャプチャオプション|小道具 |タイプ |説明 |
Section titled “キャプチャオプション|小道具 |タイプ |説明 |”| -------------- | ------------------ | ------------------------------------- |
| quality | number |画質 (1-100) (オプション) |
| saveToGallery | boolean |デバイス ギャラリーに保存 (オプション) |
録音オプション
Section titled “録音オプション”| 小道具 | タイプ | 説明 |
|---|---|---|
maxDuration | number | 最大録音時間 (秒単位) (オプション) |
quality | string | ビデオ品質: ‘高’ | ‘中’ | ‘低’ (オプション) |
キャプチャ結果
Section titled “キャプチャ結果”| 小道具 | タイプ | 説明 |
|---|---|---|
filePath | string | キャプチャされたファイルへのパス |
fileUrl | string | ファイルにアクセスするための URL |
| 小道具 | タイプ | 説明 |
|---|---|---|
model | string | カメラのモデル名 |
serialNumber | string | カメラのシリアル番号 |
firmwareVersion | string | ファームウェアのバージョン |
batteryLevel | number | バッテリー残量 (0-100) |
露出オプション
Section titled “露出オプション”| 小道具 | タイプ | 説明 |
|---|---|---|
mode | string | 露出モード: ‘自動’ | ‘マニュアル’ | ‘イソ’ |
iso | number | ISO 値 (100、200、400 など) (オプション) |
shutter | number | シャッタースピード (オプション) |
ホワイトバランスオプション
Section titled “ホワイトバランスオプション”| 小道具 | タイプ | 説明 |
|---|---|---|
mode | string | ホワイトバランス: ‘自動’ | ‘日光’ | 「曇り」 | ‘タングステン’ | ‘蛍光’ |
import { Ricoh360Camera } from '@capgo/capacitor-ricoh360-camera';
class Camera360Controller { async setup() { try { // Initialize await Ricoh360Camera.initialize();
// Connect to camera await Ricoh360Camera.connect({ ssid: 'THETAYL12345678', password: '12345678' });
// Get camera info const info = await Ricoh360Camera.getCameraInfo(); console.log('Connected to:', info.model); console.log('Battery level:', info.batteryLevel + '%');
// Configure exposure await Ricoh360Camera.setExposure({ mode: 'auto' });
// Configure white balance await Ricoh360Camera.setWhiteBalance({ mode: 'auto' });
// Start preview await Ricoh360Camera.startPreview({ container: 'camera-preview' });
} catch (error) { console.error('Failed to setup camera:', error); } }
async takePhoto() { try { const result = await Ricoh360Camera.capturePhoto({ quality: 95, saveToGallery: true }); console.log('Photo captured:', result.filePath); return result; } catch (error) { console.error('Failed to capture photo:', error); } }
async recordVideo(durationSeconds: number) { try { // Start recording await Ricoh360Camera.startRecording({ maxDuration: durationSeconds, quality: 'high' });
console.log('Recording started...');
// Stop after duration setTimeout(async () => { const result = await Ricoh360Camera.stopRecording(); console.log('Video saved:', result.filePath); }, durationSeconds * 1000);
} catch (error) { console.error('Failed to record video:', error); } }
async cleanup() { try { await Ricoh360Camera.stopPreview(); await Ricoh360Camera.disconnect(); console.log('Camera disconnected'); } catch (error) { console.error('Failed to cleanup:', error); } }}
// Usageconst camera = new Camera360Controller();await camera.setup();await camera.takePhoto();await camera.recordVideo(10); // 10 secondsawait camera.cleanup();ベストプラクティス
Section titled “ベストプラクティス”- カメラに接続する前に必ずプラグインを初期化してください
- デバイスがカメラの WiFi ネットワークに接続されていることを確認します。
- エラー、特に接続障害を適切に処理します
- プレビューを停止し、完了したらバッテリーを節約するために接続を解除します
- 長時間の録画セッションの前にカメラのバッテリー残量を確認してください
- 実際のRicoh Thetaハードウェアでのテスト
- ストレージの制約に基づいて適切なビデオ品質を使用する
トラブルシューティング
Section titled “トラブルシューティング”- カメラの電源が入っていることを確認します
- WiFi SSID とパスワードが正しいことを確認してください
- 他のアプリがカメラに接続されていないことを確認してください
- 接続に失敗した場合はカメラの WiFi 設定をリセット
プレビューが表示されない
Section titled “プレビューが表示されない”- HTML コンテナ要素が存在することを確認します
- カメラの権限が付与されていることを確認してください
- 接続が成功した後にプレビューが開始されることを確認します
キャプチャの失敗- 利用可能なストレージ容量を確認する
Section titled “キャプチャの失敗- 利用可能なストレージ容量を確認する”- カメラのバッテリー残量が十分であることを確認します
- カメラがスリープモードになっていないことを確認してください