Skip to content

Commit

Permalink
launching app on mobile device
Browse files Browse the repository at this point in the history
  • Loading branch information
OchiengPaul442 committed Feb 20, 2024
1 parent ed51adf commit aa8e9d9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@capacitor-firebase/performance"
],
"server": {
"url": "http://192.168.0.107:4200",
"androidScheme": "http",
"cleartext": true
}
Expand Down
2 changes: 1 addition & 1 deletion apps/picsa-apps/extension-app-native/capacitor.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const config: CapacitorConfig = {
* See notes at https://docs.picsa.app/advanced/testing
**/

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

/**
Expand Down
22 changes: 19 additions & 3 deletions libs/shared/src/features/video-player/video-player.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export class VideoPlayerComponent implements OnDestroy {
/** Track any created object urls to dispose on destroy */
private objectUrl: string;

private pauseTime: number = 0;

constructor(private elementRef: ElementRef<HTMLDivElement>) {}

async ngOnDestroy() {
Expand All @@ -67,10 +69,17 @@ export class VideoPlayerComponent implements OnDestroy {
public async playVideo() {
// Remove thumbnail from future playback
this.thumbnail = undefined;
if (Capacitor.isNativePlatform()) {
await this.videoPlayer.stopAllPlayers();
this.initialised = false;
}

// Initialise player any time playback triggered in case url updated (e.g. downloaded after init)
await this.initPlayer();
await this.videoPlayer.stopAllPlayers();
await this.videoPlayer.play({ playerId: this.playerId });
if (this.pauseTime > 0) {
await this.videoPlayer.setCurrentTime({ playerId: this.playerId, seektime: this.pauseTime });
}
}

private async initPlayer() {
Expand Down Expand Up @@ -149,15 +158,22 @@ export class VideoPlayerComponent implements OnDestroy {
this.showPlayButton = false;
}
}
private async handlePlayerPause() {
this.showPlayButton = true;

private handlePlayerPause(e: { fromPlayerId: string; currentTime: number }) {
if (e.fromPlayerId === this.playerId) {
this.pauseTime = e.currentTime;
this.showPlayButton = true;
}
}

private handlePlayerEnded() {
this.showPlayButton = true;
}
private handlePlayerExit() {
this.showPlayButton = true;
if (Capacitor.isNativePlatform()) {
this.initialised = false;
}
}
}

Expand Down

0 comments on commit aa8e9d9

Please sign in to comment.