Skip to content

Commit

Permalink
chore: show subtitle button
Browse files Browse the repository at this point in the history
  • Loading branch information
seyedmostafahasani committed Jun 21, 2024
1 parent 9fbca52 commit e9493a1
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2258,4 +2258,9 @@ public void setControlsStyles(ControlsConfig controlsStyles) {
controlsConfig = controlsStyles;
refreshProgressBarVisibility();
}

public void setShowSubtitleButton(Boolean showSubtitleButton) {
if(exoPlayerView == null) return;
exoPlayerView.setShowSubtitleButton(showSubtitleButton);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
private static final String PROP_SHOW_NOTIFICATION_CONTROLS = "showNotificationControls";
private static final String PROP_DEBUG = "debug";
private static final String PROP_CONTROLS_STYLES = "controlsStyles";
private static final String PROP_SHOW_SUBTITLE_BUTTON = "showSubtitleButton";


private final ReactExoplayerConfig config;
Expand Down Expand Up @@ -358,4 +359,9 @@ public void setControlsStyles(final ReactExoplayerView videoView, @Nullable Read
ControlsConfig controlsConfig = ControlsConfig.parse(controlsStyles);
videoView.setControlsStyles(controlsConfig);
}

@ReactProp(name = PROP_SHOW_SUBTITLE_BUTTON)
public void setShowSubtitle(final ReactExoplayerView videoView, @Nullable Boolean showSubtitleButton) {
videoView.setShowSubtitleButton(showSubtitleButton);
}
}
11 changes: 10 additions & 1 deletion docs/pages/component/props.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,15 @@ source={{
}}
```

### `showSubtitleButton`
<PlatformsList types={['Android']} />

Display the subtitle button. The default setting is `true`.

```javascript
showSubtitleButton={true}
```

### `subtitleStyle`

| Property | Description | Platforms |
Expand Down Expand Up @@ -926,4 +935,4 @@ Adjust the volume.

- **1.0 (default)** - Play at full volume
- **0.0** - Mute the audio
- **Other values** - Reduce volume
- **Other values** - Reduce volume
4 changes: 4 additions & 0 deletions src/Video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
selectedVideoTrack,
selectedAudioTrack,
selectedTextTrack,
showSubtitleButton,
onLoadStart,
onLoad,
onError,
Expand Down Expand Up @@ -557,6 +558,9 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
selectedAudioTrack={_selectedAudioTrack}
selectedVideoTrack={_selectedVideoTrack}
onGetLicense={useExternalGetLicense ? onGetLicense : undefined}
showSubtitleButton={
showSubtitleButton === undefined ? true : showSubtitleButton
}
onVideoLoad={
onLoad || hasPoster
? (onVideoLoad as (e: NativeSyntheticEvent<object>) => void)
Expand Down
1 change: 1 addition & 0 deletions src/specs/VideoNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ export interface VideoNativeProps extends ViewProps {
useSecureView?: boolean; // Android
bufferingStrategy?: BufferingStrategyType; // Android
controlsStyles?: ControlsStyles; // Android
showSubtitleButton?: boolean;
onVideoLoad?: DirectEventHandler<OnLoadData>;
onVideoLoadStart?: DirectEventHandler<OnLoadStartData>;
onVideoAspectRatio?: DirectEventHandler<OnVideoAspectRatioData>;
Expand Down
1 change: 1 addition & 0 deletions src/types/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,5 @@ export interface ReactVideoProps extends ReactVideoEvents, ViewProps {
debug?: DebugConfig;
allowsExternalPlayback?: boolean; // iOS
controlsStyles?: ControlsStyles; // Android
showSubtitleButton?: boolean;
}

0 comments on commit e9493a1

Please sign in to comment.