Skip to content

Commit 85af314

Browse files
Fix/play pause event and seek ended event (#468)
* fix: add onPlayPauseActionEvent and onDorisSeekEndedEvent * fix: bump rndv * chore: bump doris-android version * chore: bump rndv to fix the seek action type * chore: add android-tv seek play pause track event * chore: revert skip marker track * chore: bump doris * chore: seekStartAt seekEndAt value changed to second * chore: bump doris-android to 5.2.23 --------- Co-authored-by: wei.liu <[email protected]>
1 parent 0c7bef9 commit 85af314

File tree

7 files changed

+92
-9
lines changed

7 files changed

+92
-9
lines changed

Video.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ export default class Video extends React.PureComponent<IVideoPlayer, IState> {
7575
this.props.onSeek?.(event.nativeEvent);
7676
};
7777

78+
onSeekEndedEvent = (event) => {
79+
this.props.onSeekEndedEvent?.(event.nativeEvent);
80+
};
81+
7882
onEnd = (event) => {
7983
this.props.onEnd?.(event.nativeEvent);
8084
};
@@ -130,6 +134,10 @@ export default class Video extends React.PureComponent<IVideoPlayer, IState> {
130134
this.props.onSkipMarkerButton?.(event.nativeEvent);
131135
};
132136

137+
onPlayPauseAction = (event) => {
138+
this.props.onPlayPauseAction?.(event.nativeEvent);
139+
}
140+
133141
replaceAdTagParameters = (payload: IVideoReplaceAdTagParametersPayload) => {
134142
let command = 'replaceAdTagParameters';
135143

@@ -189,6 +197,7 @@ export default class Video extends React.PureComponent<IVideoPlayer, IState> {
189197
onVideoError: this.onError,
190198
onVideoProgress: this.onProgress,
191199
onVideoSeek: this.onSeek,
200+
onSeekEndedEvent: this.onSeekEndedEvent,
192201
onVideoEnd: this.onEnd,
193202
onVideoBuffer: this.onBuffer,
194203
onTimedMetadata: this.onTimedMetadata,
@@ -204,6 +213,7 @@ export default class Video extends React.PureComponent<IVideoPlayer, IState> {
204213
onReloadCurrentSource: this.onReloadCurrentSource,
205214
onBehindLiveWindowError: this.onBehindLiveWindowError,
206215
onSkipMarkerButton: this.onSkipMarkerButton,
216+
onPlayPauseAction: this.onPlayPauseAction,
207217
};
208218
};
209219

android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactTVExoplayerView.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1919,7 +1919,7 @@ public void onWatchlistButtonClicked() {
19191919
}
19201920

19211921
@Override
1922-
public void onSkipMarkerClicked(SkipMarker skipMarker) {
1922+
public void onSkipMarkerClicked(long currentPosition, SkipMarker skipMarker) {
19231923
eventEmitter.skipMarkerClick(skipMarker);
19241924
}
19251925

@@ -1933,6 +1933,31 @@ public void onStatsButtonClicked() {
19331933
eventEmitter.statsIconClick();
19341934
}
19351935

1936+
@Override
1937+
public void onVideoPlayPauseButtonClick(boolean playing) {
1938+
eventEmitter.playPauseButtonClick(playing);
1939+
}
1940+
1941+
@Override
1942+
public void onAdPlayPauseButtonClick(boolean playing) {
1943+
eventEmitter.playPauseButtonClick(playing);
1944+
}
1945+
1946+
@Override
1947+
public void onGoToLiveButtonClick(long seekStartAt, long seekEndAt) {
1948+
eventEmitter.goToLiveSeek(seekStartAt, seekEndAt);
1949+
}
1950+
1951+
@Override
1952+
public void onForwardRewindButtonClick(long seekStartAt, long seekEndAt) {
1953+
eventEmitter.forwardRewindSeek(seekStartAt, seekEndAt);
1954+
}
1955+
1956+
@Override
1957+
public void onContinuousSeekClick(long seekStartAt, long seekEndAt) {
1958+
eventEmitter.continuousSeek(seekStartAt, seekEndAt);
1959+
}
1960+
19361961
@Override
19371962
public void onSubtitleSelected(String language) {
19381963
TrackPreferenceStorage storage = TrackPreferenceStorage.getInstance(getContext());

android-exoplayer/src/main/java/com/brentvatne/exoplayer/VideoEventEmitter.java

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ class VideoEventEmitter {
6565
private static final String EVENT_SUBTITLE_TRACK_CHANGED = "onSubtitleTrackChanged";
6666
private static final String EVENT_AUDIO_TRACK_CHANGED = "onAudioTrackChanged";
6767
private static final String EVENT_SKIP_MARKER = "onSkipMarkerButton";
68+
private static final String EVENT_SEEK_ENDED = "onSeekEndedEvent";
69+
private static final String EVENT_PLAY_PAUSE_ACTION = "onPlayPauseAction";
6870

6971
static final String[] Events = {
7072
EVENT_LOAD_START,
@@ -103,7 +105,9 @@ class VideoEventEmitter {
103105
EVENT_REQUIRE_AD_PARAMETERS,
104106
EVENT_RELOAD_CURRENT_SOURCE,
105107
EVENT_BEHIND_LIVE_WINDOW_ERROR,
106-
EVENT_SKIP_MARKER
108+
EVENT_SKIP_MARKER,
109+
EVENT_SEEK_ENDED,
110+
EVENT_PLAY_PAUSE_ACTION
107111
};
108112

109113
@Retention(RetentionPolicy.SOURCE)
@@ -144,7 +148,9 @@ class VideoEventEmitter {
144148
EVENT_REQUIRE_AD_PARAMETERS,
145149
EVENT_RELOAD_CURRENT_SOURCE,
146150
EVENT_BEHIND_LIVE_WINDOW_ERROR,
147-
EVENT_SKIP_MARKER
151+
EVENT_SKIP_MARKER,
152+
EVENT_SEEK_ENDED,
153+
EVENT_PLAY_PAUSE_ACTION
148154
})
149155
@interface VideoEvents {
150156
}
@@ -165,6 +171,10 @@ class VideoEventEmitter {
165171
private static final String EVENT_PROP_CURRENT_DATE = "currentDate";
166172
private static final String EVENT_PROP_CURRENT_TIME = "currentTime";
167173

174+
private static final String EVENT_PROP_IS_PAUSE = "isPaused";
175+
private static final String EVENT_PROP_SEEK_TYPE = "seekType";
176+
private static final String EVENT_PROP_SEEK_START_TIME = "seekStartAt";
177+
private static final String EVENT_PROP_SEEK_END_TIME = "seekEndAt";
168178
private static final String EVENT_PROP_SEEK_TIME = "seekTime";
169179
private static final String EVENT_PROP_NATURAL_SIZE = "naturalSize";
170180
private static final String EVENT_PROP_WIDTH = "width";
@@ -189,6 +199,9 @@ class VideoEventEmitter {
189199
private static final String EVENT_PROP_ERROR_EXCEPTION = "errorException";
190200

191201
private static final String EVENT_PROP_TIMED_METADATA = "metadata";
202+
private static final String EVENT_PROP_SEEK_GO_TO_LIVE = "liveBadge";
203+
private static final String EVENT_PROP_SEEK_SKIP = "skip";
204+
private static final String EVENT_PROP_SEEK = "seek";
192205

193206
void setViewId(int viewId) {
194207
this.viewId = viewId;
@@ -250,6 +263,32 @@ void seek(long currentPosition, long seekTime) {
250263
receiveEvent(EVENT_SEEK, event);
251264
}
252265

266+
void goToLiveSeek(long seekStartAt, long seekEndAt) {
267+
onSeek(EVENT_PROP_SEEK_GO_TO_LIVE, seekStartAt, seekEndAt);
268+
}
269+
270+
void forwardRewindSeek(long seekStartAt, long seekEndAt) {
271+
onSeek(EVENT_PROP_SEEK_SKIP, seekStartAt, seekEndAt);
272+
}
273+
274+
void continuousSeek(long seekStartAt, long seekEndAt) {
275+
onSeek(EVENT_PROP_SEEK, seekStartAt, seekEndAt);
276+
}
277+
278+
private void onSeek(String seekType, long seekStartAt, long seekEndAt) {
279+
WritableMap event = Arguments.createMap();
280+
event.putString(EVENT_PROP_SEEK_TYPE, seekType);
281+
event.putDouble(EVENT_PROP_SEEK_START_TIME, seekStartAt / 1000D);
282+
event.putDouble(EVENT_PROP_SEEK_END_TIME, seekEndAt / 1000D);
283+
receiveEvent(EVENT_SEEK_ENDED, event);
284+
}
285+
286+
void playPauseButtonClick(boolean isPlaying) {
287+
WritableMap event = Arguments.createMap();
288+
event.putBoolean(EVENT_PROP_IS_PAUSE, !isPlaying);
289+
receiveEvent(EVENT_PLAY_PAUSE_ACTION, event);
290+
}
291+
253292
void ready() {
254293
receiveEvent(EVENT_READY, null);
255294
}

ios/Video/NewPlayerView.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ class NewPlayerView: UIView, JSInputProtocol {
3434
@objc var onWatchlistButtonClick: RCTBubblingEventBlock?
3535
@objc var onSkipMarkerButton: RCTBubblingEventBlock?
3636
@objc var onVideoSeek: RCTBubblingEventBlock?
37-
37+
@objc var onSeekEndedEvent: RCTBubblingEventBlock?
38+
@objc var onPlayPauseAction: RCTBubblingEventBlock?
39+
3840
//not used
3941
@objc var onVideoLoadStart: RCTBubblingEventBlock?
4042
@objc var onTimedMetadata: RCTBubblingEventBlock?
@@ -223,6 +225,8 @@ class NewPlayerView: UIView, JSInputProtocol {
223225
jsPlayerView.onWatchlistButtonClick = self.onWatchlistButtonClick
224226
jsPlayerView.onSkipMarkerButton = self.onSkipMarkerButton
225227
jsPlayerView.onSeekEvent = self.onVideoSeek
228+
jsPlayerView.onSeekEndedEvent = self.onSeekEndedEvent
229+
jsPlayerView.onPlayPauseAction = self.onPlayPauseAction
226230
jsPlayerView.onVideoBuffer = self.onVideoBuffer
227231
jsPlayerView.onVideoAboutToEnd = self.onVideoAboutToEnd
228232

ios/Video/RCTVideoManager.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ @interface RCT_EXTERN_MODULE(RCTVideoManager, RCTViewManager)
4242
RCT_EXPORT_VIEW_PROPERTY(onVideoError, RCTBubblingEventBlock);
4343
RCT_EXPORT_VIEW_PROPERTY(onVideoProgress, RCTBubblingEventBlock);
4444
RCT_EXPORT_VIEW_PROPERTY(onVideoSeek, RCTBubblingEventBlock);
45+
RCT_EXPORT_VIEW_PROPERTY(onSeekEndedEvent, RCTBubblingEventBlock);
4546
RCT_EXPORT_VIEW_PROPERTY(onVideoEnd, RCTBubblingEventBlock);
4647
RCT_EXPORT_VIEW_PROPERTY(onTimedMetadata, RCTBubblingEventBlock);
4748
RCT_EXPORT_VIEW_PROPERTY(onVideoAudioBecomingNoisy, RCTBubblingEventBlock);
@@ -65,6 +66,8 @@ @interface RCT_EXTERN_MODULE(RCTVideoManager, RCTViewManager)
6566
RCT_EXPORT_VIEW_PROPERTY(onSubtitleTrackChanged, RCTBubblingEventBlock);
6667
RCT_EXPORT_VIEW_PROPERTY(onAudioTrackChanged, RCTBubblingEventBlock)
6768
RCT_EXPORT_VIEW_PROPERTY(onSkipMarkerButton, RCTBubblingEventBlock);
69+
RCT_EXPORT_VIEW_PROPERTY(onPlayPauseAction, RCTBubblingEventBlock);
70+
6871

6972
RCT_EXTERN_METHOD(seekToPosition:(nonnull NSNumber *)node position:(double)position)
7073
RCT_EXTERN_METHOD(replaceAdTagParameters:(nonnull NSNumber *)node payload:(NSDictionary)payload)

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-native-video",
3-
"version": "7.12.18",
4-
"dorisAndroidVersion": "5.2.20",
3+
"version": "7.12.19",
4+
"dorisAndroidVersion": "5.2.23",
55
"messagingAndroidVersion": "1.1.0",
66
"description": "A <Video /> element for react-native",
77
"main": "Video.tsx",
@@ -21,7 +21,7 @@
2121
"eslint-plugin-react": "3.16.1"
2222
},
2323
"dependencies": {
24-
"@dicetechnology/react-native-dice-video": "git+ssh://[email protected]/DiceTechnology/react-native-dice-video.git#7.4.14",
24+
"@dicetechnology/react-native-dice-video": "git+ssh://[email protected]/DiceTechnology/react-native-dice-video.git#7.4.20",
2525
"@dicetechnology/dice-unity": "^2.26.3",
2626
"keymirror": "0.1.1",
2727
"prop-types": "^15.5.10"

types/callbacks.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ export interface IVideoPlayerCallbacks {
1818
onRelatedVideosIconClicked?: (e: any) => void;
1919
onRequireAdParameters?: (e: IVideoPlayerOnRequireAdParametersPayload) => void;
2020
onSeek?: (e: any) => void;
21+
onSeekEndedEvent?: (e: any) => void;
2122
onStatsIconClick?: () => void;
2223
onTimedMetadata?: (e: any) => void;
2324
onVideoAboutToEnd?: (e: any) => void;
2425
onWatchlistButtonClick?: (e: any) => void;
2526
onReloadCurrentSource?: (e: any) => void;
2627
onBehindLiveWindowError?: (e: any) => void;
27-
onAudioTrackChanged?: ({ language } : { language: string }) => void;
28-
onSubtitleTrackChanged?: ({ language } : { language: string }) => void;
28+
onAudioTrackChanged?: ({ language }: { language: string }) => void;
29+
onSubtitleTrackChanged?: ({ language }: { language: string }) => void;
2930
onSkipMarkerButton?: (e: any) => void;
31+
onPlayPauseAction?: (e: any) => void;
3032
}

0 commit comments

Comments
 (0)