Skip to content

Commit

Permalink
Merge pull request #329 from bitmovin/fix-PiP-sample-for-tvOS
Browse files Browse the repository at this point in the history
Fix Picture in Picture sample screen layout on tvOS
  • Loading branch information
rolandkakonyi authored Nov 27, 2023
2 parents f3d6f7f + 094c4f1 commit 5d33a4c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Android: `onEvent` callback not being called on `PlayerView`
- iOS: `onEvent` on iOS has incomplete payload information
- tvOS: Picture in Picture sample screen has unwanted padding

## [0.14.1] (2023-11-16)

Expand Down
14 changes: 9 additions & 5 deletions example/src/screens/BasicPictureInPicture.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useCallback, useEffect, useState } from 'react';
import { Button, Platform, StyleSheet } from 'react-native';
import { Button, Platform, StyleSheet, View, ViewProps } from 'react-native';
import { useFocusEffect } from '@react-navigation/native';
import {
Event,
Expand Down Expand Up @@ -116,9 +116,9 @@ export default function BasicPictureInPicture({
[]
);

const ContainerView = Platform.isTV ? View : SafeAreaContainer;
return (
<SafeAreaView
edges={['bottom', 'left', 'right']}
<ContainerView
style={
// On Android, we need to remove the padding from the container when in PiP mode.
Platform.OS === 'android' && isInPictureInPicture
Expand All @@ -137,17 +137,21 @@ export default function BasicPictureInPicture({
onPictureInPictureExit={onPictureInPictureExitEvent}
onPictureInPictureExited={onEvent}
/>
</SafeAreaView>
</ContainerView>
);
}

function SafeAreaContainer(props: ViewProps): JSX.Element {
return <SafeAreaView edges={['bottom', 'left', 'right']} {...props} />;
}

const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: 'white',
padding: 10,
padding: Platform.isTV ? 0 : 10,
},
player: {
flex: 1,
Expand Down

0 comments on commit 5d33a4c

Please sign in to comment.