expo-video 2.0.0-preview.2 → 2.0.1

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.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,18 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 2.0.1 — 2024-11-19
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - [Android] Fixed `border` related props weren't applied correctly. ([#33075](https://github.com/expo/expo/pull/33075) by [@lukmccall](https://github.com/lukmccall))
18
+
19
+ ## 2.0.0 — 2024-11-11
20
+
21
+ ### 💡 Others
22
+
23
+ - [Android] Modify aspect ratio coverage of Android PiP to be more specific ([#32551](https://github.com/expo/expo/pull/32551) by [@YangJonghun](https://github.com/YangJonghun))
24
+
13
25
  ## 2.0.0-preview.2 — 2024-11-07
14
26
 
15
27
  ### 🎉 New features
@@ -1,7 +1,7 @@
1
1
  apply plugin: 'com.android.library'
2
2
 
3
3
  group = 'host.exp.exponent'
4
- version = '2.0.0-preview.2'
4
+ version = '2.0.1'
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 '2.0.0-preview.2'
17
+ versionName '2.0.1'
18
18
  }
19
19
  }
20
20
 
@@ -7,10 +7,6 @@ import androidx.media3.common.PlaybackParameters
7
7
  import androidx.media3.common.Player.REPEAT_MODE_OFF
8
8
  import androidx.media3.common.Player.REPEAT_MODE_ONE
9
9
  import com.facebook.react.common.annotations.UnstableReactNativeAPI
10
- import com.facebook.react.uimanager.PixelUtil
11
- import com.facebook.react.uimanager.Spacing
12
- import com.facebook.react.uimanager.ViewProps
13
- import com.facebook.yoga.YogaConstants
14
10
  import expo.modules.kotlin.apifeatures.EitherType
15
11
  import expo.modules.kotlin.functions.Coroutine
16
12
  import expo.modules.kotlin.modules.Module
@@ -22,8 +18,6 @@ import expo.modules.video.player.VideoPlayer
22
18
  import expo.modules.video.records.BufferOptions
23
19
  import expo.modules.video.records.SubtitleTrack
24
20
  import expo.modules.video.records.VideoSource
25
- import expo.modules.video.utils.ifYogaDefinedUse
26
- import expo.modules.video.utils.makeYogaUndefinedIfNegative
27
21
  import expo.modules.video.utils.runWithPiPMisconfigurationSoftHandling
28
22
  import kotlinx.coroutines.async
29
23
  import kotlinx.coroutines.awaitAll
@@ -80,55 +74,6 @@ class VideoModule : Module() {
80
74
  view.videoPlayer?.requiresLinearPlayback = linearPlayback
81
75
  }
82
76
 
83
- PropGroup(
84
- ViewProps.BORDER_RADIUS to 0,
85
- ViewProps.BORDER_TOP_LEFT_RADIUS to 1,
86
- ViewProps.BORDER_TOP_RIGHT_RADIUS to 2,
87
- ViewProps.BORDER_BOTTOM_RIGHT_RADIUS to 3,
88
- ViewProps.BORDER_BOTTOM_LEFT_RADIUS to 4,
89
- ViewProps.BORDER_TOP_START_RADIUS to 5,
90
- ViewProps.BORDER_TOP_END_RADIUS to 6,
91
- ViewProps.BORDER_BOTTOM_START_RADIUS to 7,
92
- ViewProps.BORDER_BOTTOM_END_RADIUS to 8
93
- ) { view: VideoView, index: Int, borderRadius: Float? ->
94
- val radius = makeYogaUndefinedIfNegative(borderRadius ?: YogaConstants.UNDEFINED)
95
- view.setBorderRadius(index, radius)
96
- }
97
-
98
- PropGroup(
99
- ViewProps.BORDER_WIDTH to Spacing.ALL,
100
- ViewProps.BORDER_LEFT_WIDTH to Spacing.LEFT,
101
- ViewProps.BORDER_RIGHT_WIDTH to Spacing.RIGHT,
102
- ViewProps.BORDER_TOP_WIDTH to Spacing.TOP,
103
- ViewProps.BORDER_BOTTOM_WIDTH to Spacing.BOTTOM,
104
- ViewProps.BORDER_START_WIDTH to Spacing.START,
105
- ViewProps.BORDER_END_WIDTH to Spacing.END
106
- ) { view: VideoView, index: Int, width: Float? ->
107
- val pixelWidth = makeYogaUndefinedIfNegative(width ?: YogaConstants.UNDEFINED)
108
- .ifYogaDefinedUse(PixelUtil::toPixelFromDIP)
109
- view.setBorderWidth(index, pixelWidth)
110
- }
111
-
112
- PropGroup(
113
- ViewProps.BORDER_COLOR to Spacing.ALL,
114
- ViewProps.BORDER_LEFT_COLOR to Spacing.LEFT,
115
- ViewProps.BORDER_RIGHT_COLOR to Spacing.RIGHT,
116
- ViewProps.BORDER_TOP_COLOR to Spacing.TOP,
117
- ViewProps.BORDER_BOTTOM_COLOR to Spacing.BOTTOM,
118
- ViewProps.BORDER_START_COLOR to Spacing.START,
119
- ViewProps.BORDER_END_COLOR to Spacing.END
120
- ) { view: VideoView, index: Int, color: Int ->
121
- view.setBorderColor(index, color)
122
- }
123
-
124
- Prop("borderStyle") { view: VideoView, borderStyle: String? ->
125
- view.setBorderStyle(borderStyle)
126
- }
127
-
128
- OnViewDidUpdateProps { view: VideoView ->
129
- view.didUpdateProps()
130
- }
131
-
132
77
  AsyncFunction("enterFullscreen") { view: VideoView ->
133
78
  view.enterFullscreen()
134
79
  }
@@ -4,7 +4,6 @@ import android.app.Activity
4
4
  import android.app.PictureInPictureParams
5
5
  import android.content.Context
6
6
  import android.content.Intent
7
- import android.graphics.Canvas
8
7
  import android.os.Build
9
8
  import android.util.Rational
10
9
  import android.view.View
@@ -14,27 +13,16 @@ import android.widget.ImageButton
14
13
  import androidx.fragment.app.FragmentActivity
15
14
  import androidx.media3.common.Tracks
16
15
  import androidx.media3.ui.PlayerView
17
- import com.facebook.react.common.annotations.UnstableReactNativeAPI
18
- import com.facebook.react.modules.i18nmanager.I18nUtil
19
- import com.facebook.react.uimanager.LengthPercentage
20
- import com.facebook.react.uimanager.LengthPercentageType
21
- import com.facebook.react.uimanager.PixelUtil
22
- import com.facebook.react.uimanager.Spacing
23
- import com.facebook.react.uimanager.drawable.CSSBackgroundDrawable
24
- import com.facebook.react.uimanager.style.BorderRadiusProp
25
- import com.facebook.yoga.YogaConstants
26
16
  import expo.modules.kotlin.AppContext
27
17
  import expo.modules.kotlin.viewevent.EventDispatcher
28
18
  import expo.modules.kotlin.views.ExpoView
29
19
  import expo.modules.video.delegates.IgnoreSameSet
30
- import expo.modules.video.drawing.OutlineProvider
31
20
  import expo.modules.video.enums.ContentFit
32
21
  import expo.modules.video.player.VideoPlayer
33
22
  import expo.modules.video.player.VideoPlayerListener
34
23
  import expo.modules.video.utils.applyAutoEnterPiP
35
24
  import expo.modules.video.utils.applyRectHint
36
25
  import expo.modules.video.utils.calculateRectHint
37
- import expo.modules.video.utils.ifYogaDefinedUse
38
26
  import java.util.UUID
39
27
 
40
28
  // https://developer.android.com/guide/topics/media/media3/getting-started/migration-guide#improvements_in_media3
@@ -64,32 +52,6 @@ class VideoView(context: Context, appContext: AppContext) : ExpoView(context, ap
64
52
  private val rootViewChildrenOriginalVisibility: ArrayList<Int> = arrayListOf()
65
53
  private var pictureInPictureHelperTag: String? = null
66
54
 
67
- private var shouldInvalided = false
68
-
69
- private val outlineProvider = OutlineProvider(context)
70
-
71
- @UnstableReactNativeAPI
72
- private val borderDrawableLazyHolder = lazy {
73
- CSSBackgroundDrawable(context).apply {
74
- callback = this@VideoView
75
-
76
- outlineProvider.borderRadiiConfig
77
- .map { it.ifYogaDefinedUse(PixelUtil::toPixelFromDIP) }
78
- .withIndex()
79
- .forEach { (i, radius) ->
80
- if (i == 0) {
81
- setBorderRadius(BorderRadiusProp.BORDER_RADIUS, LengthPercentage(radius, LengthPercentageType.POINT))
82
- } else {
83
- setBorderRadius(BorderRadiusProp.entries[i - 1], LengthPercentage(radius, LengthPercentageType.POINT))
84
- }
85
- }
86
- }
87
- }
88
-
89
- @UnstableReactNativeAPI
90
- private val borderDrawable
91
- get() = borderDrawableLazyHolder.value
92
-
93
55
  var autoEnterPiP: Boolean by IgnoreSameSet(false) { new, _ ->
94
56
  applyAutoEnterPiP(currentActivity, new)
95
57
  }
@@ -201,11 +163,14 @@ class VideoView(context: Context, appContext: AppContext) : ExpoView(context, ap
201
163
  } else {
202
164
  Rational(width, height)
203
165
  }
204
- // Android PiP doesn't support aspect ratios lower than 0.4184 or higher than 2.39
205
- if (aspectRatio.toFloat() > 2.39) {
206
- aspectRatio = Rational(239, 100)
207
- } else if (aspectRatio.toFloat() < 0.4184) {
208
- aspectRatio = Rational(10000, 4184)
166
+ // AspectRatio for the activity in picture-in-picture, must be between 2.39:1 and 1:2.39 (inclusive).
167
+ // https://developer.android.com/reference/android/app/PictureInPictureParams.Builder#setAspectRatio(android.util.Rational)
168
+ val maximumRatio = Rational(239, 100)
169
+ val minimumRatio = Rational(100, 239)
170
+ if (aspectRatio.toFloat() > maximumRatio.toFloat()) {
171
+ aspectRatio = maximumRatio
172
+ } else if (aspectRatio.toFloat() < minimumRatio.toFloat()) {
173
+ aspectRatio = minimumRatio
209
174
  }
210
175
 
211
176
  currentActivity.setPictureInPictureParams(
@@ -274,31 +239,6 @@ class VideoView(context: Context, appContext: AppContext) : ExpoView(context, ap
274
239
  applyRectHint(currentActivity, calculateRectHint(playerView))
275
240
  }
276
241
 
277
- @UnstableReactNativeAPI
278
- override fun draw(canvas: Canvas) {
279
- // When the border-radii are not all the same, a convex-path
280
- // is used for the Outline. Unfortunately clipping is not supported
281
- // for convex-paths and we fallback to Canvas clipping.
282
- outlineProvider.clipCanvasIfNeeded(canvas, this)
283
-
284
- super.draw(canvas)
285
-
286
- // Draw borders on top of the video
287
- if (borderDrawableLazyHolder.isInitialized()) {
288
- val newLayoutDirection = if (I18nUtil.instance.isRTL(context)) {
289
- LAYOUT_DIRECTION_RTL
290
- } else {
291
- LAYOUT_DIRECTION_LTR
292
- }
293
-
294
- borderDrawable.apply {
295
- layoutDirection = newLayoutDirection
296
- setBounds(0, 0, width, height)
297
- draw(canvas)
298
- }
299
- }
300
- }
301
-
302
242
  override fun onAttachedToWindow() {
303
243
  super.onAttachedToWindow()
304
244
  (currentActivity as? FragmentActivity)?.let {
@@ -323,78 +263,6 @@ class VideoView(context: Context, appContext: AppContext) : ExpoView(context, ap
323
263
  applyAutoEnterPiP(currentActivity, false)
324
264
  }
325
265
 
326
- @UnstableReactNativeAPI
327
- internal fun setBorderRadius(position: Int, borderRadius: Float) {
328
- val isInvalidated = outlineProvider.setBorderRadius(borderRadius, position)
329
- if (isInvalidated) {
330
- invalidateOutline()
331
- if (!outlineProvider.hasEqualCorners()) {
332
- shouldInvalided = true
333
- }
334
- }
335
-
336
- // Setting the border-radius doesn't necessarily mean that a border
337
- // should to be drawn. Only update the border-drawable when needed.
338
- if (borderDrawableLazyHolder.isInitialized()) {
339
- shouldInvalided = true
340
- val radius = borderRadius.ifYogaDefinedUse(PixelUtil::toPixelFromDIP)
341
- borderDrawableLazyHolder.value.apply {
342
- if (position == 0) {
343
- setBorderRadius(BorderRadiusProp.BORDER_RADIUS, LengthPercentage(radius, LengthPercentageType.POINT))
344
- } else {
345
- setBorderRadius(BorderRadiusProp.entries[position - 1], LengthPercentage(radius, LengthPercentageType.POINT))
346
- }
347
- }
348
- }
349
- }
350
-
351
- @UnstableReactNativeAPI
352
- internal fun setBorderWidth(position: Int, width: Float) {
353
- borderDrawable.setBorderWidth(position, width)
354
- shouldInvalided = true
355
- }
356
-
357
- @UnstableReactNativeAPI
358
- internal fun setBorderColor(position: Int, rgb: Int) {
359
- borderDrawable.setBorderColor(position, rgb)
360
- shouldInvalided = true
361
- }
362
-
363
- @UnstableReactNativeAPI
364
- internal fun setBorderStyle(style: String?) {
365
- borderDrawable.setBorderStyle(style)
366
- shouldInvalided = true
367
- }
368
-
369
- @UnstableReactNativeAPI
370
- fun didUpdateProps() {
371
- val hasBorder = if (borderDrawableLazyHolder.isInitialized()) {
372
- val spacings = listOf(
373
- Spacing.ALL,
374
- Spacing.LEFT,
375
- Spacing.RIGHT,
376
- Spacing.TOP,
377
- Spacing.BOTTOM,
378
- Spacing.START,
379
- Spacing.END
380
- )
381
- spacings
382
- .any {
383
- val boarderWidth = borderDrawable.getBorderWidthOrDefaultTo(YogaConstants.UNDEFINED, it)
384
- boarderWidth != YogaConstants.UNDEFINED && boarderWidth > 0f
385
- }
386
- } else {
387
- false
388
- }
389
-
390
- // We need to enable drawing on the view to draw the border or background
391
- setWillNotDraw(!isOpaque && !hasBorder)
392
- if (shouldInvalided) {
393
- shouldInvalided = false
394
- invalidate()
395
- }
396
- }
397
-
398
266
  companion object {
399
267
  fun isPictureInPictureSupported(currentActivity: Activity): Boolean {
400
268
  return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && currentActivity.packageManager.hasSystemFeature(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "expo-video",
3
3
  "title": "Expo Video",
4
- "version": "2.0.0-preview.2",
4
+ "version": "2.0.1",
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",
@@ -38,5 +38,5 @@
38
38
  "react": "*",
39
39
  "react-native": "*"
40
40
  },
41
- "gitHead": "c0899e56c5be08b0142f06f05aa7bac8d6bc18b8"
41
+ "gitHead": "128718d43bac2eaed764b3551469b95400f2363e"
42
42
  }