diff --git a/CHANGELOG.md b/CHANGELOG.md index 2df8a54a..48c22469 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - iOS: `onEvent` on iOS has incomplete payload information - tvOS: Picture in Picture sample screen has unwanted padding - iOS: hide home indicator when entering fullscreen mode in the example application +- iOS: invalid `loadingState` value in `SeekEvent`, `SourceLoadEvent`, `SourceLoadedEvent` and in `SourceUnloadedEvent` ## [0.14.1] (2023-11-16) diff --git a/example/src/App.tsx b/example/src/App.tsx index 18e1a31d..227f1ad9 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -1,9 +1,9 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import { Platform, Button } from 'react-native'; import { NavigationContainer } from '@react-navigation/native'; import { createNativeStackNavigator } from '@react-navigation/native-stack'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; -import { SourceType } from 'bitmovin-player-react-native'; +import { AudioSession, SourceType } from 'bitmovin-player-react-native'; import ExamplesList from './screens/ExamplesList'; import BasicAds from './screens/BasicAds'; import BasicAnalytics from './screens/BasicAnalytics'; @@ -63,6 +63,20 @@ const RootStack = createNativeStackNavigator(); const isTVOS = Platform.OS === 'ios' && Platform.isTV; export default function App() { + useEffect(() => { + // iOS audio session category must be set to `playback` first, otherwise playback + // will have no audio when the device is silenced. + // This is also required to make Picture in Picture work on iOS. + // + // Usually it's desireable to set the audio's category only once during your app's main component + // initialization. This way you can guarantee that your app's audio category is properly + // configured throughout the whole lifecycle of the application. + AudioSession.setCategory('playback').catch((error) => { + // Handle any native errors that might occur while setting the audio's category. + console.log("Failed to set app's audio category to `playback`:\n", error); + }); + }); + const stackParams = { data: [ { diff --git a/example/src/screens/BasicPictureInPicture.tsx b/example/src/screens/BasicPictureInPicture.tsx index d1fa44f0..98971d03 100644 --- a/example/src/screens/BasicPictureInPicture.tsx +++ b/example/src/screens/BasicPictureInPicture.tsx @@ -6,7 +6,6 @@ import { usePlayer, PlayerView, SourceType, - AudioSession, PictureInPictureEnterEvent, PictureInPictureExitEvent, PlayerViewConfig, @@ -51,19 +50,6 @@ export default function BasicPictureInPicture({ useFocusEffect( useCallback(() => { - // iOS audio session must be set to `playback` first otherwise PiP mode won't work. - // - // Usually it's desireable to set the audio's category only once during your app's main component - // initialization. This way you can guarantee that your app's audio category is properly - // configured throughout the whole lifecycle of the application. - AudioSession.setCategory('playback').catch((error) => { - // Handle any native errors that might occur while setting the audio's category. - console.log( - "[BasicPictureInPicture] Failed to set app's audio category to `playback`:\n", - error - ); - }); - // Load desired source configuration player.load({ url: diff --git a/ios/Event+JSON.swift b/ios/Event+JSON.swift index 0b6c817c..12b06ef5 100644 --- a/ios/Event+JSON.swift +++ b/ios/Event+JSON.swift @@ -5,7 +5,7 @@ extension Source { var json: [AnyHashable: Any] = [ "duration": duration, "isActive": isActive, - "loadingState": loadingState, + "loadingState": loadingState.rawValue, "isAttachedToPlayer": isAttachedToPlayer ] if let metadata { diff --git a/src/events.ts b/src/events.ts index c467ebf7..3f357808 100644 --- a/src/events.ts +++ b/src/events.ts @@ -9,6 +9,7 @@ import { import { SubtitleTrack } from './subtitleTrack'; import { VideoQuality } from './media'; import { AudioTrack } from './audioTrack'; +import { LoadingState } from './source'; /** * Base event type for all events. @@ -139,6 +140,10 @@ export interface EventSource { * Metadata for this event's source. */ metadata?: Record; + /** + * The current `LoadingState` of the source. + */ + loadingState: LoadingState; } /**