@capgo/capacitor-screen-orientationを使用
Capacitor画面の向きを変更するプラグインのインターフェース
インストール
bun add @capgo/capacitor-screen-orientation
bunx cap sync
このプラグインが公開するもの
orientation- 現在の画面の向きを取得lock- 画面の向きを特定のタイプに固定unlock- スクリーン オリエンテーションをアンロックします。startOrientationTracking- デバイス オリエンテーションをモーション センサで追跡します。
例の使用
orientation
現在のスクリーン オリエンテーションを取得します。
import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';
const result = await ScreenOrientation.orientation();
console.log('Current orientation:', result.type);
lock
特定のタイプのスクリーン オリエンテーションにロックします。
import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';
// Standard lock
await ScreenOrientation.lock({ orientation: 'landscape' });
// Lock with motion tracking on iOS
await ScreenOrientation.lock({
orientation: 'portrait',
bypassOrientationLock: true
});
unlock
スクリーン オリエンテーションをアンロックします。
import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';
await ScreenOrientation.unlock();
startOrientationTracking
デバイス オリエンテーションをモーション センサで追跡します。
import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';
await ScreenOrientation.startOrientationTracking({
bypassOrientationLock: true
});
// Listen for changes
ScreenOrientation.addListener('screenOrientationChange', (result) => {
console.log('Orientation changed:', result.type);
});
フル リファレンス
- GitHub: https://github.com/Cap-go/capacitor-screen-orientation/
- ドキュメント: /docs/plugins/screen-orientation/
続けて、@capgo/capacitor-screen-orientationを使用します。
If you are using native media and interface behaviorを計画するために@capgo/capacitor-screen-orientationを使用 @__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-screen-orientationと接続 @capgo/capacitor-screen-orientationの実装詳細 for the implementation detail in @capgo/capacitor-screen-orientation, Getting Startedの実装詳細 native capabilityを使用する@__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-live-activities Using @capgo/capacitor-live-activities @capgo/capacitor-live-activitiesの実装詳細 Using @capgo/capacitor-video-player native capabilityを使用する@capgo/capacitor-video-player native capabilityを使用する@capgo/capacitor-video-player ネイティブ機能の使用に@capgo/capacitor-video-playerを使用します。