Skip to content

Commit

Permalink
Merge pull request #3179 from vemarav/shuttercolor
Browse files Browse the repository at this point in the history
Android: fixes black splashes
  • Loading branch information
freeboub authored Aug 3, 2023
2 parents 6c4e90e + 24b5975 commit 90fe971
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 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
1 change: 1 addition & 0 deletions Video.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,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
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 @@ -2039,6 +2039,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

0 comments on commit 90fe971

Please sign in to comment.