Skip to content

Commit

Permalink
fix: video player screen orientation
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismclarke committed Feb 23, 2024
1 parent 0ebbe24 commit 634fa7c
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies {
implementation project(':capacitor-community-firebase-analytics')
implementation project(':capacitor-community-firebase-crashlytics')
implementation project(':capacitor-firebase-performance')
implementation project(':capacitor-screen-orientation')
implementation "androidx.webkit:webkit:1.4.0"
implementation "androidx.legacy:legacy-support-v4:1.0.0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
"capacitor-video-player",
"@capacitor-community/firebase-analytics",
"@capacitor-community/firebase-crashlytics",
"@capacitor-firebase/performance"
"@capacitor-firebase/performance",
"@capacitor/screen-orientation"
],
"server": {
"url": "http://192.168.0.107:4200",
"androidScheme": "http",
"cleartext": true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,9 @@
{
"pkg": "@capacitor-firebase/performance",
"classpath": "io.capawesome.capacitorjs.plugins.firebase.performance.FirebasePerformancePlugin"
},
{
"pkg": "@capacitor/screen-orientation",
"classpath": "com.capacitorjs.plugins.screenorientation.ScreenOrientationPlugin"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ project(':capacitor-community-firebase-crashlytics').projectDir = new File('../.

include ':capacitor-firebase-performance'
project(':capacitor-firebase-performance').projectDir = new File('../../../../node_modules/@capacitor-firebase/performance/android')

include ':capacitor-screen-orientation'
project(':capacitor-screen-orientation').projectDir = new File('../../../../node_modules/@capacitor/screen-orientation/android')
3 changes: 2 additions & 1 deletion apps/picsa-apps/extension-app-native/capacitor.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const config: CapacitorConfig = {
'@capacitor-community/firebase-analytics',
'@capacitor-community/firebase-crashlytics',
'@capacitor-firebase/performance',
'@capacitor/screen-orientation',
],
// Enable app to use native http for requests (bypass cors)
// https://capacitorjs.com/docs/apis/http
Expand All @@ -44,7 +45,7 @@ const config: CapacitorConfig = {
* See notes at https://docs.picsa.app/advanced/testing
**/

// url: 'http://192.168.0.107:4200',
// url: 'http://192.168.50.67:4200',
androidScheme: 'http',

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, ElementRef, HostBinding, Input, OnDestroy } from '@angular/core';
import { Capacitor } from '@capacitor/core';
import { ScreenOrientation } from '@capacitor/screen-orientation';
import { CapacitorVideoPlayer, CapacitorVideoPlayerPlugin, capVideoPlayerOptions } from 'capacitor-video-player';

// Fix listeners missing from type
Expand Down Expand Up @@ -173,9 +174,13 @@ export class VideoPlayerComponent implements OnDestroy {
private handlePlayerEnded() {
this.showPlayButton = true;
}
private handlePlayerExit(e: { currentTime: number }) {
private async handlePlayerExit(e: { currentTime: number }) {
this.showPlayButton = true;
this.pauseTime = e.currentTime;
// Ensure player does not stay stuck in landscape mode
if (Capacitor.isNativePlatform()) {
await ScreenOrientation.unlock();
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"@capacitor/device": "^5.0.6",
"@capacitor/filesystem": "^5.1.4",
"@capacitor/network": "^5.0.6",
"@capacitor/screen-orientation": "^5.0.7",
"@ngx-translate/core": "~15.0.0",
"@ngx-translate/http-loader": "~8.0.0",
"@nx/angular": "17.1.2",
Expand All @@ -75,7 +76,7 @@
"@uppy/tus": "^3.4.0",
"c3": "^0.7.20",
"capacitor-blob-writer": "^1.1.14",
"capacitor-video-player": "^5.0.3",
"capacitor-video-player": "^5.5.1",
"cordova-plugin-codeplay-share-own-apk": "0.0.7",
"cordova-plugin-file": "^8.0.1",
"cordova-plugin-file-opener2": "^4.0.0",
Expand Down
14 changes: 12 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2336,6 +2336,15 @@ __metadata:
languageName: node
linkType: hard

"@capacitor/screen-orientation@npm:^5.0.7":
version: 5.0.7
resolution: "@capacitor/screen-orientation@npm:5.0.7"
peerDependencies:
"@capacitor/core": ^5.0.0
checksum: 0ae635df7c4c2cea494d3a746ec257327568b66210b8acf16e8e4f6ce696c8eeca5fdb465d6cd756a2f2e4469cb918bab6b74b4abfeffad8cc6946f2ab15c248
languageName: node
linkType: hard

"@colors/colors@npm:1.5.0":
version: 1.5.0
resolution: "@colors/colors@npm:1.5.0"
Expand Down Expand Up @@ -9428,7 +9437,7 @@ __metadata:
languageName: node
linkType: hard

"capacitor-video-player@npm:^5.0.3":
"capacitor-video-player@npm:^5.5.1":
version: 5.5.1
resolution: "capacitor-video-player@npm:5.5.1"
peerDependencies:
Expand Down Expand Up @@ -17527,6 +17536,7 @@ __metadata:
"@capacitor/device": ^5.0.6
"@capacitor/filesystem": ^5.1.4
"@capacitor/network": ^5.0.6
"@capacitor/screen-orientation": ^5.0.7
"@ngx-translate/core": ~15.0.0
"@ngx-translate/http-loader": ~8.0.0
"@nx/angular": 17.1.2
Expand Down Expand Up @@ -17570,7 +17580,7 @@ __metadata:
autoprefixer: ^10.4.0
c3: ^0.7.20
capacitor-blob-writer: ^1.1.14
capacitor-video-player: ^5.0.3
capacitor-video-player: ^5.5.1
cordova-plugin-codeplay-share-own-apk: 0.0.7
cordova-plugin-file: ^8.0.1
cordova-plugin-file-opener2: ^4.0.0
Expand Down

0 comments on commit 634fa7c

Please sign in to comment.