Skip to content

Commit

Permalink
chore: bump to alpha.7
Browse files Browse the repository at this point in the history
  • Loading branch information
remigallego committed Apr 25, 2024
1 parent 7344eb6 commit e516bc4
Show file tree
Hide file tree
Showing 15 changed files with 181 additions and 117 deletions.
12 changes: 12 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ var styles = StyleSheet.create({
| [selectedAudioTrack](#selectedaudiotrack) | Android, iOS |
| [selectedTextTrack](#selectedtexttrack) | Android, iOS |
| [selectedVideoTrack](#selectedvideotrack) | Android |
| [shutterColor](#shutterColor) | Android |
| [source](#source) | All |
| [subtitleStyle](#subtitleStyle) | Android |
| [textTracks](#texttracks) | Android, iOS |
Expand Down Expand Up @@ -852,6 +853,17 @@ If a track matching the specified Type (and Value if appropriate) is unavailable

Platforms: Android

#### shutterColor
Apply color to shutter view, if you see black flashes before video start then set

```
shutterColor='transparent'
```

- black (default)

Platforms: Android

#### source
Sets the media source. You can pass an asset loaded via require or an object with a uri.

Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
## Changelog

### Version 6.0.0-alpha.7
- All: clean JS warnings (https://github.com/react-native-video/react-native-video/pull/3183)
- Android: Add shutterView color configurtion (https://github.com/react-native-video/react-native-video/pull/3179)
- Android: React native 0.73 support (https://github.com/react-native-video/react-native-video/pull/3163)
- Android: Fix memory leaks from AudioManager [#3123](https://github.com/react-native-video/react-native-video/pull/3123)
- Android: Fixed syntax error [#3182](https://github.com/react-native-video/react-native-video/issues/3182)
- iOS: Fix freeze at playback startup (https://github.com/react-native-video/react-native-video/pull/3173)
- iOS: Various safety checks (https://github.com/react-native-video/react-native-video/pull/3168)

### Version 6.0.0-alpha.6
- Feature: Video range support [#3030](https://github.com/react-native-video/react-native-video/pull/3030)
- iOS: remove undocumented `currentTime` property [#3064](https://github.com/react-native-video/react-native-video/pull/3064)
Expand Down
18 changes: 3 additions & 15 deletions Video.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default class Video extends Component {
this.setNativeProps({ fullscreen: false });
};

save = async (options?) => {
save = async (options) => {
return await NativeModules.VideoManager.save(options, findNodeHandle(this._root));
}

Expand Down Expand Up @@ -423,13 +423,6 @@ Video.propTypes = {
FilterType.SEPIA,
]),
filterEnabled: PropTypes.bool,
/* Native only */
src: PropTypes.object,
seek: PropTypes.oneOfType([
PropTypes.number,
PropTypes.object,
]),
fullscreen: PropTypes.bool,
onVideoLoadStart: PropTypes.func,
onVideoLoad: PropTypes.func,
onVideoBuffer: PropTypes.func,
Expand Down Expand Up @@ -542,6 +535,7 @@ Video.propTypes = {
useTextureView: PropTypes.bool,
useSecureView: PropTypes.bool,
hideShutterView: PropTypes.bool,
shutterColor: PropTypes.string,
onLoadStart: PropTypes.func,
onPlaybackStateChanged: PropTypes.func,
onLoad: PropTypes.func,
Expand Down Expand Up @@ -574,10 +568,4 @@ Video.propTypes = {
...ViewPropTypes,
};

const RCTVideo = requireNativeComponent('RCTVideo', Video, {
nativeOnly: {
src: true,
seek: true,
fullscreen: true,
},
});
const RCTVideo = requireNativeComponent('RCTVideo');
1 change: 1 addition & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def configStringPath = (
).md5()

android {
namespace 'com.brentvatne.react'
compileSdkVersion safeExtGet('compileSdkVersion', 31)
buildToolsVersion safeExtGet('buildToolsVersion', '30.0.2')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ public void setSubtitleStyle(SubtitleStyle style) {
subtitleLayout.setPadding(style.getPaddingLeft(), style.getPaddingTop(), style.getPaddingRight(), style.getPaddingBottom());
}

public void setShutterColor(Integer color) {
shutterView.setBackgroundColor(color);
}

private void updateSurfaceView() {
View view;
if (!useTextureView || useSecureView) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ class ReactExoplayerView extends FrameLayout implements
Player.Listener,
BandwidthMeter.EventListener,
BecomingNoisyListener,
AudioManager.OnAudioFocusChangeListener,
DrmSessionEventListener,
AdEvent.AdEventListener {

Expand Down Expand Up @@ -215,6 +214,7 @@ class ReactExoplayerView extends FrameLayout implements
private final ThemedReactContext themedReactContext;
private final AudioManager audioManager;
private final AudioBecomingNoisyReceiver audioBecomingNoisyReceiver;
private final AudioManager.OnAudioFocusChangeListener audioFocusChangeListener;

// store last progress event values to avoid sending unnecessary messages
private long lastPos = -1;
Expand Down Expand Up @@ -270,6 +270,7 @@ public ReactExoplayerView(ThemedReactContext context, ReactExoplayerConfig confi
audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
themedReactContext.addLifecycleEventListener(this);
audioBecomingNoisyReceiver = new AudioBecomingNoisyReceiver(themedReactContext);
audioFocusChangeListener = new OnAudioFocusChangedListener(this);
}

private boolean isPlayingAd() {
Expand Down Expand Up @@ -305,9 +306,7 @@ private void createViews() {
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
// uncommented `initializePlayer()`, because it caused video to restart when it is running
// behind another screen and the user navigated back to the screen where the video runs
// initializePlayer();
initializePlayer();
}

@Override
Expand Down Expand Up @@ -905,11 +904,54 @@ private void releasePlayer() {
bandwidthMeter.removeEventListener(this);
}

private static class OnAudioFocusChangedListener implements AudioManager.OnAudioFocusChangeListener {
private final ReactExoplayerView view;

private OnAudioFocusChangedListener(ReactExoplayerView view) {
this.view = view;
}

@Override
public void onAudioFocusChange(int focusChange) {
switch (focusChange) {
case AudioManager.AUDIOFOCUS_LOSS:
view.hasAudioFocus = false;
view.eventEmitter.audioFocusChanged(false);
view.pausePlayback();
view.audioManager.abandonAudioFocus(this);
break;
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
view.eventEmitter.audioFocusChanged(false);
break;
case AudioManager.AUDIOFOCUS_GAIN:
view.hasAudioFocus = true;
view.eventEmitter.audioFocusChanged(true);
break;
default:
break;
}

if (view.player != null) {
if (focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK) {
// Lower the volume
if (!view.muted) {
view.player.setVolume(view.audioVolume * 0.8f);
}
} else if (focusChange == AudioManager.AUDIOFOCUS_GAIN) {
// Raise it back to normal
if (!view.muted) {
view.player.setVolume(view.audioVolume * 1);
}
}
}
}
}

private boolean requestAudioFocus() {
if (disableFocus || srcUri == null || this.hasAudioFocus) {
return true;
}
int result = audioManager.requestAudioFocus(this,
int result = audioManager.requestAudioFocus(audioFocusChangeListener,
AudioManager.STREAM_MUSIC,
AudioManager.AUDIOFOCUS_GAIN);
return result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED;
Expand Down Expand Up @@ -975,7 +1017,7 @@ private void onStopPlayback() {
if (isFullscreen) {
setFullscreen(false);
}
audioManager.abandonAudioFocus(this);
audioManager.abandonAudioFocus(audioFocusChangeListener);
}

private void updateResumePosition() {
Expand Down Expand Up @@ -1013,43 +1055,6 @@ private HttpDataSource.Factory buildHttpDataSourceFactory(boolean useBandwidthMe
}


// AudioManager.OnAudioFocusChangeListener implementation

@Override
public void onAudioFocusChange(int focusChange) {
switch (focusChange) {
case AudioManager.AUDIOFOCUS_LOSS:
this.hasAudioFocus = false;
eventEmitter.audioFocusChanged(false);
pausePlayback();
audioManager.abandonAudioFocus(this);
break;
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
eventEmitter.audioFocusChanged(false);
break;
case AudioManager.AUDIOFOCUS_GAIN:
this.hasAudioFocus = true;
eventEmitter.audioFocusChanged(true);
break;
default:
break;
}

if (player != null) {
if (focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK) {
// Lower the volume
if (!muted) {
player.setVolume(audioVolume * 0.8f);
}
} else if (focusChange == AudioManager.AUDIOFOCUS_GAIN) {
// Raise it back to normal
if (!muted) {
player.setVolume(audioVolume * 1);
}
}
}
}

// AudioBecomingNoisyListener implementation

@Override
Expand Down Expand Up @@ -2037,6 +2042,10 @@ public void setSubtitleStyle(SubtitleStyle style) {
exoPlayerView.setSubtitleStyle(style);
}

public void setShutterColor(Integer color) {
exoPlayerView.setShutterColor(color);
}

@Override
public void onAdEvent(AdEvent adEvent) {
eventEmitter.receiveAdEvent(adEvent.getType().name());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.brentvatne.exoplayer;

import android.graphics.Color;
import android.content.Context;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;

import com.facebook.react.bridge.Dynamic;
import com.facebook.react.bridge.ReadableArray;
Expand All @@ -13,7 +13,6 @@
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.ViewGroupManager;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.bridge.ReactMethod;
import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.DefaultLoadControl;
import com.google.android.exoplayer2.upstream.RawResourceDataSource;
Expand Down Expand Up @@ -81,8 +80,8 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
private static final String PROP_SELECTED_VIDEO_TRACK_VALUE = "value";
private static final String PROP_HIDE_SHUTTER_VIEW = "hideShutterView";
private static final String PROP_CONTROLS = "controls";

private static final String PROP_SUBTITLE_STYLE = "subtitleStyle";
private static final String PROP_SHUTTER_COLOR = "shutterColor";

private ReactExoplayerConfig config;

Expand Down Expand Up @@ -378,6 +377,11 @@ public void setSubtitleStyle(final ReactExoplayerView videoView, @Nullable final
videoView.setSubtitleStyle(SubtitleStyle.parse(src));
}

@ReactProp(name = PROP_SHUTTER_COLOR, customType = "Color")
public void setShutterColor(final ReactExoplayerView videoView, final Integer color) {
videoView.setShutterColor(color == null ? Color.BLACK : color);
}

@ReactProp(name = PROP_BUFFER_CONFIG)
public void setBufferConfig(final ReactExoplayerView videoView, @Nullable ReadableMap bufferConfig) {
int minBufferMs = DefaultLoadControl.DEFAULT_MIN_BUFFER_MS;
Expand Down
20 changes: 10 additions & 10 deletions android/src/main/res/layout/exo_player_control_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@
android:paddingTop="4dp"
android:orientation="horizontal">

<ImageButton android:id="@id/exo_prev"
<ImageButton android:id="@+id/exo_prev"
style="@style/ExoMediaButton.Previous"/>

<ImageButton android:id="@id/exo_rew"
<ImageButton android:id="@+id/exo_rew"
style="@style/ExoMediaButton.Rewind"/>
<FrameLayout
android:id="@+id/exo_play_pause_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<ImageButton android:id="@id/exo_play"
<ImageButton android:id="@+id/exo_play"
style="@style/ExoMediaButton.Play"/>

<ImageButton android:id="@id/exo_pause"
<ImageButton android:id="@+id/exo_pause"
style="@style/ExoMediaButton.Pause"/>
</FrameLayout>

<ImageButton android:id="@id/exo_ffwd"
<ImageButton android:id="@+id/exo_ffwd"
style="@style/ExoMediaButton.FastForward"/>

<ImageButton android:id="@id/exo_next"
<ImageButton android:id="@+id/exo_next"
style="@style/ExoMediaButton.Next"/>

</LinearLayout>
Expand All @@ -46,7 +46,7 @@
android:gravity="center_vertical"
android:orientation="horizontal">

<TextView android:id="@id/exo_position"
<TextView android:id="@+id/exo_position"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:textSize="14sp"
Expand All @@ -57,12 +57,12 @@
android:textColor="#FFBEBEBE"/>

<com.google.android.exoplayer2.ui.DefaultTimeBar
android:id="@id/exo_progress"
android:id="@+id/exo_progress"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="26dp"/>

<TextView android:id="@id/exo_duration"
<TextView android:id="@+id/exo_duration"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:textSize="14sp"
Expand All @@ -73,7 +73,7 @@
android:textColor="#FFBEBEBE"/>

<ImageButton
android:id="@id/exo_fullscreen"
android:id="@+id/exo_fullscreen"
style="@style/ExoMediaButton.FullScreen"
android:layout_width="30dp"
android:layout_height="30dp"
Expand Down
Loading

0 comments on commit e516bc4

Please sign in to comment.