expo-video 1.1.5 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/android/build.gradle +2 -2
  3. package/android/src/main/java/expo/modules/video/ExpoVideoPlaybackService.kt +17 -1
  4. package/android/src/main/java/expo/modules/video/FullscreenPlayerActivity.kt +2 -1
  5. package/android/src/main/java/expo/modules/video/VideoExceptions.kt +3 -0
  6. package/android/src/main/java/expo/modules/video/VideoModule.kt +12 -3
  7. package/android/src/main/java/expo/modules/video/VideoPlayer.kt +33 -15
  8. package/android/src/main/java/expo/modules/video/VideoPlayerAudioFocusManager.kt +105 -0
  9. package/android/src/main/java/expo/modules/video/VideoView.kt +1 -0
  10. package/android/src/main/java/expo/modules/video/drawing/OutlineProvider.kt +6 -1
  11. package/android/src/main/java/expo/modules/video/records/VideoMetadata.kt +10 -0
  12. package/android/src/main/java/expo/modules/video/records/VideoSource.kt +15 -2
  13. package/android/src/main/java/expo/modules/video/records/VolumeEvent.kt +1 -1
  14. package/build/NativeVideoModule.d.ts +6 -4
  15. package/build/NativeVideoModule.d.ts.map +1 -1
  16. package/build/NativeVideoModule.js +0 -3
  17. package/build/NativeVideoModule.js.map +1 -1
  18. package/build/VideoPlayer.d.ts +1 -1
  19. package/build/VideoPlayer.d.ts.map +1 -1
  20. package/build/VideoPlayer.js.map +1 -1
  21. package/build/VideoPlayer.web.d.ts +1 -1
  22. package/build/VideoPlayer.web.d.ts.map +1 -1
  23. package/build/VideoPlayer.web.js.map +1 -1
  24. package/build/VideoView.d.ts +2 -2
  25. package/build/VideoView.d.ts.map +1 -1
  26. package/build/VideoView.js.map +1 -1
  27. package/build/VideoView.types.d.ts +18 -7
  28. package/build/VideoView.types.d.ts.map +1 -1
  29. package/build/VideoView.types.js.map +1 -1
  30. package/build/VideoView.web.d.ts +1 -1
  31. package/build/VideoView.web.d.ts.map +1 -1
  32. package/build/VideoView.web.js.map +1 -1
  33. package/ios/VideoPlayer.swift +13 -7
  34. package/ios/VideoPlayerObserver.swift +3 -2
  35. package/package.json +2 -2
  36. package/src/NativeVideoModule.ts +8 -4
  37. package/src/VideoPlayer.tsx +1 -1
  38. package/src/VideoPlayer.web.tsx +6 -1
  39. package/src/VideoView.tsx +2 -2
  40. package/src/VideoView.types.ts +20 -8
  41. package/src/VideoView.web.tsx +1 -1
package/CHANGELOG.md CHANGED
@@ -10,6 +10,20 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 1.1.7 — 2024-05-06
14
+
15
+ _This version does not introduce any user-facing changes._
16
+
17
+ ## 1.1.6 — 2024-05-01
18
+
19
+ ### 🎉 New features
20
+
21
+ - [Android] Add support for customizing the now playing notification. ([#28390](https://github.com/expo/expo/pull/28390) by [@behenate](https://github.com/behenate))
22
+
23
+ ### 💡 Others
24
+
25
+ - [Android] Improve audio focus management. ([#28453](https://github.com/expo/expo/pull/28453) by [@behenate](https://github.com/behenate))
26
+
13
27
  ## 1.1.5 — 2024-04-26
14
28
 
15
29
  ### 🎉 New features
@@ -1,7 +1,7 @@
1
1
  apply plugin: 'com.android.library'
2
2
 
3
3
  group = 'host.exp.exponent'
4
- version = '1.1.5'
4
+ version = '1.1.7'
5
5
 
6
6
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
7
7
  apply from: expoModulesCorePlugin
@@ -14,7 +14,7 @@ android {
14
14
  namespace "expo.modules.video"
15
15
  defaultConfig {
16
16
  versionCode 1
17
- versionName '1.1.5'
17
+ versionName '1.1.7'
18
18
  }
19
19
  }
20
20
 
@@ -40,6 +40,15 @@ class ExpoVideoPlaybackService : MediaSessionService() {
40
40
  .setIconResId(R.drawable.seek_backwards_10s)
41
41
  .build()
42
42
 
43
+ fun setShowNotification(showNotification: Boolean, player: ExoPlayer) {
44
+ val sessionExtras = mediaSessions[player]?.sessionExtras?.deepCopy() ?: Bundle()
45
+ sessionExtras.putBoolean(SESSION_SHOW_NOTIFICATION, showNotification)
46
+ mediaSessions[player]?.let {
47
+ it.sessionExtras = sessionExtras
48
+ onUpdateNotification(it, showNotification)
49
+ }
50
+ }
51
+
43
52
  fun registerPlayer(player: ExoPlayer) {
44
53
  if (mediaSessions[player] != null) {
45
54
  return
@@ -71,7 +80,13 @@ class ExpoVideoPlaybackService : MediaSessionService() {
71
80
  }
72
81
 
73
82
  override fun onUpdateNotification(session: MediaSession, startInForegroundRequired: Boolean) {
74
- createNotification(session)
83
+ if (session.sessionExtras.getBoolean(SESSION_SHOW_NOTIFICATION, true)) {
84
+ createNotification(session)
85
+ } else {
86
+ (session.player as? ExoPlayer)?.let {
87
+ hidePlayerNotification(it)
88
+ }
89
+ }
75
90
  }
76
91
 
77
92
  override fun onTaskRemoved(rootIntent: Intent?) {
@@ -135,6 +150,7 @@ class ExpoVideoPlaybackService : MediaSessionService() {
135
150
  const val SEEK_FORWARD_COMMAND = "SEEK_FORWARD"
136
151
  const val SEEK_BACKWARD_COMMAND = "SEEK_REWIND"
137
152
  const val CHANNEL_ID = "PlaybackService"
153
+ const val SESSION_SHOW_NOTIFICATION = "showNotification"
138
154
  const val SEEK_INTERVAL_MS = 10000L
139
155
  }
140
156
  }
@@ -46,9 +46,10 @@ class FullscreenPlayerActivity : Activity() {
46
46
  VideoManager.getVideoView(videoViewId).exitFullscreen()
47
47
 
48
48
  // Disable the exit transition
49
- if (Build.VERSION.SDK_INT >= 34) {
49
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
50
50
  overrideActivityTransition(OVERRIDE_TRANSITION_CLOSE, 0, 0)
51
51
  } else {
52
+ @Suppress("DEPRECATION")
52
53
  overridePendingTransition(0, 0)
53
54
  }
54
55
  }
@@ -23,3 +23,6 @@ internal class UnsupportedDRMTypeException(type: DRMType) :
23
23
 
24
24
  internal class PlaybackException(reason: String?, cause: Throwable? = null) :
25
25
  CodedException("A playback exception has occurred: ${reason ?: "reason unknown"}", cause)
26
+
27
+ internal class FailedToGetAudioFocusManagerException :
28
+ CodedException("Failed to get AudioFocusManager service")
@@ -139,9 +139,7 @@ class VideoModule : Module() {
139
139
 
140
140
  Class(VideoPlayer::class) {
141
141
  Constructor { source: VideoSource ->
142
- val mediaItem = source.toMediaItem()
143
- VideoManager.registerVideoSourceToMediaItem(mediaItem, source)
144
- VideoPlayer(activity.applicationContext, appContext, mediaItem)
142
+ VideoPlayer(activity.applicationContext, appContext, source)
145
143
  }
146
144
 
147
145
  Property("playing")
@@ -206,6 +204,16 @@ class VideoModule : Module() {
206
204
  }
207
205
  }
208
206
 
207
+ Property("showNowPlayingNotification")
208
+ .get { ref: VideoPlayer ->
209
+ ref.showNowPlayingNotification
210
+ }
211
+ .set { ref: VideoPlayer, showNotification: Boolean ->
212
+ appContext.mainQueue.launch {
213
+ ref.showNowPlayingNotification = showNotification
214
+ }
215
+ }
216
+
209
217
  Property("status")
210
218
  .get { ref: VideoPlayer ->
211
219
  ref.status
@@ -255,6 +263,7 @@ class VideoModule : Module() {
255
263
  VideoManager.registerVideoSourceToMediaItem(mediaItem, videoSource)
256
264
 
257
265
  appContext.mainQueue.launch {
266
+ ref.videoSource = videoSource
258
267
  ref.player.setMediaItem(mediaItem)
259
268
  }
260
269
  }
@@ -24,16 +24,18 @@ import expo.modules.kotlin.sharedobjects.SharedObject
24
24
  import expo.modules.video.enums.PlayerStatus
25
25
  import expo.modules.video.enums.PlayerStatus.*
26
26
  import expo.modules.video.records.PlaybackError
27
+ import expo.modules.video.records.VideoSource
27
28
  import expo.modules.video.records.VolumeEvent
28
29
  import kotlinx.coroutines.launch
30
+ import java.lang.ref.WeakReference
29
31
 
30
32
  // https://developer.android.com/guide/topics/media/media3/getting-started/migration-guide#improvements_in_media3
31
33
  @UnstableApi
32
- class VideoPlayer(context: Context, appContext: AppContext, private val mediaItem: MediaItem) : AutoCloseable, SharedObject(appContext) {
34
+ class VideoPlayer(context: Context, appContext: AppContext, source: VideoSource?) : AutoCloseable, SharedObject(appContext) {
33
35
  // This improves the performance of playing DRM-protected content
34
36
  private var renderersFactory = DefaultRenderersFactory(context)
35
37
  .forceEnableMediaCodecAsynchronousQueueing()
36
-
38
+ val audioFocusManager = VideoPlayerAudioFocusManager(context, WeakReference(this))
37
39
  val player = ExoPlayer
38
40
  .Builder(context, renderersFactory)
39
41
  .setLooper(context.mainLooper)
@@ -48,21 +50,19 @@ class VideoPlayer(context: Context, appContext: AppContext, private val mediaIte
48
50
  field = value
49
51
  }
50
52
 
51
- var status: PlayerStatus = IDLE
52
-
53
- var currentMediaItem: MediaItem? = null
54
- set(newMediaItem) {
55
- if (field != newMediaItem) {
56
- val oldVideoSource = VideoManager.getVideoSourceFromMediaItem(field)
57
- val newVideoSource = VideoManager.getVideoSourceFromMediaItem(newMediaItem)
58
-
59
- sendEventOnJSThread("sourceChange", newVideoSource, oldVideoSource)
53
+ // This is used only for sending events and keeping the reference to the video source for the
54
+ // VideoManager, which holds weak references. Changing this will not affect the player.
55
+ var videoSource: VideoSource? = source
56
+ set(videoSource) {
57
+ if (field != videoSource) {
58
+ sendEventOnJSThread("sourceChange", videoSource, field)
60
59
  }
61
- field = newMediaItem
60
+ field = videoSource
62
61
  }
63
62
 
64
63
  // Volume of the player if there was no mute applied.
65
64
  var userVolume = 1f
65
+ var status: PlayerStatus = IDLE
66
66
  var requiresLinearPlayback = false
67
67
  var staysActiveInBackground = false
68
68
  var preservesPitch = false
@@ -70,6 +70,11 @@ class VideoPlayer(context: Context, appContext: AppContext, private val mediaIte
70
70
  playbackParameters = applyPitchCorrection(playbackParameters)
71
71
  field = preservesPitch
72
72
  }
73
+ var showNowPlayingNotification = true
74
+ set(value) {
75
+ field = value
76
+ playbackServiceBinder?.service?.setShowNotification(value, this.player)
77
+ }
73
78
 
74
79
  private var serviceConnection: ServiceConnection
75
80
  internal var playbackServiceBinder: PlaybackServiceBinder? = null
@@ -89,6 +94,7 @@ class VideoPlayer(context: Context, appContext: AppContext, private val mediaIte
89
94
  sendEventOnJSThread("volumeChange", VolumeEvent(volume, muted), VolumeEvent(volume, field))
90
95
  player.volume = if (muted) 0f else userVolume
91
96
  field = muted
97
+ audioFocusManager.onPlayerChangedAudioFocusProperty(this@VideoPlayer)
92
98
  }
93
99
 
94
100
  var playbackParameters: PlaybackParameters = PlaybackParameters.DEFAULT
@@ -107,6 +113,7 @@ class VideoPlayer(context: Context, appContext: AppContext, private val mediaIte
107
113
  private val playerListener = object : Player.Listener {
108
114
  override fun onIsPlayingChanged(isPlaying: Boolean) {
109
115
  this@VideoPlayer.playing = isPlaying
116
+ audioFocusManager.onPlayerChangedAudioFocusProperty(this@VideoPlayer)
110
117
  }
111
118
 
112
119
  override fun onTimelineChanged(timeline: Timeline, reason: Int) {
@@ -114,7 +121,8 @@ class VideoPlayer(context: Context, appContext: AppContext, private val mediaIte
114
121
  }
115
122
 
116
123
  override fun onMediaItemTransition(mediaItem: MediaItem?, reason: Int) {
117
- this@VideoPlayer.currentMediaItem = mediaItem
124
+ val newVideoSource = VideoManager.getVideoSourceFromMediaItem(mediaItem)
125
+ this@VideoPlayer.videoSource = newVideoSource
118
126
  if (reason == Player.MEDIA_ITEM_TRANSITION_REASON_REPEAT) {
119
127
  sendEventOnJSThread("playToEnd")
120
128
  }
@@ -131,6 +139,7 @@ class VideoPlayer(context: Context, appContext: AppContext, private val mediaIte
131
139
 
132
140
  override fun onVolumeChanged(volume: Float) {
133
141
  this@VideoPlayer.volume = volume
142
+ audioFocusManager.onPlayerChangedAudioFocusProperty(this@VideoPlayer)
134
143
  }
135
144
 
136
145
  override fun onPlaybackParametersChanged(playbackParameters: PlaybackParameters) {
@@ -194,6 +203,7 @@ class VideoPlayer(context: Context, appContext: AppContext, private val mediaIte
194
203
  }
195
204
 
196
205
  override fun close() {
206
+ audioFocusManager.onPlayerDestroyed()
197
207
  appContext?.reactContext?.unbindService(serviceConnection)
198
208
  playbackServiceBinder?.service?.unregisterPlayer(player)
199
209
  VideoManager.unregisterVideoPlayer(this@VideoPlayer)
@@ -202,6 +212,7 @@ class VideoPlayer(context: Context, appContext: AppContext, private val mediaIte
202
212
  player.removeListener(playerListener)
203
213
  player.release()
204
214
  }
215
+ videoSource = null
205
216
  }
206
217
 
207
218
  override fun deallocate() {
@@ -216,8 +227,15 @@ class VideoPlayer(context: Context, appContext: AppContext, private val mediaIte
216
227
  }
217
228
 
218
229
  fun prepare() {
219
- player.setMediaItem(mediaItem)
220
- player.prepare()
230
+ videoSource?.let { videoSource ->
231
+ val mediaItem = videoSource.toMediaItem()
232
+ VideoManager.registerVideoSourceToMediaItem(mediaItem, videoSource)
233
+ player.setMediaItem(mediaItem)
234
+ player.prepare()
235
+ } ?: run {
236
+ player.removeMediaItem(0)
237
+ player.prepare()
238
+ }
221
239
  }
222
240
 
223
241
  private fun applyPitchCorrection(playbackParameters: PlaybackParameters): PlaybackParameters {
@@ -0,0 +1,105 @@
1
+ package expo.modules.video
2
+
3
+ import android.content.Context
4
+ import android.media.AudioAttributes
5
+ import android.media.AudioFocusRequest
6
+ import android.media.AudioManager
7
+ import android.os.Build
8
+ import androidx.media3.common.util.UnstableApi
9
+ import java.lang.ref.WeakReference
10
+
11
+ @UnstableApi
12
+ class VideoPlayerAudioFocusManager(val context: Context, private val player: WeakReference<VideoPlayer>) : AudioManager.OnAudioFocusChangeListener {
13
+ private val audioManager by lazy {
14
+ context.getSystemService(Context.AUDIO_SERVICE) as? AudioManager ?: run {
15
+ throw FailedToGetAudioFocusManagerException()
16
+ }
17
+ }
18
+ private var currentFocusRequest: AudioFocusRequest? = null
19
+ private var volumeBeforeDuck: Float = -1f
20
+
21
+ // TODO: @behenate (SDK52) Instead of calling this explicitly in the player we should add functionality
22
+ // To register as a player delegate and react to player events.
23
+ fun onPlayerChangedAudioFocusProperty(player: VideoPlayer) {
24
+ if (player.playing && !player.muted && player.volume > 0) {
25
+ requestAudioFocus()
26
+ } else {
27
+ abandonAudioFocus()
28
+ }
29
+ }
30
+
31
+ fun onPlayerDestroyed() {
32
+ abandonAudioFocus()
33
+ }
34
+
35
+ private fun requestAudioFocus() {
36
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
37
+ if (currentFocusRequest != null) {
38
+ abandonAudioFocus()
39
+ }
40
+
41
+ val newFocusRequest = AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN).run {
42
+ setAudioAttributes(
43
+ AudioAttributes.Builder().run {
44
+ setUsage(AudioAttributes.USAGE_MEDIA)
45
+ setContentType(AudioAttributes.CONTENT_TYPE_MOVIE)
46
+ setOnAudioFocusChangeListener(this@VideoPlayerAudioFocusManager)
47
+ build()
48
+ }
49
+ ).build()
50
+ }
51
+ this.currentFocusRequest = newFocusRequest
52
+ audioManager.requestAudioFocus(newFocusRequest)
53
+ } else {
54
+ @Suppress("DEPRECATION")
55
+ audioManager.requestAudioFocus(
56
+ this,
57
+ AudioManager.STREAM_MUSIC,
58
+ AudioManager.AUDIOFOCUS_GAIN
59
+ )
60
+ }
61
+ }
62
+
63
+ private fun abandonAudioFocus() {
64
+ currentFocusRequest?.let {
65
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
66
+ audioManager.abandonAudioFocusRequest(it)
67
+ } else {
68
+ @Suppress("DEPRECATION")
69
+ audioManager.abandonAudioFocus(this)
70
+ }
71
+ }
72
+ currentFocusRequest = null
73
+ }
74
+
75
+ override fun onAudioFocusChange(focusChange: Int) {
76
+ when (focusChange) {
77
+ AudioManager.AUDIOFOCUS_LOSS -> {
78
+ player.get()?.player?.pause()
79
+ }
80
+
81
+ AudioManager.AUDIOFOCUS_LOSS_TRANSIENT -> {
82
+ player.get()?.player?.pause()
83
+ }
84
+
85
+ AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK -> {
86
+ player.get()?.let { player ->
87
+ volumeBeforeDuck = player.player.volume
88
+ player.volume = player.volume / 2f
89
+ player.userVolume = player.volume
90
+ }
91
+ }
92
+
93
+ AudioManager.AUDIOFOCUS_GAIN -> {
94
+ // TODO: For now this behaves like iOS and doesn't resume playback automatically
95
+ // In future versions we can add a prop to control this behavior.
96
+ player.get()?.let { player ->
97
+ if (player.playing && !player.muted && player.volume > 0) {
98
+ player.volume = volumeBeforeDuck
99
+ player.userVolume = player.volume
100
+ }
101
+ }
102
+ }
103
+ }
104
+ }
105
+ }
@@ -146,6 +146,7 @@ class VideoView(context: Context, appContext: AppContext) : ExpoView(context, ap
146
146
  if (Build.VERSION.SDK_INT >= 34) {
147
147
  currentActivity.overrideActivityTransition(Activity.OVERRIDE_TRANSITION_OPEN, 0, 0)
148
148
  } else {
149
+ @Suppress("DEPRECATION")
149
150
  currentActivity.overridePendingTransition(0, 0)
150
151
  }
151
152
  isInFullscreen = true
@@ -5,6 +5,7 @@ import android.graphics.Canvas
5
5
  import android.graphics.Outline
6
6
  import android.graphics.Path
7
7
  import android.graphics.RectF
8
+ import android.os.Build
8
9
  import android.view.View
9
10
  import android.view.ViewOutlineProvider
10
11
  import com.facebook.react.modules.i18nmanager.I18nUtil
@@ -197,7 +198,11 @@ class OutlineProvider(private val mContext: Context) : ViewOutlineProvider() {
197
198
  // shadow is. For the particular case, we fallback to canvas clipping in the view
198
199
  // which is supposed to call `clipCanvasIfNeeded` in its `draw` method.
199
200
  updateConvexPathIfNeeded()
200
- outline.setConvexPath(mConvexPath)
201
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
202
+ outline.setPath(mConvexPath)
203
+ } else {
204
+ outline.setConvexPath(mConvexPath)
205
+ }
201
206
  }
202
207
  }
203
208
 
@@ -0,0 +1,10 @@
1
+ package expo.modules.video.records
2
+
3
+ import expo.modules.kotlin.records.Field
4
+ import expo.modules.kotlin.records.Record
5
+ import java.io.Serializable
6
+
7
+ class VideoMetadata(
8
+ @Field var title: String? = null,
9
+ @Field var artist: String? = null
10
+ ) : Record, Serializable
@@ -1,6 +1,7 @@
1
1
  package expo.modules.video.records
2
2
 
3
3
  import androidx.media3.common.MediaItem
4
+ import androidx.media3.common.MediaMetadata
4
5
  import expo.modules.kotlin.records.Field
5
6
  import expo.modules.kotlin.records.Record
6
7
  import expo.modules.video.UnsupportedDRMTypeException
@@ -8,7 +9,8 @@ import java.io.Serializable
8
9
 
9
10
  class VideoSource(
10
11
  @Field var uri: String? = null,
11
- @Field var drm: DRMOptions? = null
12
+ @Field var drm: DRMOptions? = null,
13
+ @Field var metadata: VideoMetadata? = null
12
14
  ) : Record, Serializable {
13
15
  private fun toMediaId(): String {
14
16
  return "uri:${this.uri}" +
@@ -16,13 +18,16 @@ class VideoSource(
16
18
  "DrmLicenseServer:${this.drm?.licenseServer}" +
17
19
  "DrmMultiKey:${this.drm?.multiKey}" +
18
20
  "DRMHeadersKeys:${this.drm?.headers?.keys?.joinToString {it}}}" +
19
- "DRMHeadersValues:${this.drm?.headers?.values?.joinToString {it}}}"
21
+ "DRMHeadersValues:${this.drm?.headers?.values?.joinToString {it}}}" +
22
+ "NotificationDataTitle:${this.metadata?.title}" +
23
+ "NotificationDataSecondaryText:${this.metadata?.artist}"
20
24
  }
21
25
 
22
26
  fun toMediaItem() = MediaItem
23
27
  .Builder()
24
28
  .apply {
25
29
  setUri(uri ?: "")
30
+ setMediaId(toMediaId())
26
31
  drm?.let {
27
32
  if (it.type.isSupported()) {
28
33
  setDrmConfiguration(it.toDRMConfiguration())
@@ -30,6 +35,14 @@ class VideoSource(
30
35
  throw UnsupportedDRMTypeException(it.type)
31
36
  }
32
37
  }
38
+ setMediaMetadata(
39
+ MediaMetadata.Builder().apply {
40
+ metadata?.let { data ->
41
+ setTitle(data.title)
42
+ setArtist(data.artist)
43
+ }
44
+ }.build()
45
+ )
33
46
  }
34
47
  .build()
35
48
  }
@@ -6,5 +6,5 @@ import java.io.Serializable
6
6
 
7
7
  internal class VolumeEvent(
8
8
  @Field var volume: Float? = null,
9
- @Field var muted: Boolean? = null
9
+ @Field var isMuted: Boolean? = null
10
10
  ) : Record, Serializable
@@ -1,6 +1,8 @@
1
- /**
2
- * @hidden
3
- */
4
- declare const _default: any;
1
+ import type { VideoPlayer } from './VideoView.types';
2
+ type ExpoVideoModule = {
3
+ VideoPlayer: typeof VideoPlayer;
4
+ isPictureInPictureSupported(): boolean;
5
+ };
6
+ declare const _default: ExpoVideoModule;
5
7
  export default _default;
6
8
  //# sourceMappingURL=NativeVideoModule.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NativeVideoModule.d.ts","sourceRoot":"","sources":["../src/NativeVideoModule.ts"],"names":[],"mappings":"AAEA;;GAEG;;AACH,wBAAgD"}
1
+ {"version":3,"file":"NativeVideoModule.d.ts","sourceRoot":"","sources":["../src/NativeVideoModule.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,KAAK,eAAe,GAAG;IACrB,WAAW,EAAE,OAAO,WAAW,CAAC;IAChC,2BAA2B,IAAI,OAAO,CAAC;CACxC,CAAC;;AAEF,wBAAiE"}
@@ -1,6 +1,3 @@
1
1
  import { requireNativeModule } from 'expo-modules-core';
2
- /**
3
- * @hidden
4
- */
5
2
  export default requireNativeModule('ExpoVideo');
6
3
  //# sourceMappingURL=NativeVideoModule.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NativeVideoModule.js","sourceRoot":"","sources":["../src/NativeVideoModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD;;GAEG;AACH,eAAe,mBAAmB,CAAC,WAAW,CAAC,CAAC","sourcesContent":["import { requireNativeModule } from 'expo-modules-core';\n\n/**\n * @hidden\n */\nexport default requireNativeModule('ExpoVideo');\n"]}
1
+ {"version":3,"file":"NativeVideoModule.js","sourceRoot":"","sources":["../src/NativeVideoModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AASxD,eAAe,mBAAmB,CAAkB,WAAW,CAAC,CAAC","sourcesContent":["import { requireNativeModule } from 'expo-modules-core';\n\nimport type { VideoPlayer } from './VideoView.types';\n\ntype ExpoVideoModule = {\n VideoPlayer: typeof VideoPlayer;\n isPictureInPictureSupported(): boolean;\n};\n\nexport default requireNativeModule<ExpoVideoModule>('ExpoVideo');\n"]}
@@ -1,4 +1,4 @@
1
- import { VideoPlayer, VideoSource } from './VideoView.types';
1
+ import type { VideoPlayer, VideoSource } from './VideoView.types';
2
2
  /**
3
3
  * Creates a `VideoPlayer`, which will be automatically cleaned up when the component is unmounted.
4
4
  * @param source - A video source that is used to initialize the player.
@@ -1 +1 @@
1
- {"version":3,"file":"VideoPlayer.d.ts","sourceRoot":"","sources":["../src/VideoPlayer.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE7D;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,WAAW,EACnB,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,GACpC,WAAW,CAQb"}
1
+ {"version":3,"file":"VideoPlayer.d.ts","sourceRoot":"","sources":["../src/VideoPlayer.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAElE;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,WAAW,EACnB,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,GACpC,WAAW,CAQb"}
@@ -1 +1 @@
1
- {"version":3,"file":"VideoPlayer.js","sourceRoot":"","sources":["../src/VideoPlayer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAGpD;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAmB,EACnB,KAAqC;IAErC,MAAM,YAAY,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IAE3E,OAAO,wBAAwB,CAAC,GAAG,EAAE;QACnC,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;QAC/D,KAAK,EAAE,CAAC,MAAM,CAAC,CAAC;QAChB,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC","sourcesContent":["import { useReleasingSharedObject } from 'expo-modules-core';\n\nimport NativeVideoModule from './NativeVideoModule';\nimport { VideoPlayer, VideoSource } from './VideoView.types';\n\n/**\n * Creates a `VideoPlayer`, which will be automatically cleaned up when the component is unmounted.\n * @param source - A video source that is used to initialize the player.\n * @param setup - A function that allows setting up the player. It will run after the player is created.\n */\nexport function useVideoPlayer(\n source: VideoSource,\n setup?: (player: VideoPlayer) => void\n): VideoPlayer {\n const parsedSource = typeof source === 'string' ? { uri: source } : source;\n\n return useReleasingSharedObject(() => {\n const player = new NativeVideoModule.VideoPlayer(parsedSource);\n setup?.(player);\n return player;\n }, [JSON.stringify(parsedSource)]);\n}\n"]}
1
+ {"version":3,"file":"VideoPlayer.js","sourceRoot":"","sources":["../src/VideoPlayer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAGpD;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAmB,EACnB,KAAqC;IAErC,MAAM,YAAY,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IAE3E,OAAO,wBAAwB,CAAC,GAAG,EAAE;QACnC,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;QAC/D,KAAK,EAAE,CAAC,MAAM,CAAC,CAAC;QAChB,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC","sourcesContent":["import { useReleasingSharedObject } from 'expo-modules-core';\n\nimport NativeVideoModule from './NativeVideoModule';\nimport type { VideoPlayer, VideoSource } from './VideoView.types';\n\n/**\n * Creates a `VideoPlayer`, which will be automatically cleaned up when the component is unmounted.\n * @param source - A video source that is used to initialize the player.\n * @param setup - A function that allows setting up the player. It will run after the player is created.\n */\nexport function useVideoPlayer(\n source: VideoSource,\n setup?: (player: VideoPlayer) => void\n): VideoPlayer {\n const parsedSource = typeof source === 'string' ? { uri: source } : source;\n\n return useReleasingSharedObject(() => {\n const player = new NativeVideoModule.VideoPlayer(parsedSource);\n setup?.(player);\n return player;\n }, [JSON.stringify(parsedSource)]);\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { VideoPlayer, VideoPlayerEvents, VideoPlayerStatus, VideoSource } from './VideoView.types';
1
+ import type { VideoPlayer, VideoPlayerEvents, VideoPlayerStatus, VideoSource } from './VideoView.types';
2
2
  export declare function useVideoPlayer(source: VideoSource, setup?: (player: VideoPlayer) => void): VideoPlayer;
3
3
  export declare function getSourceUri(source: VideoSource): string | null;
4
4
  export declare class VideoPlayerWeb extends globalThis.expo.SharedObject<VideoPlayerEvents> implements VideoPlayer {
@@ -1 +1 @@
1
- {"version":3,"file":"VideoPlayer.web.d.ts","sourceRoot":"","sources":["../src/VideoPlayer.web.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEnG,wBAAgB,cAAc,CAC5B,MAAM,EAAE,WAAW,EACnB,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,GACpC,WAAW,CA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,CAAC,WAAW;oBAAE,OAAO;gBACrF,YAAY,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;YAC/C,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,KAAK,CAAC,YAAY,GAAG,GAAG,EAAE;YACxB,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE;gBAC3C,IAAI,YAAY,KAAK,KAAK,IAAI,YAAY,CAAC,YAAY,KAAK,KAAK,CAAC,YAAY;oBAAE,OAAO;gBACvF,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,YAAY,CAAC;gBACxC,YAAY,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;YACjD,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,KAAK,CAAC,OAAO,GAAG,GAAG,EAAE;YACnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACzB,CAAC,CAAC;QAEF,KAAK,CAAC,YAAY,GAAG,GAAG,EAAE;YACxB,IAAI,CAAC,OAAO,GAAG,aAAa,CAAC;YAE7B,IAAI,IAAI,CAAC,OAAO,IAAI,KAAK,CAAC,MAAM,EAAE;gBAChC,KAAK,CAAC,IAAI,EAAE,CAAC;aACd;QACH,CAAC,CAAC;QAEF,KAAK,CAAC,SAAS,GAAG,GAAG,EAAE;YACrB,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QAC3B,CAAC,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { useMemo } from 'react';\n\nimport { VideoPlayer, VideoPlayerEvents, VideoPlayerStatus, VideoSource } from './VideoView.types';\n\nexport function useVideoPlayer(\n source: VideoSource,\n setup?: (player: VideoPlayer) => void\n): VideoPlayer {\n const parsedSource = typeof source === 'string' ? { uri: source } : source;\n\n return useMemo(() => {\n const player = new VideoPlayerWeb(parsedSource);\n setup?.(player);\n return player;\n }, [JSON.stringify(source)]);\n}\n\nexport function getSourceUri(source: VideoSource): string | null {\n if (typeof source == 'string') {\n return source;\n }\n return source?.uri ?? null;\n}\n\nexport class VideoPlayerWeb\n extends globalThis.expo.SharedObject<VideoPlayerEvents>\n implements VideoPlayer\n{\n constructor(source: VideoSource) {\n super();\n this.src = source;\n }\n\n src: VideoSource = null;\n _mountedVideos: Set<HTMLVideoElement> = new Set();\n _audioNodes: Set<MediaElementAudioSourceNode> = new Set();\n playing: boolean = false;\n _muted: boolean = false;\n _volume: number = 1;\n _loop: boolean = false;\n _playbackRate: number = 1.0;\n _preservesPitch: boolean = true;\n _status: VideoPlayerStatus = 'idle';\n staysActiveInBackground: boolean = false; // Not supported on web. Dummy to match the interface.\n showNowPlayingNotification: boolean = false; // Not supported on web. Dummy to match the interface.\n\n set muted(value: boolean) {\n this._mountedVideos.forEach((video) => {\n video.muted = value;\n });\n this._muted = value;\n }\n\n get muted(): boolean {\n return this._muted;\n }\n\n set playbackRate(value: number) {\n this._mountedVideos.forEach((video) => {\n video.playbackRate = value;\n });\n }\n\n get playbackRate(): number {\n return this._playbackRate;\n }\n\n set volume(value: number) {\n this._mountedVideos.forEach((video) => {\n video.volume = value;\n });\n this._volume = value;\n }\n\n get volume(): number {\n this._mountedVideos.forEach((video) => {\n this._volume = video.volume;\n });\n return this._volume;\n }\n\n set loop(value: boolean) {\n this._mountedVideos.forEach((video) => {\n video.loop = value;\n });\n this._loop = value;\n }\n\n get loop(): boolean {\n return this._loop;\n }\n\n get currentTime(): number {\n // All videos should be synchronized, so we return the position of the first video.\n return [...this._mountedVideos][0].currentTime;\n }\n\n set currentTime(value: number) {\n this._mountedVideos.forEach((video) => {\n video.currentTime = value;\n });\n }\n\n get preservesPitch(): boolean {\n return this._preservesPitch;\n }\n\n set preservesPitch(value: boolean) {\n this._mountedVideos.forEach((video) => {\n video.preservesPitch = value;\n });\n this._preservesPitch = value;\n }\n\n get status(): VideoPlayerStatus {\n return this._status;\n }\n\n mountVideoView(video: HTMLVideoElement) {\n this._mountedVideos.add(video);\n this._addListeners(video);\n this._synchronizeWithFirstVideo(video);\n }\n\n unmountVideoView(video: HTMLVideoElement) {\n this._mountedVideos.delete(video);\n }\n\n mountAudioNode(\n audioContext: AudioContext,\n zeroGainNode: GainNode,\n audioSourceNode: MediaElementAudioSourceNode\n ): void {\n if (!audioContext || !zeroGainNode) return;\n\n this._audioNodes.add(audioSourceNode);\n // First mounted video should be connected to the audio context. All other videos have to be muted.\n if (this._audioNodes.size === 1) {\n audioSourceNode.connect(audioContext.destination);\n } else {\n audioSourceNode.connect(zeroGainNode);\n }\n }\n\n unmountAudioNode(\n video: HTMLVideoElement,\n audioContext: AudioContext,\n audioSourceNode: MediaElementAudioSourceNode\n ) {\n const mountedVideos = [...this._mountedVideos];\n const videoPlayingAudio = mountedVideos[0];\n this._audioNodes.delete(audioSourceNode);\n audioSourceNode.disconnect();\n\n // If video playing audio has been removed, select a new video to be the audio player by disconnecting it from the mute node.\n if (videoPlayingAudio === video && this._audioNodes.size > 0 && audioContext) {\n const newMainAudioSource = [...this._audioNodes][0];\n newMainAudioSource.disconnect();\n newMainAudioSource.connect(audioContext.destination);\n }\n }\n\n play(): void {\n this._mountedVideos.forEach((video) => {\n video.play();\n });\n this.playing = true;\n }\n\n pause(): void {\n this._mountedVideos.forEach((video) => {\n video.pause();\n });\n this.playing = false;\n }\n\n replace(source: VideoSource): void {\n this._mountedVideos.forEach((video) => {\n const uri = getSourceUri(source);\n video.pause();\n if (uri) {\n video.setAttribute('src', uri);\n video.load();\n video.play();\n } else {\n video.removeAttribute('src');\n }\n });\n this.playing = true;\n }\n\n seekBy(seconds: number): void {\n this._mountedVideos.forEach((video) => {\n video.currentTime += seconds;\n });\n }\n\n replay(): void {\n this._mountedVideos.forEach((video) => {\n video.currentTime = 0;\n video.play();\n });\n this.playing = true;\n }\n\n _synchronizeWithFirstVideo(video: HTMLVideoElement): void {\n const firstVideo = [...this._mountedVideos][0];\n if (!firstVideo) return;\n\n if (firstVideo.paused) {\n video.pause();\n } else {\n video.play();\n }\n video.currentTime = firstVideo.currentTime;\n video.volume = firstVideo.volume;\n video.muted = firstVideo.muted;\n video.playbackRate = firstVideo.playbackRate;\n }\n\n _addListeners(video: HTMLVideoElement): void {\n video.onplay = () => {\n this.playing = true;\n this._mountedVideos.forEach((mountedVideo) => {\n mountedVideo.play();\n });\n };\n\n video.onpause = () => {\n this.playing = false;\n this._mountedVideos.forEach((mountedVideo) => {\n mountedVideo.pause();\n });\n };\n\n video.onvolumechange = () => {\n this.volume = video.volume;\n this.muted = video.muted;\n };\n\n video.onseeking = () => {\n this._mountedVideos.forEach((mountedVideo) => {\n if (mountedVideo === video || mountedVideo.currentTime === video.currentTime) return;\n mountedVideo.currentTime = video.currentTime;\n });\n };\n\n video.onseeked = () => {\n this._mountedVideos.forEach((mountedVideo) => {\n if (mountedVideo === video || mountedVideo.currentTime === video.currentTime) return;\n mountedVideo.currentTime = video.currentTime;\n });\n };\n\n video.onratechange = () => {\n this._mountedVideos.forEach((mountedVideo) => {\n if (mountedVideo === video || mountedVideo.playbackRate === video.playbackRate) return;\n this._playbackRate = video.playbackRate;\n mountedVideo.playbackRate = video.playbackRate;\n });\n };\n\n video.onerror = () => {\n this._status = 'error';\n };\n\n video.onloadeddata = () => {\n this._status = 'readyToPlay';\n\n if (this.playing && video.paused) {\n video.play();\n }\n };\n\n video.onwaiting = () => {\n this._status = 'loading';\n };\n }\n}\n"]}
1
+ {"version":3,"file":"VideoPlayer.web.js","sourceRoot":"","sources":["../src/VideoPlayer.web.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAShC,MAAM,UAAU,cAAc,CAC5B,MAAmB,EACnB,KAAqC;IAErC,MAAM,YAAY,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IAE3E,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC,YAAY,CAAC,CA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AC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,KAAK,CAAC,OAAO,GAAG,GAAG,EAAE;YACnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACzB,CAAC,CAAC;QAEF,KAAK,CAAC,YAAY,GAAG,GAAG,EAAE;YACxB,IAAI,CAAC,OAAO,GAAG,aAAa,CAAC;YAE7B,IAAI,IAAI,CAAC,OAAO,IAAI,KAAK,CAAC,MAAM,EAAE;gBAChC,KAAK,CAAC,IAAI,EAAE,CAAC;aACd;QACH,CAAC,CAAC;QAEF,KAAK,CAAC,SAAS,GAAG,GAAG,EAAE;YACrB,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QAC3B,CAAC,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { useMemo } from 'react';\n\nimport type {\n VideoPlayer,\n VideoPlayerEvents,\n VideoPlayerStatus,\n VideoSource,\n} from './VideoView.types';\n\nexport function useVideoPlayer(\n source: VideoSource,\n setup?: (player: VideoPlayer) => void\n): VideoPlayer {\n const parsedSource = typeof source === 'string' ? { uri: source } : source;\n\n return useMemo(() => {\n const player = new VideoPlayerWeb(parsedSource);\n setup?.(player);\n return player;\n }, [JSON.stringify(source)]);\n}\n\nexport function getSourceUri(source: VideoSource): string | null {\n if (typeof source == 'string') {\n return source;\n }\n return source?.uri ?? null;\n}\n\nexport class VideoPlayerWeb\n extends globalThis.expo.SharedObject<VideoPlayerEvents>\n implements VideoPlayer\n{\n constructor(source: VideoSource) {\n super();\n this.src = source;\n }\n\n src: VideoSource = null;\n _mountedVideos: Set<HTMLVideoElement> = new Set();\n _audioNodes: Set<MediaElementAudioSourceNode> = new Set();\n playing: boolean = false;\n _muted: boolean = false;\n _volume: number = 1;\n _loop: boolean = false;\n _playbackRate: number = 1.0;\n _preservesPitch: boolean = true;\n _status: VideoPlayerStatus = 'idle';\n staysActiveInBackground: boolean = false; // Not supported on web. Dummy to match the interface.\n showNowPlayingNotification: boolean = false; // Not supported on web. Dummy to match the interface.\n\n set muted(value: boolean) {\n this._mountedVideos.forEach((video) => {\n video.muted = value;\n });\n this._muted = value;\n }\n\n get muted(): boolean {\n return this._muted;\n }\n\n set playbackRate(value: number) {\n this._mountedVideos.forEach((video) => {\n video.playbackRate = value;\n });\n }\n\n get playbackRate(): number {\n return this._playbackRate;\n }\n\n set volume(value: number) {\n this._mountedVideos.forEach((video) => {\n video.volume = value;\n });\n this._volume = value;\n }\n\n get volume(): number {\n this._mountedVideos.forEach((video) => {\n this._volume = video.volume;\n });\n return this._volume;\n }\n\n set loop(value: boolean) {\n this._mountedVideos.forEach((video) => {\n video.loop = value;\n });\n this._loop = value;\n }\n\n get loop(): boolean {\n return this._loop;\n }\n\n get currentTime(): number {\n // All videos should be synchronized, so we return the position of the first video.\n return [...this._mountedVideos][0].currentTime;\n }\n\n set currentTime(value: number) {\n this._mountedVideos.forEach((video) => {\n video.currentTime = value;\n });\n }\n\n get preservesPitch(): boolean {\n return this._preservesPitch;\n }\n\n set preservesPitch(value: boolean) {\n this._mountedVideos.forEach((video) => {\n video.preservesPitch = value;\n });\n this._preservesPitch = value;\n }\n\n get status(): VideoPlayerStatus {\n return this._status;\n }\n\n mountVideoView(video: HTMLVideoElement) {\n this._mountedVideos.add(video);\n this._addListeners(video);\n this._synchronizeWithFirstVideo(video);\n }\n\n unmountVideoView(video: HTMLVideoElement) {\n this._mountedVideos.delete(video);\n }\n\n mountAudioNode(\n audioContext: AudioContext,\n zeroGainNode: GainNode,\n audioSourceNode: MediaElementAudioSourceNode\n ): void {\n if (!audioContext || !zeroGainNode) return;\n\n this._audioNodes.add(audioSourceNode);\n // First mounted video should be connected to the audio context. All other videos have to be muted.\n if (this._audioNodes.size === 1) {\n audioSourceNode.connect(audioContext.destination);\n } else {\n audioSourceNode.connect(zeroGainNode);\n }\n }\n\n unmountAudioNode(\n video: HTMLVideoElement,\n audioContext: AudioContext,\n audioSourceNode: MediaElementAudioSourceNode\n ) {\n const mountedVideos = [...this._mountedVideos];\n const videoPlayingAudio = mountedVideos[0];\n this._audioNodes.delete(audioSourceNode);\n audioSourceNode.disconnect();\n\n // If video playing audio has been removed, select a new video to be the audio player by disconnecting it from the mute node.\n if (videoPlayingAudio === video && this._audioNodes.size > 0 && audioContext) {\n const newMainAudioSource = [...this._audioNodes][0];\n newMainAudioSource.disconnect();\n newMainAudioSource.connect(audioContext.destination);\n }\n }\n\n play(): void {\n this._mountedVideos.forEach((video) => {\n video.play();\n });\n this.playing = true;\n }\n\n pause(): void {\n this._mountedVideos.forEach((video) => {\n video.pause();\n });\n this.playing = false;\n }\n\n replace(source: VideoSource): void {\n this._mountedVideos.forEach((video) => {\n const uri = getSourceUri(source);\n video.pause();\n if (uri) {\n video.setAttribute('src', uri);\n video.load();\n video.play();\n } else {\n video.removeAttribute('src');\n }\n });\n this.playing = true;\n }\n\n seekBy(seconds: number): void {\n this._mountedVideos.forEach((video) => {\n video.currentTime += seconds;\n });\n }\n\n replay(): void {\n this._mountedVideos.forEach((video) => {\n video.currentTime = 0;\n video.play();\n });\n this.playing = true;\n }\n\n _synchronizeWithFirstVideo(video: HTMLVideoElement): void {\n const firstVideo = [...this._mountedVideos][0];\n if (!firstVideo) return;\n\n if (firstVideo.paused) {\n video.pause();\n } else {\n video.play();\n }\n video.currentTime = firstVideo.currentTime;\n video.volume = firstVideo.volume;\n video.muted = firstVideo.muted;\n video.playbackRate = firstVideo.playbackRate;\n }\n\n _addListeners(video: HTMLVideoElement): void {\n video.onplay = () => {\n this.playing = true;\n this._mountedVideos.forEach((mountedVideo) => {\n mountedVideo.play();\n });\n };\n\n video.onpause = () => {\n this.playing = false;\n this._mountedVideos.forEach((mountedVideo) => {\n mountedVideo.pause();\n });\n };\n\n video.onvolumechange = () => {\n this.volume = video.volume;\n this.muted = video.muted;\n };\n\n video.onseeking = () => {\n this._mountedVideos.forEach((mountedVideo) => {\n if (mountedVideo === video || mountedVideo.currentTime === video.currentTime) return;\n mountedVideo.currentTime = video.currentTime;\n });\n };\n\n video.onseeked = () => {\n this._mountedVideos.forEach((mountedVideo) => {\n if (mountedVideo === video || mountedVideo.currentTime === video.currentTime) return;\n mountedVideo.currentTime = video.currentTime;\n });\n };\n\n video.onratechange = () => {\n this._mountedVideos.forEach((mountedVideo) => {\n if (mountedVideo === video || mountedVideo.playbackRate === video.playbackRate) return;\n this._playbackRate = video.playbackRate;\n mountedVideo.playbackRate = video.playbackRate;\n });\n };\n\n video.onerror = () => {\n this._status = 'error';\n };\n\n video.onloadeddata = () => {\n this._status = 'readyToPlay';\n\n if (this.playing && video.paused) {\n video.play();\n }\n };\n\n video.onwaiting = () => {\n this._status = 'loading';\n };\n }\n}\n"]}
@@ -1,12 +1,12 @@
1
1
  import { ReactNode, PureComponent } from 'react';
2
- import { VideoViewProps } from './VideoView.types';
2
+ import type { VideoViewProps } from './VideoView.types';
3
3
  /**
4
4
  * Returns whether the current device supports Picture in Picture (PiP) mode.
5
5
  * @returns A `boolean` which is `true` if the device supports PiP mode, and `false` otherwise.
6
6
  * @platform android
7
7
  * @platform ios
8
8
  */
9
- export declare function isPictureInPictureSupported(): Promise<boolean>;
9
+ export declare function isPictureInPictureSupported(): boolean;
10
10
  export declare class VideoView extends PureComponent<VideoViewProps> {
11
11
  nativeRef: import("react").RefObject<any>;
12
12
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"VideoView.d.ts","sourceRoot":"","sources":["../src/VideoView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAa,MAAM,OAAO,CAAC;AAI5D,OAAO,EAAe,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEhE;;;;;GAKG;AACH,wBAAgB,2BAA2B,IAAI,OAAO,CAAC,OAAO,CAAC,CAE9D;AAED,qBAAa,SAAU,SAAQ,aAAa,CAAC,cAAc,CAAC;IAC1D,SAAS,iCAAoB;IAE7B;;OAEG;IACH,eAAe;IAIf;;OAEG;IACH,cAAc;IAId;;;;;OAKG;IACH,qBAAqB,IAAI,IAAI;IAI7B;;;;OAIG;IACH,oBAAoB,IAAI,IAAI;IAI5B,MAAM,IAAI,SAAS;CAMpB"}
1
+ {"version":3,"file":"VideoView.d.ts","sourceRoot":"","sources":["../src/VideoView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAa,MAAM,OAAO,CAAC;AAI5D,OAAO,KAAK,EAAe,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAErE;;;;;GAKG;AACH,wBAAgB,2BAA2B,IAAI,OAAO,CAErD;AAED,qBAAa,SAAU,SAAQ,aAAa,CAAC,cAAc,CAAC;IAC1D,SAAS,iCAAoB;IAE7B;;OAEG;IACH,eAAe;IAIf;;OAEG;IACH,cAAc;IAId;;;;;OAKG;IACH,qBAAqB,IAAI,IAAI;IAI7B;;;;OAIG;IACH,oBAAoB,IAAI,IAAI;IAI5B,MAAM,IAAI,SAAS;CAMpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"VideoView.js","sourceRoot":"","sources":["../src/VideoView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAGhD;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B;IACzC,OAAO,iBAAiB,CAAC,2BAA2B,EAAE,CAAC;AACzD,CAAC;AAED,MAAM,OAAO,SAAU,SAAQ,aAA6B;IAC1D,SAAS,GAAG,SAAS,EAAO,CAAC;IAE7B;;OAEG;IACH,eAAe;QACb,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,eAAe,EAAE,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,cAAc;QACZ,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,cAAc,EAAE,CAAC;IAC3C,CAAC;IAED;;;;;OAKG;IACH,qBAAqB;QACnB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,qBAAqB,EAAE,CAAC;IACzD,CAAC;IAED;;;;OAIG;IACH,oBAAoB;QAClB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,oBAAoB,EAAE,CAAC;IACxD,CAAC;IAED,MAAM;QACJ,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACxC,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;QAErC,OAAO,CAAC,eAAe,CAAC,IAAI,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,EAAG,CAAC;IAC/E,CAAC;CACF;AAED,gFAAgF;AAChF,gEAAgE;AAChE,yEAAyE;AACzE,SAAS,WAAW,CAAC,MAA4B;IAC/C,IAAI,MAAM,YAAY,iBAAiB,CAAC,WAAW,EAAE;QACnD,mBAAmB;QACnB,OAAO,MAAM,CAAC,yBAAyB,CAAC;KACzC;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,OAAO,MAAM,CAAC;KACf;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { ReactNode, PureComponent, createRef } from 'react';\n\nimport NativeVideoModule from './NativeVideoModule';\nimport NativeVideoView from './NativeVideoView';\nimport { VideoPlayer, VideoViewProps } from './VideoView.types';\n\n/**\n * Returns whether the current device supports Picture in Picture (PiP) mode.\n * @returns A `boolean` which is `true` if the device supports PiP mode, and `false` otherwise.\n * @platform android\n * @platform ios\n */\nexport function isPictureInPictureSupported(): Promise<boolean> {\n return NativeVideoModule.isPictureInPictureSupported();\n}\n\nexport class VideoView extends PureComponent<VideoViewProps> {\n nativeRef = createRef<any>();\n\n /**\n * Enters fullscreen mode.\n */\n enterFullscreen() {\n this.nativeRef.current?.enterFullscreen();\n }\n\n /**\n * Exits fullscreen mode.\n */\n exitFullscreen() {\n this.nativeRef.current?.exitFullscreen();\n }\n\n /**\n * Enters Picture in Picture (PiP) mode. Throws an exception if the device does not support PiP.\n * > **Note:** Only one player can be in Picture in Picture (PiP) mode at a time.\n * @platform android\n * @platform ios 14+\n */\n startPictureInPicture(): void {\n return this.nativeRef.current?.startPictureInPicture();\n }\n\n /**\n * Exits Picture in Picture (PiP) mode.\n * @platform android\n * @platform ios 14+\n */\n stopPictureInPicture(): void {\n return this.nativeRef.current?.stopPictureInPicture();\n }\n\n render(): ReactNode {\n const { player, ...props } = this.props;\n const playerId = getPlayerId(player);\n\n return <NativeVideoView {...props} player={playerId} ref={this.nativeRef} />;\n }\n}\n\n// Temporary solution to pass the shared object ID instead of the player object.\n// We can't really pass it as an object in the old architecture.\n// Technically we can in the new architecture, but it's not possible yet.\nfunction getPlayerId(player: number | VideoPlayer): number | null {\n if (player instanceof NativeVideoModule.VideoPlayer) {\n // @ts-expect-error\n return player.__expo_shared_object_id__;\n }\n if (typeof player === 'number') {\n return player;\n }\n return null;\n}\n"]}
1
+ {"version":3,"file":"VideoView.js","sourceRoot":"","sources":["../src/VideoView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAGhD;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B;IACzC,OAAO,iBAAiB,CAAC,2BAA2B,EAAE,CAAC;AACzD,CAAC;AAED,MAAM,OAAO,SAAU,SAAQ,aAA6B;IAC1D,SAAS,GAAG,SAAS,EAAO,CAAC;IAE7B;;OAEG;IACH,eAAe;QACb,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,eAAe,EAAE,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,cAAc;QACZ,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,cAAc,EAAE,CAAC;IAC3C,CAAC;IAED;;;;;OAKG;IACH,qBAAqB;QACnB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,qBAAqB,EAAE,CAAC;IACzD,CAAC;IAED;;;;OAIG;IACH,oBAAoB;QAClB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,oBAAoB,EAAE,CAAC;IACxD,CAAC;IAED,MAAM;QACJ,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACxC,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;QAErC,OAAO,CAAC,eAAe,CAAC,IAAI,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,EAAG,CAAC;IAC/E,CAAC;CACF;AAED,gFAAgF;AAChF,gEAAgE;AAChE,yEAAyE;AACzE,SAAS,WAAW,CAAC,MAA4B;IAC/C,IAAI,MAAM,YAAY,iBAAiB,CAAC,WAAW,EAAE;QACnD,mBAAmB;QACnB,OAAO,MAAM,CAAC,yBAAyB,CAAC;KACzC;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,OAAO,MAAM,CAAC;KACf;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { ReactNode, PureComponent, createRef } from 'react';\n\nimport NativeVideoModule from './NativeVideoModule';\nimport NativeVideoView from './NativeVideoView';\nimport type { VideoPlayer, VideoViewProps } from './VideoView.types';\n\n/**\n * Returns whether the current device supports Picture in Picture (PiP) mode.\n * @returns A `boolean` which is `true` if the device supports PiP mode, and `false` otherwise.\n * @platform android\n * @platform ios\n */\nexport function isPictureInPictureSupported(): boolean {\n return NativeVideoModule.isPictureInPictureSupported();\n}\n\nexport class VideoView extends PureComponent<VideoViewProps> {\n nativeRef = createRef<any>();\n\n /**\n * Enters fullscreen mode.\n */\n enterFullscreen() {\n this.nativeRef.current?.enterFullscreen();\n }\n\n /**\n * Exits fullscreen mode.\n */\n exitFullscreen() {\n this.nativeRef.current?.exitFullscreen();\n }\n\n /**\n * Enters Picture in Picture (PiP) mode. Throws an exception if the device does not support PiP.\n * > **Note:** Only one player can be in Picture in Picture (PiP) mode at a time.\n * @platform android\n * @platform ios 14+\n */\n startPictureInPicture(): void {\n return this.nativeRef.current?.startPictureInPicture();\n }\n\n /**\n * Exits Picture in Picture (PiP) mode.\n * @platform android\n * @platform ios 14+\n */\n stopPictureInPicture(): void {\n return this.nativeRef.current?.stopPictureInPicture();\n }\n\n render(): ReactNode {\n const { player, ...props } = this.props;\n const playerId = getPlayerId(player);\n\n return <NativeVideoView {...props} player={playerId} ref={this.nativeRef} />;\n }\n}\n\n// Temporary solution to pass the shared object ID instead of the player object.\n// We can't really pass it as an object in the old architecture.\n// Technically we can in the new architecture, but it's not possible yet.\nfunction getPlayerId(player: number | VideoPlayer): number | null {\n if (player instanceof NativeVideoModule.VideoPlayer) {\n // @ts-expect-error\n return player.__expo_shared_object_id__;\n }\n if (typeof player === 'number') {\n return player;\n }\n return null;\n}\n"]}
@@ -16,11 +16,17 @@ export declare class VideoPlayer extends SharedObject<VideoPlayerEvents> {
16
16
  loop: boolean;
17
17
  /**
18
18
  * Boolean value whether the player is currently muted.
19
+ * Setting this property to `true`/`false` will mute/unmute the player.
19
20
  * @default false
20
21
  */
21
22
  muted: boolean;
22
23
  /**
23
- * Integer value representing the current position in seconds.
24
+ * Float value indicating the current playback time in seconds.
25
+ *
26
+ * If the player is not yet playing, this value indicates the time position
27
+ * at which playback will begin once the `play()` method is called.
28
+ *
29
+ * Setting `currentTime` to a new value seeks the player to the given time.
24
30
  */
25
31
  currentTime: number;
26
32
  /**
@@ -59,6 +65,11 @@ export declare class VideoPlayer extends SharedObject<VideoPlayerEvents> {
59
65
  * @platform android
60
66
  */
61
67
  staysActiveInBackground: boolean;
68
+ /**
69
+ * Initializes a new video player instance with the given source.
70
+ * @hidden
71
+ */
72
+ constructor(source: VideoSource);
62
73
  /**
63
74
  * Resumes the player.
64
75
  */
@@ -225,27 +236,27 @@ export type VideoPlayerEvents = {
225
236
  /**
226
237
  * Handler for an event emitted when the status of the player changes.
227
238
  */
228
- statusChange: (newStatus: VideoPlayerStatus, oldStatus: VideoPlayerStatus, error: PlayerError) => void;
239
+ statusChange(newStatus: VideoPlayerStatus, oldStatus: VideoPlayerStatus, error: PlayerError): void;
229
240
  /**
230
241
  * Handler for an event emitted when the player starts or stops playback.
231
242
  */
232
- playingChange: (newIsPlaying: boolean, oldIsPlaying: boolean) => void;
243
+ playingChange(newIsPlaying: boolean, oldIsPlaying: boolean): void;
233
244
  /**
234
245
  * Handler for an event emitted when the `playbackRate` property of the player changes.
235
246
  */
236
- playbackRateChange: (newPlaybackRate: number, oldPlaybackRate: number) => void;
247
+ playbackRateChange(newPlaybackRate: number, oldPlaybackRate: number): void;
237
248
  /**
238
249
  * Handler for an event emitted when the `volume` property of the player changes.
239
250
  */
240
- volumeChange: (newVolume: VolumeEvent, oldVolume: VolumeEvent) => void;
251
+ volumeChange(newVolume: VolumeEvent, oldVolume: VolumeEvent): void;
241
252
  /**
242
253
  * Handler for an event emitted when the player plays to the end of the current source.
243
254
  */
244
- playToEnd: () => void;
255
+ playToEnd(): void;
245
256
  /**
246
257
  * Handler for an event emitted when the current media source of the player changes.
247
258
  */
248
- sourceChange: (newSource: VideoSource, previousSource: VideoSource) => void;
259
+ sourceChange(newSource: VideoSource, previousSource: VideoSource): void;
249
260
  };
250
261
  /**
251
262
  * Contains information about any errors that the player encountered during the playback
@@ -1 +1 @@
1
- {"version":3,"file":"VideoView.types.d.ts","sourceRoot":"","sources":["../src/VideoView.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,YAAY,CAAC,iBAAiB,CAAC;IACtE;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;I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E,WAAW,GAAG,IAAI,CAAC;IACnE;;OAEG;IACH,SAAS,IAAI,IAAI,CAAC;IAClB;;OAEG;IACH,YAAY,CAAC,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,GAAG,IAAI,CAAC;CACzE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"VideoView.types.js","sourceRoot":"","sources":["../src/VideoView.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SharedObject } from 'expo-modules-core';\nimport { ViewProps } from 'react-native';\n\n/**\n * A class that represents an instance of the video player.\n */\nexport declare class VideoPlayer extends SharedObject<VideoPlayerEvents> {\n /**\n * Boolean value whether the player is currently playing.\n * > This property is get-only, use `play` and `pause` methods to control the playback.\n */\n playing: boolean;\n\n /**\n * Determines whether the player should automatically replay after reaching the end of the video.\n * @default false\n */\n loop: boolean;\n\n /**\n * Boolean value whether the player is currently muted.\n * @default false\n */\n muted: boolean;\n\n /**\n * Integer value representing the current position in seconds.\n */\n currentTime: number;\n\n /**\n * Float value between 0 and 1 representing the current volume.\n * Muting the player doesn't affect the volume. In other words, when the player is muted, the volume is the same as\n * when unmuted. Similarly, setting the volume doesn't unmute the player.\n * @default 1.0\n */\n volume: number;\n\n /**\n * Boolean value indicating if the player should correct audio pitch when the playback speed changes.\n * > On web, changing this property is not supported, the player will always correct the pitch.\n * @default true\n * @platform android\n * @platform ios\n */\n preservesPitch: boolean;\n\n /**\n * Float value between 0 and 16 indicating the current playback speed of the player.\n * @default 1.0\n */\n playbackRate: number;\n\n /**\n * Indicates the current status of the player.\n * > This property is get-only\n */\n status: VideoPlayerStatus;\n\n /**\n * Boolean value determining whether the player should show the now playing notification.\n */\n showNowPlayingNotification: boolean;\n\n /**\n * Determines whether the player should continue playing after the app enters the background.\n * @default false\n * @platform ios\n * @platform android\n */\n staysActiveInBackground: boolean;\n\n /**\n * Resumes the player.\n */\n play(): void;\n\n /**\n * Pauses the player.\n */\n pause(): void;\n\n /**\n * Replaces the current source with a new one.\n */\n replace(source: VideoSource): void;\n\n /**\n * Seeks the playback by the given number of seconds.\n */\n seekBy(seconds: number): void;\n\n /**\n * Seeks the playback to the beginning.\n */\n replay(): void;\n}\n\n/**\n * Describes how a video should be scaled to fit in a container.\n * - `contain`: The video maintains its aspect ratio and fits inside the container, with possible letterboxing/pillarboxing.\n * - `cover`: The video maintains its aspect ratio and covers the entire container, potentially cropping some portions.\n * - `fill`: The video stretches/squeezes to completely fill the container, potentially causing distortion.\n */\nexport type VideoContentFit = 'contain' | 'cover' | 'fill';\n\n/**\n * Describes the current status of the player.\n * - `idle`: The player is not playing or loading any videos.\n * - `loading`: The player is loading video data from the provided source\n * - `readyToPlay`: The player has loaded enough data to start playing or to continue playback.\n * - `error`: The player has encountered an error while loading or playing the video.\n */\nexport type VideoPlayerStatus = 'idle' | 'loading' | 'readyToPlay' | 'error';\n\nexport interface VideoViewProps extends ViewProps {\n /**\n * A player instance – use `useVideoPlayer()` to create one.\n */\n player: VideoPlayer;\n\n /**\n * Determines whether native controls should be displayed or not.\n * @default true\n */\n nativeControls?: boolean;\n\n /**\n * Describes how the video should be scaled to fit in the container.\n * Options are 'contain', 'cover', and 'fill'.\n * @default 'contain'\n */\n contentFit?: VideoContentFit;\n\n /**\n * Determines whether fullscreen mode is allowed or not.\n * @default true\n */\n allowsFullscreen?: boolean;\n\n /**\n * Determines whether the timecodes should be displayed or not.\n * @default true\n * @platform ios\n */\n showsTimecodes?: boolean;\n\n /**\n * Determines whether the player allows the user to skip media content.\n * @default false\n * @platform android\n * @platform ios\n */\n requiresLinearPlayback?: boolean;\n\n /**\n * Determines the position offset of the video inside the container.\n * @default { dx: 0, dy: 0 }\n * @platform ios\n */\n contentPosition?: { dx?: number; dy?: number };\n\n /**\n * A callback to call after the video player enters Picture in Picture (PiP) mode.\n * @platform android\n * @platform ios 14+\n */\n onPictureInPictureStart?: () => void;\n\n /**\n * A callback to call after the video player exits Picture in Picture (PiP) mode.\n * @platform android\n * @platform ios 14+\n */\n onPictureInPictureStop?: () => void;\n\n /**\n * Determines whether the player allows Picture in Picture (PiP) mode.\n * @default false\n * @platform ios 14+\n */\n allowsPictureInPicture?: boolean;\n\n /**\n * Determines whether the player should start Picture in Picture (PiP) automatically when the app is in the background.\n * > **Note:** Only one player can be in Picture in Picture (PiP) mode at a time.\n * @default false\n * @platform android 12+\n * @platform ios 14.2+\n */\n startsPictureInPictureAutomatically?: boolean;\n}\n\n/**\n * Specifies which type of DRM to use. Android supports Widevine, PlayReady and ClearKey, iOS supports FairPlay.\n */\nexport type DRMType = 'clearkey' | 'fairplay' | 'playready' | 'widevine';\n\n/**\n * Specifies DRM options which will be used by the player while loading the video.\n */\nexport type DRMOptions = {\n /**\n * Determines which type of DRM to use.\n */\n type: DRMType;\n\n /**\n * Determines the license server URL.\n */\n licenseServer: string;\n\n /**\n * Determines headers sent to the license server on license requests.\n */\n headers?: { [key: string]: string };\n\n /**\n * Specifies whether the DRM is a multi-key DRM.\n * @platform android\n */\n multiKey?: boolean;\n\n /**\n * Specifies the content ID of the stream.\n * @platform ios\n */\n contentId?: string;\n\n /**\n * Specifies the certificate URL for the FairPlay DRM.\n * @platform ios\n */\n certificateUrl?: string;\n};\n\nexport type VideoSource =\n | string\n | {\n /**\n * The URI of the video.\n */\n uri: string;\n /**\n * Specifies the DRM options which will be used by the player while loading the video.\n */\n drm?: DRMOptions;\n /**\n * Specifies information which will be displayed in the now playing notification.\n * When undefined the player will display information contained in the video metadata.\n */\n metadata?: VideoMetadata;\n }\n | null;\n\n/**\n * Handlers for events which can be emitted by the player.\n */\nexport type VideoPlayerEvents = {\n /**\n * Handler for an event emitted when the status of the player changes.\n */\n statusChange: (\n newStatus: VideoPlayerStatus,\n oldStatus: VideoPlayerStatus,\n error: PlayerError\n ) => void;\n /**\n * Handler for an event emitted when the player starts or stops playback.\n */\n playingChange: (newIsPlaying: boolean, oldIsPlaying: boolean) => void;\n /**\n * Handler for an event emitted when the `playbackRate` property of the player changes.\n */\n playbackRateChange: (newPlaybackRate: number, oldPlaybackRate: number) => void;\n /**\n * Handler for an event emitted when the `volume` property of the player changes.\n */\n volumeChange: (newVolume: VolumeEvent, oldVolume: VolumeEvent) => void;\n /**\n * Handler for an event emitted when the player plays to the end of the current source.\n */\n playToEnd: () => void;\n /**\n * Handler for an event emitted when the current media source of the player changes.\n */\n sourceChange: (newSource: VideoSource, previousSource: VideoSource) => void;\n};\n\n/**\n * Contains information about any errors that the player encountered during the playback\n */\nexport type PlayerError = {\n message: string;\n};\n\n/**\n * Contains information about the current volume and whether the player is muted.\n */\nexport type VolumeEvent = {\n volume: number;\n isMuted: boolean;\n};\n\n/**\n * Contains information that will be displayed in the now playing notification when the video is playing.\n */\nexport type VideoMetadata = {\n /**\n * The title of the video.\n */\n title?: string;\n /**\n * Secondary text that will be displayed under the title.\n */\n artist?: string;\n};\n"]}
1
+ {"version":3,"file":"VideoView.types.js","sourceRoot":"","sources":["../src/VideoView.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SharedObject } from 'expo-modules-core';\nimport { ViewProps } from 'react-native';\n\n/**\n * A class that represents an instance of the video player.\n */\nexport declare class VideoPlayer extends SharedObject<VideoPlayerEvents> {\n /**\n * Boolean value whether the player is currently playing.\n * > This property is get-only, use `play` and `pause` methods to control the playback.\n */\n playing: boolean;\n\n /**\n * Determines whether the player should automatically replay after reaching the end of the video.\n * @default false\n */\n loop: boolean;\n\n /**\n * Boolean value whether the player is currently muted.\n * Setting this property to `true`/`false` will mute/unmute the player.\n * @default false\n */\n muted: boolean;\n\n /**\n * Float value indicating the current playback time in seconds.\n *\n * If the player is not yet playing, this value indicates the time position\n * at which playback will begin once the `play()` method is called.\n *\n * Setting `currentTime` to a new value seeks the player to the given time.\n */\n currentTime: number;\n\n /**\n * Float value between 0 and 1 representing the current volume.\n * Muting the player doesn't affect the volume. In other words, when the player is muted, the volume is the same as\n * when unmuted. Similarly, setting the volume doesn't unmute the player.\n * @default 1.0\n */\n volume: number;\n\n /**\n * Boolean value indicating if the player should correct audio pitch when the playback speed changes.\n * > On web, changing this property is not supported, the player will always correct the pitch.\n * @default true\n * @platform android\n * @platform ios\n */\n preservesPitch: boolean;\n\n /**\n * Float value between 0 and 16 indicating the current playback speed of the player.\n * @default 1.0\n */\n playbackRate: number;\n\n /**\n * Indicates the current status of the player.\n * > This property is get-only\n */\n status: VideoPlayerStatus;\n\n /**\n * Boolean value determining whether the player should show the now playing notification.\n */\n showNowPlayingNotification: boolean;\n\n /**\n * Determines whether the player should continue playing after the app enters the background.\n * @default false\n * @platform ios\n * @platform android\n */\n staysActiveInBackground: boolean;\n\n /**\n * Initializes a new video player instance with the given source.\n * @hidden\n */\n constructor(source: VideoSource);\n\n /**\n * Resumes the player.\n */\n play(): void;\n\n /**\n * Pauses the player.\n */\n pause(): void;\n\n /**\n * Replaces the current source with a new one.\n */\n replace(source: VideoSource): void;\n\n /**\n * Seeks the playback by the given number of seconds.\n */\n seekBy(seconds: number): void;\n\n /**\n * Seeks the playback to the beginning.\n */\n replay(): void;\n}\n\n/**\n * Describes how a video should be scaled to fit in a container.\n * - `contain`: The video maintains its aspect ratio and fits inside the container, with possible letterboxing/pillarboxing.\n * - `cover`: The video maintains its aspect ratio and covers the entire container, potentially cropping some portions.\n * - `fill`: The video stretches/squeezes to completely fill the container, potentially causing distortion.\n */\nexport type VideoContentFit = 'contain' | 'cover' | 'fill';\n\n/**\n * Describes the current status of the player.\n * - `idle`: The player is not playing or loading any videos.\n * - `loading`: The player is loading video data from the provided source\n * - `readyToPlay`: The player has loaded enough data to start playing or to continue playback.\n * - `error`: The player has encountered an error while loading or playing the video.\n */\nexport type VideoPlayerStatus = 'idle' | 'loading' | 'readyToPlay' | 'error';\n\nexport interface VideoViewProps extends ViewProps {\n /**\n * A player instance – use `useVideoPlayer()` to create one.\n */\n player: VideoPlayer;\n\n /**\n * Determines whether native controls should be displayed or not.\n * @default true\n */\n nativeControls?: boolean;\n\n /**\n * Describes how the video should be scaled to fit in the container.\n * Options are 'contain', 'cover', and 'fill'.\n * @default 'contain'\n */\n contentFit?: VideoContentFit;\n\n /**\n * Determines whether fullscreen mode is allowed or not.\n * @default true\n */\n allowsFullscreen?: boolean;\n\n /**\n * Determines whether the timecodes should be displayed or not.\n * @default true\n * @platform ios\n */\n showsTimecodes?: boolean;\n\n /**\n * Determines whether the player allows the user to skip media content.\n * @default false\n * @platform android\n * @platform ios\n */\n requiresLinearPlayback?: boolean;\n\n /**\n * Determines the position offset of the video inside the container.\n * @default { dx: 0, dy: 0 }\n * @platform ios\n */\n contentPosition?: { dx?: number; dy?: number };\n\n /**\n * A callback to call after the video player enters Picture in Picture (PiP) mode.\n * @platform android\n * @platform ios 14+\n */\n onPictureInPictureStart?: () => void;\n\n /**\n * A callback to call after the video player exits Picture in Picture (PiP) mode.\n * @platform android\n * @platform ios 14+\n */\n onPictureInPictureStop?: () => void;\n\n /**\n * Determines whether the player allows Picture in Picture (PiP) mode.\n * @default false\n * @platform ios 14+\n */\n allowsPictureInPicture?: boolean;\n\n /**\n * Determines whether the player should start Picture in Picture (PiP) automatically when the app is in the background.\n * > **Note:** Only one player can be in Picture in Picture (PiP) mode at a time.\n * @default false\n * @platform android 12+\n * @platform ios 14.2+\n */\n startsPictureInPictureAutomatically?: boolean;\n}\n\n/**\n * Specifies which type of DRM to use. Android supports Widevine, PlayReady and ClearKey, iOS supports FairPlay.\n */\nexport type DRMType = 'clearkey' | 'fairplay' | 'playready' | 'widevine';\n\n/**\n * Specifies DRM options which will be used by the player while loading the video.\n */\nexport type DRMOptions = {\n /**\n * Determines which type of DRM to use.\n */\n type: DRMType;\n\n /**\n * Determines the license server URL.\n */\n licenseServer: string;\n\n /**\n * Determines headers sent to the license server on license requests.\n */\n headers?: { [key: string]: string };\n\n /**\n * Specifies whether the DRM is a multi-key DRM.\n * @platform android\n */\n multiKey?: boolean;\n\n /**\n * Specifies the content ID of the stream.\n * @platform ios\n */\n contentId?: string;\n\n /**\n * Specifies the certificate URL for the FairPlay DRM.\n * @platform ios\n */\n certificateUrl?: string;\n};\n\nexport type VideoSource =\n | string\n | {\n /**\n * The URI of the video.\n */\n uri: string;\n /**\n * Specifies the DRM options which will be used by the player while loading the video.\n */\n drm?: DRMOptions;\n /**\n * Specifies information which will be displayed in the now playing notification.\n * When undefined the player will display information contained in the video metadata.\n */\n metadata?: VideoMetadata;\n }\n | null;\n\n/**\n * Handlers for events which can be emitted by the player.\n */\nexport type VideoPlayerEvents = {\n /**\n * Handler for an event emitted when the status of the player changes.\n */\n statusChange(\n newStatus: VideoPlayerStatus,\n oldStatus: VideoPlayerStatus,\n error: PlayerError\n ): void;\n /**\n * Handler for an event emitted when the player starts or stops playback.\n */\n playingChange(newIsPlaying: boolean, oldIsPlaying: boolean): void;\n /**\n * Handler for an event emitted when the `playbackRate` property of the player changes.\n */\n playbackRateChange(newPlaybackRate: number, oldPlaybackRate: number): void;\n /**\n * Handler for an event emitted when the `volume` property of the player changes.\n */\n volumeChange(newVolume: VolumeEvent, oldVolume: VolumeEvent): void;\n /**\n * Handler for an event emitted when the player plays to the end of the current source.\n */\n playToEnd(): void;\n /**\n * Handler for an event emitted when the current media source of the player changes.\n */\n sourceChange(newSource: VideoSource, previousSource: VideoSource): void;\n};\n\n/**\n * Contains information about any errors that the player encountered during the playback\n */\nexport type PlayerError = {\n message: string;\n};\n\n/**\n * Contains information about the current volume and whether the player is muted.\n */\nexport type VolumeEvent = {\n volume: number;\n isMuted: boolean;\n};\n\n/**\n * Contains information that will be displayed in the now playing notification when the video is playing.\n */\nexport type VideoMetadata = {\n /**\n * The title of the video.\n */\n title?: string;\n /**\n * Secondary text that will be displayed under the title.\n */\n artist?: string;\n};\n"]}
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { VideoPlayerWeb } from './VideoPlayer.web';
3
- import { VideoViewProps } from './VideoView.types';
3
+ import type { VideoViewProps } from './VideoView.types';
4
4
  export declare const VideoView: React.ForwardRefExoticComponent<{
5
5
  player?: VideoPlayerWeb | undefined;
6
6
  } & VideoViewProps & React.RefAttributes<unknown>>;
@@ -1 +1 @@
1
- {"version":3,"file":"VideoView.web.d.ts","sourceRoot":"","sources":["../src/VideoView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6D,MAAM,OAAO,CAAC;AAGlF,OAAO,EAAE,cAAc,EAAgB,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAsBnD,eAAO,MAAM,SAAS;;kDA6EpB,CAAC;AAEH,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"VideoView.web.d.ts","sourceRoot":"","sources":["../src/VideoView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6D,MAAM,OAAO,CAAC;AAGlF,OAAO,EAAE,cAAc,EAAgB,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAsBxD,eAAO,MAAM,SAAS;;kDA6EpB,CAAC;AAEH,eAAe,SAAS,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"VideoView.web.js","sourceRoot":"","sources":["../src/VideoView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAkB,YAAY,EAAE,MAAM,m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AC,CAAC,CAAC,MAAM,EAAE,EAAE;YACd,+EAA+E;YAC/E,6EAA6E;YAC7E,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;gBACnD,QAAQ,CAAC,OAAO,GAAG,MAAM,CAAC;gBAC1B,MAAM,YAAY,GAAG,kBAAkB,EAAE,CAAC;gBAC1C,eAAe,CAAC,OAAO,GAAG,YAAY,CAAC;gBACvC,eAAe,CAAC,OAAO,GAAG,kBAAkB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;gBACtE,YAAY,CAAC,OAAO,GAAG,YAAY;oBACjC,CAAC,CAAC,YAAY,CAAC,wBAAwB,CAAC,MAAM,CAAC;oBAC/C,CAAC,CAAC,IAAI,CAAC;aACV;QACH,CAAC,CAAC,CACF,GAAG,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,EAC3C,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,SAAS,CAAC","sourcesContent":["import React, { useEffect, useRef, forwardRef, useImperativeHandle } from 'react';\nimport { StyleSheet } from 'react-native';\n\nimport { VideoPlayerWeb, getSourceUri } from './VideoPlayer.web';\nimport { VideoViewProps } from './VideoView.types';\n\nfunction createAudioContext(): AudioContext | null {\n return typeof window !== 'undefined' ? new window.AudioContext() : null;\n}\n\nfunction createZeroGainNode(audioContext: AudioContext | null): GainNode | null {\n const zeroGainNode = audioContext?.createGain() ?? null;\n\n if (audioContext && zeroGainNode) {\n zeroGainNode.gain.value = 0;\n zeroGainNode.connect(audioContext.destination);\n }\n return zeroGainNode;\n}\n\nfunction mapStyles(style: VideoViewProps['style']): React.CSSProperties {\n const flattenedStyles = StyleSheet.flatten(style);\n // Looking through react-native-web source code they also just pass styles directly without further conversions, so it's just a cast.\n return flattenedStyles as React.CSSProperties;\n}\n\nexport const VideoView = forwardRef((props: { player?: VideoPlayerWeb } & VideoViewProps, ref) => {\n const videoRef = useRef<null | HTMLVideoElement>(null);\n const mediaNodeRef = useRef<null | MediaElementAudioSourceNode>(null);\n\n /**\n * Audio context is used to mute all but one video when multiple video views are playing from one player simultaneously.\n * Using audio context nodes allows muting videos without displaying the mute icon in the video player.\n * We have to keep the context that called createMediaElementSource(videoRef), as the method can't be called\n * for the second time with another context and there is no way to unbind the video and audio context afterward.\n */\n const audioContextRef = useRef<null | AudioContext>(null);\n const zeroGainNodeRef = useRef<null | GainNode>(null);\n\n useImperativeHandle(ref, () => ({\n enterFullscreen: () => {\n if (!props.allowsFullscreen) {\n return;\n }\n videoRef.current?.requestFullscreen();\n },\n exitFullscreen: () => {\n document.exitFullscreen();\n },\n }));\n\n useEffect(() => {\n const audioContext = audioContextRef.current;\n const zeroGainNode = zeroGainNodeRef.current;\n const mediaNode = mediaNodeRef.current;\n\n if (videoRef.current) {\n props.player?.mountVideoView(videoRef.current);\n }\n\n if (audioContext && zeroGainNode && mediaNode) {\n props.player.mountAudioNode(audioContext, zeroGainNode, mediaNode);\n } else {\n console.warn(\n \"Couldn't mount audio node, this might affect the audio playback when using multiple video views with the same player.\"\n );\n }\n\n return () => {\n if (videoRef.current) {\n props.player?.unmountVideoView(videoRef.current);\n }\n if (videoRef.current && audioContext && mediaNode) {\n props.player?.unmountAudioNode(videoRef.current, audioContext, mediaNode);\n }\n };\n }, [props.player]);\n\n return (\n <video\n controls={props.nativeControls}\n controlsList={props.allowsFullscreen ? undefined : 'nofullscreen'}\n crossOrigin=\"anonymous\"\n style={{\n ...mapStyles(props.style),\n objectFit: props.contentFit,\n }}\n ref={(newRef) => {\n // This is called with a null value before `player.unmountVideoView` is called,\n // we can't assign null to videoRef if we want to unmount it from the player.\n if (newRef && !newRef.isEqualNode(videoRef.current)) {\n videoRef.current = newRef;\n const audioContext = createAudioContext();\n audioContextRef.current = audioContext;\n zeroGainNodeRef.current = createZeroGainNode(audioContextRef.current);\n mediaNodeRef.current = audioContext\n ? audioContext.createMediaElementSource(newRef)\n : null;\n }\n }}\n src={getSourceUri(props.player?.src) ?? ''}\n />\n );\n});\n\nexport default VideoView;\n"]}
1
+ {"version":3,"file":"VideoView.web.js","sourceRoot":"","sources":["../src/VideoView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAkB,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjE,SAAS,kBAAkB;IACzB,OAAO,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC1E,CAAC;AAED,SAAS,kBAAkB,CAAC,YAAiC;IAC3D,MAAM,YAAY,GAAG,YAAY,EAAE,UAAU,EAAE,IAAI,IAAI,CAAC;IAExD,IAAI,YAAY,IAAI,YAAY,EAAE;QAChC,YAAY,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QAC5B,YAAY,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;KAChD;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAS,SAAS,CAAC,KAA8B;IAC/C,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAClD,qIAAqI;IACrI,OAAO,eAAsC,CAAC;AAChD,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,KAAmD,EAAE,GAAG,EAAE,EAAE;IAC/F,MAAM,QAAQ,GAAG,MAAM,CAA0B,IAAI,CAAC,CAAC;IACvD,MAAM,YAAY,GAAG,MAAM,CAAqC,IAAI,CAAC,CAAC;IAEtE;;;;;OAKG;IACH,MAAM,eAAe,GAAG,MAAM,CAAsB,IAAI,CAAC,CAAC;IAC1D,MAAM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AC,CAAC;IAEnB,OAAO,CACL,CAAC,KAAK,CACJ,QAAQ,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAC/B,YAAY,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,CAClE,WAAW,CAAC,WAAW,CACvB,KAAK,CAAC,CAAC;YACL,GAAG,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC;YACzB,SAAS,EAAE,KAAK,CAAC,UAAU;SAC5B,CAAC,CACF,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE;YACd,+EAA+E;YAC/E,6EAA6E;YAC7E,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;gBACnD,QAAQ,CAAC,OAAO,GAAG,MAAM,CAAC;gBAC1B,MAAM,YAAY,GAAG,kBAAkB,EAAE,CAAC;gBAC1C,eAAe,CAAC,OAAO,GAAG,YAAY,CAAC;gBACvC,eAAe,CAAC,OAAO,GAAG,kBAAkB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;gBACtE,YAAY,CAAC,OAAO,GAAG,YAAY;oBACjC,CAAC,CAAC,YAAY,CAAC,wBAAwB,CAAC,MAAM,CAAC;oBAC/C,CAAC,CAAC,IAAI,CAAC;aACV;QACH,CAAC,CAAC,CACF,GAAG,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,EAC3C,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,SAAS,CAAC","sourcesContent":["import React, { useEffect, useRef, forwardRef, useImperativeHandle } from 'react';\nimport { StyleSheet } from 'react-native';\n\nimport { VideoPlayerWeb, getSourceUri } from './VideoPlayer.web';\nimport type { VideoViewProps } from './VideoView.types';\n\nfunction createAudioContext(): AudioContext | null {\n return typeof window !== 'undefined' ? new window.AudioContext() : null;\n}\n\nfunction createZeroGainNode(audioContext: AudioContext | null): GainNode | null {\n const zeroGainNode = audioContext?.createGain() ?? null;\n\n if (audioContext && zeroGainNode) {\n zeroGainNode.gain.value = 0;\n zeroGainNode.connect(audioContext.destination);\n }\n return zeroGainNode;\n}\n\nfunction mapStyles(style: VideoViewProps['style']): React.CSSProperties {\n const flattenedStyles = StyleSheet.flatten(style);\n // Looking through react-native-web source code they also just pass styles directly without further conversions, so it's just a cast.\n return flattenedStyles as React.CSSProperties;\n}\n\nexport const VideoView = forwardRef((props: { player?: VideoPlayerWeb } & VideoViewProps, ref) => {\n const videoRef = useRef<null | HTMLVideoElement>(null);\n const mediaNodeRef = useRef<null | MediaElementAudioSourceNode>(null);\n\n /**\n * Audio context is used to mute all but one video when multiple video views are playing from one player simultaneously.\n * Using audio context nodes allows muting videos without displaying the mute icon in the video player.\n * We have to keep the context that called createMediaElementSource(videoRef), as the method can't be called\n * for the second time with another context and there is no way to unbind the video and audio context afterward.\n */\n const audioContextRef = useRef<null | AudioContext>(null);\n const zeroGainNodeRef = useRef<null | GainNode>(null);\n\n useImperativeHandle(ref, () => ({\n enterFullscreen: () => {\n if (!props.allowsFullscreen) {\n return;\n }\n videoRef.current?.requestFullscreen();\n },\n exitFullscreen: () => {\n document.exitFullscreen();\n },\n }));\n\n useEffect(() => {\n const audioContext = audioContextRef.current;\n const zeroGainNode = zeroGainNodeRef.current;\n const mediaNode = mediaNodeRef.current;\n\n if (videoRef.current) {\n props.player?.mountVideoView(videoRef.current);\n }\n\n if (audioContext && zeroGainNode && mediaNode) {\n props.player.mountAudioNode(audioContext, zeroGainNode, mediaNode);\n } else {\n console.warn(\n \"Couldn't mount audio node, this might affect the audio playback when using multiple video views with the same player.\"\n );\n }\n\n return () => {\n if (videoRef.current) {\n props.player?.unmountVideoView(videoRef.current);\n }\n if (videoRef.current && audioContext && mediaNode) {\n props.player?.unmountAudioNode(videoRef.current, audioContext, mediaNode);\n }\n };\n }, [props.player]);\n\n return (\n <video\n controls={props.nativeControls}\n controlsList={props.allowsFullscreen ? undefined : 'nofullscreen'}\n crossOrigin=\"anonymous\"\n style={{\n ...mapStyles(props.style),\n objectFit: props.contentFit,\n }}\n ref={(newRef) => {\n // This is called with a null value before `player.unmountVideoView` is called,\n // we can't assign null to videoRef if we want to unmount it from the player.\n if (newRef && !newRef.isEqualNode(videoRef.current)) {\n videoRef.current = newRef;\n const audioContext = createAudioContext();\n audioContextRef.current = audioContext;\n zeroGainNodeRef.current = createZeroGainNode(audioContextRef.current);\n mediaNodeRef.current = audioContext\n ? audioContext.createMediaElementSource(newRef)\n : null;\n }\n }}\n src={getSourceUri(props.player?.src) ?? ''}\n />\n );\n});\n\nexport default VideoView;\n"]}
@@ -14,7 +14,7 @@ internal final class VideoPlayer: SharedRef<AVPlayer>, Hashable, VideoPlayerObse
14
14
  var playbackRate: Float = 1.0 {
15
15
  didSet {
16
16
  if oldValue != playbackRate {
17
- self.emit(event: "playbackRateChange", arguments: playbackRate, oldValue)
17
+ safeEmit(event: "playbackRateChange", arguments: playbackRate, oldValue)
18
18
  }
19
19
  if #available(iOS 16.0, *) {
20
20
  pointer.defaultRate = playbackRate
@@ -43,7 +43,7 @@ internal final class VideoPlayer: SharedRef<AVPlayer>, Hashable, VideoPlayerObse
43
43
  let oldVolumeEvent = VolumeEvent(volume: oldValue, isMuted: isMuted)
44
44
  let newVolumeEvent = VolumeEvent(volume: volume, isMuted: isMuted)
45
45
 
46
- self.emit(event: "volumeChange", arguments: newVolumeEvent, oldVolumeEvent)
46
+ safeEmit(event: "volumeChange", arguments: newVolumeEvent, oldVolumeEvent)
47
47
  }
48
48
  pointer.volume = volume
49
49
  }
@@ -55,7 +55,7 @@ internal final class VideoPlayer: SharedRef<AVPlayer>, Hashable, VideoPlayerObse
55
55
  let oldVolumeEvent = VolumeEvent(volume: volume, isMuted: oldValue)
56
56
  let newVolumeEvent = VolumeEvent(volume: volume, isMuted: isMuted)
57
57
 
58
- self.emit(event: "volumeChange", arguments: newVolumeEvent.isMuted, oldVolumeEvent.isMuted)
58
+ safeEmit(event: "volumeChange", arguments: newVolumeEvent, oldVolumeEvent)
59
59
  }
60
60
  pointer.isMuted = isMuted
61
61
  VideoManager.shared.setAppropriateAudioSessionOrWarn()
@@ -131,12 +131,12 @@ internal final class VideoPlayer: SharedRef<AVPlayer>, Hashable, VideoPlayerObse
131
131
 
132
132
  func onStatusChanged(player: AVPlayer, oldStatus: PlayerStatus?, newStatus: PlayerStatus, error: Exception?) {
133
133
  let errorRecord = error != nil ? PlaybackError(message: error?.localizedDescription) : nil
134
- self.emit(event: "statusChange", arguments: newStatus.rawValue, oldStatus?.rawValue, errorRecord)
134
+ safeEmit(event: "statusChange", arguments: newStatus.rawValue, oldStatus?.rawValue, errorRecord)
135
135
  status = newStatus
136
136
  }
137
137
 
138
138
  func onIsPlayingChanged(player: AVPlayer, oldIsPlaying: Bool?, newIsPlaying: Bool) {
139
- self.emit(event: "playingChange", arguments: newIsPlaying, oldIsPlaying)
139
+ safeEmit(event: "playingChange", arguments: newIsPlaying, oldIsPlaying)
140
140
  isPlaying = newIsPlaying
141
141
 
142
142
  VideoManager.shared.setAppropriateAudioSessionOrWarn()
@@ -164,7 +164,7 @@ internal final class VideoPlayer: SharedRef<AVPlayer>, Hashable, VideoPlayerObse
164
164
  }
165
165
 
166
166
  func onPlayedToEnd(player: AVPlayer) {
167
- self.emit(event: "playToEnd")
167
+ safeEmit(event: "playToEnd")
168
168
  if loop {
169
169
  self.pointer.seek(to: .zero)
170
170
  self.pointer.play()
@@ -172,7 +172,13 @@ internal final class VideoPlayer: SharedRef<AVPlayer>, Hashable, VideoPlayerObse
172
172
  }
173
173
 
174
174
  func onItemChanged(player: AVPlayer, oldVideoPlayerItem: VideoPlayerItem?, newVideoPlayerItem: VideoPlayerItem?) {
175
- self.emit(event: "sourceChange", arguments: newVideoPlayerItem?.videoSource, oldVideoPlayerItem?.videoSource)
175
+ safeEmit(event: "sourceChange", arguments: newVideoPlayerItem?.videoSource, oldVideoPlayerItem?.videoSource)
176
+ }
177
+
178
+ func safeEmit<each A: AnyArgument>(event: String, arguments: repeat each A) {
179
+ if self.appContext != nil {
180
+ self.emit(event: event, arguments: repeat each arguments)
181
+ }
176
182
  }
177
183
 
178
184
  // MARK: - Hashable
@@ -161,7 +161,8 @@ class VideoPlayerObserver {
161
161
  // MARK: - VideoPlayerObserverDelegate
162
162
 
163
163
  private func onPlayerCurrentItemChanged(_ player: AVPlayer, _ change: NSKeyValueObservedChange<AVPlayerItem?>) {
164
- let newPlayerItem = change.newValue
164
+ // Unwraps Optional<Optional<AVPlayerItem>> into Optional<AVPlayerItem>
165
+ let newPlayerItem = change.newValue?.flatMap({ $0 })
165
166
 
166
167
  invalidateCurrentPlayerItemObservers()
167
168
 
@@ -182,7 +183,7 @@ class VideoPlayerObserver {
182
183
  status = .idle
183
184
  } else {
184
185
  log.warn(
185
- "VideoPlayer's AVPlayer has been initialized with a `AVPlayerItem` instead of a `VideoPlayerItem`." +
186
+ "VideoPlayer's AVPlayer has been initialized with a `AVPlayerItem` instead of a `VideoPlayerItem`. " +
186
187
  "Always use `VideoPlayerItem` as a wrapper for media played in `VideoPlayer`."
187
188
  )
188
189
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "expo-video",
3
3
  "title": "Expo Video",
4
- "version": "1.1.5",
4
+ "version": "1.1.7",
5
5
  "description": "A cross-platform, performant video component for React Native and Expo with Web support",
6
6
  "main": "build/index.js",
7
7
  "types": "build/index.d.ts",
@@ -36,5 +36,5 @@
36
36
  "peerDependencies": {
37
37
  "expo": "*"
38
38
  },
39
- "gitHead": "20f1765146f63f8fdc2543e8aba8b0e5140d1e05"
39
+ "gitHead": "7995f30a8d2af4836f3aef9fe322e9403fc23d34"
40
40
  }
@@ -1,6 +1,10 @@
1
1
  import { requireNativeModule } from 'expo-modules-core';
2
2
 
3
- /**
4
- * @hidden
5
- */
6
- export default requireNativeModule('ExpoVideo');
3
+ import type { VideoPlayer } from './VideoView.types';
4
+
5
+ type ExpoVideoModule = {
6
+ VideoPlayer: typeof VideoPlayer;
7
+ isPictureInPictureSupported(): boolean;
8
+ };
9
+
10
+ export default requireNativeModule<ExpoVideoModule>('ExpoVideo');
@@ -1,7 +1,7 @@
1
1
  import { useReleasingSharedObject } from 'expo-modules-core';
2
2
 
3
3
  import NativeVideoModule from './NativeVideoModule';
4
- import { VideoPlayer, VideoSource } from './VideoView.types';
4
+ import type { VideoPlayer, VideoSource } from './VideoView.types';
5
5
 
6
6
  /**
7
7
  * Creates a `VideoPlayer`, which will be automatically cleaned up when the component is unmounted.
@@ -1,6 +1,11 @@
1
1
  import { useMemo } from 'react';
2
2
 
3
- import { VideoPlayer, VideoPlayerEvents, VideoPlayerStatus, VideoSource } from './VideoView.types';
3
+ import type {
4
+ VideoPlayer,
5
+ VideoPlayerEvents,
6
+ VideoPlayerStatus,
7
+ VideoSource,
8
+ } from './VideoView.types';
4
9
 
5
10
  export function useVideoPlayer(
6
11
  source: VideoSource,
package/src/VideoView.tsx CHANGED
@@ -2,7 +2,7 @@ import { ReactNode, PureComponent, createRef } from 'react';
2
2
 
3
3
  import NativeVideoModule from './NativeVideoModule';
4
4
  import NativeVideoView from './NativeVideoView';
5
- import { VideoPlayer, VideoViewProps } from './VideoView.types';
5
+ import type { VideoPlayer, VideoViewProps } from './VideoView.types';
6
6
 
7
7
  /**
8
8
  * Returns whether the current device supports Picture in Picture (PiP) mode.
@@ -10,7 +10,7 @@ import { VideoPlayer, VideoViewProps } from './VideoView.types';
10
10
  * @platform android
11
11
  * @platform ios
12
12
  */
13
- export function isPictureInPictureSupported(): Promise<boolean> {
13
+ export function isPictureInPictureSupported(): boolean {
14
14
  return NativeVideoModule.isPictureInPictureSupported();
15
15
  }
16
16
 
@@ -19,12 +19,18 @@ export declare class VideoPlayer extends SharedObject<VideoPlayerEvents> {
19
19
 
20
20
  /**
21
21
  * Boolean value whether the player is currently muted.
22
+ * Setting this property to `true`/`false` will mute/unmute the player.
22
23
  * @default false
23
24
  */
24
25
  muted: boolean;
25
26
 
26
27
  /**
27
- * Integer value representing the current position in seconds.
28
+ * Float value indicating the current playback time in seconds.
29
+ *
30
+ * If the player is not yet playing, this value indicates the time position
31
+ * at which playback will begin once the `play()` method is called.
32
+ *
33
+ * Setting `currentTime` to a new value seeks the player to the given time.
28
34
  */
29
35
  currentTime: number;
30
36
 
@@ -70,6 +76,12 @@ export declare class VideoPlayer extends SharedObject<VideoPlayerEvents> {
70
76
  */
71
77
  staysActiveInBackground: boolean;
72
78
 
79
+ /**
80
+ * Initializes a new video player instance with the given source.
81
+ * @hidden
82
+ */
83
+ constructor(source: VideoSource);
84
+
73
85
  /**
74
86
  * Resumes the player.
75
87
  */
@@ -260,31 +272,31 @@ export type VideoPlayerEvents = {
260
272
  /**
261
273
  * Handler for an event emitted when the status of the player changes.
262
274
  */
263
- statusChange: (
275
+ statusChange(
264
276
  newStatus: VideoPlayerStatus,
265
277
  oldStatus: VideoPlayerStatus,
266
278
  error: PlayerError
267
- ) => void;
279
+ ): void;
268
280
  /**
269
281
  * Handler for an event emitted when the player starts or stops playback.
270
282
  */
271
- playingChange: (newIsPlaying: boolean, oldIsPlaying: boolean) => void;
283
+ playingChange(newIsPlaying: boolean, oldIsPlaying: boolean): void;
272
284
  /**
273
285
  * Handler for an event emitted when the `playbackRate` property of the player changes.
274
286
  */
275
- playbackRateChange: (newPlaybackRate: number, oldPlaybackRate: number) => void;
287
+ playbackRateChange(newPlaybackRate: number, oldPlaybackRate: number): void;
276
288
  /**
277
289
  * Handler for an event emitted when the `volume` property of the player changes.
278
290
  */
279
- volumeChange: (newVolume: VolumeEvent, oldVolume: VolumeEvent) => void;
291
+ volumeChange(newVolume: VolumeEvent, oldVolume: VolumeEvent): void;
280
292
  /**
281
293
  * Handler for an event emitted when the player plays to the end of the current source.
282
294
  */
283
- playToEnd: () => void;
295
+ playToEnd(): void;
284
296
  /**
285
297
  * Handler for an event emitted when the current media source of the player changes.
286
298
  */
287
- sourceChange: (newSource: VideoSource, previousSource: VideoSource) => void;
299
+ sourceChange(newSource: VideoSource, previousSource: VideoSource): void;
288
300
  };
289
301
 
290
302
  /**
@@ -2,7 +2,7 @@ import React, { useEffect, useRef, forwardRef, useImperativeHandle } from 'react
2
2
  import { StyleSheet } from 'react-native';
3
3
 
4
4
  import { VideoPlayerWeb, getSourceUri } from './VideoPlayer.web';
5
- import { VideoViewProps } from './VideoView.types';
5
+ import type { VideoViewProps } from './VideoView.types';
6
6
 
7
7
  function createAudioContext(): AudioContext | null {
8
8
  return typeof window !== 'undefined' ? new window.AudioContext() : null;