@@ -73,6 +73,7 @@ public class ReactTVExoplayerViewManager extends ViewGroupManager<ReactTVExoplay
7373 private static final String PROP_SRC_APS_TEST_MODE = "testMode" ;
7474 private static final String PROP_SRC_METADATA = "metadata" ;
7575 private static final String PROP_SRC_LIMIT_RANGE = "limitedSeekableRange" ;
76+ private static final String PROP_SRC_RESUME_POSITION = "resumePosition" ;
7677 private static final String PROP_SRC_SAVE_SUBTITLE_SELECTION = "shouldSaveSubtitleSelection" ;
7778 private static final String PROP_SRC_NOW_PLAYING = "nowPlaying" ;
7879 private static final String PROP_SRC_BIF_URL = "thumbnailsPreview" ;
@@ -260,6 +261,13 @@ public void setSrc(final ReactTVExoplayerView videoView, @Nullable ReadableMap s
260261 boolean apsTestMode = (aps != null && aps .hasKey (PROP_SRC_APS_TEST_MODE )) && aps .getBoolean (PROP_SRC_APS_TEST_MODE );
261262
262263 LimitedSeekRange limitedSeekRange = generateRange (src .hasKey (PROP_SRC_LIMIT_RANGE ) ? src .getMap (PROP_SRC_LIMIT_RANGE ) : null );
264+ long resumePosition = ResumePositionHandler .RESUME_UNSET ;
265+ if (src .hasKey (PROP_SRC_RESUME_POSITION ) && !src .isNull (PROP_SRC_RESUME_POSITION )) {
266+ long rawPosition = Math .round (src .getDouble (PROP_SRC_RESUME_POSITION ));
267+ if (rawPosition > 0 ) {
268+ resumePosition = (videoView .isLive () ? rawPosition : rawPosition * 1000 );
269+ }
270+ }
263271 boolean shouldSaveSubtitleSelection = src .hasKey (PROP_SRC_SAVE_SUBTITLE_SELECTION ) && src .getBoolean (PROP_SRC_SAVE_SUBTITLE_SELECTION );
264272
265273 if (src .hasKey (PROP_SRC_NOW_PLAYING )) {
@@ -322,10 +330,11 @@ public void setSrc(final ReactTVExoplayerView videoView, @Nullable ReadableMap s
322330 ImaCsaiProperties imaCsai = (ImaCsaiProperties ) adProperties [0 ];
323331 TracksPolicy tracksPolicy = ReactTVPropsParser .parseTracksPolicy (ReadableMapUtils .getMap (src , "tracksPolicy" ));
324332
325- Log .i (WebUtil .DEBUG , String .format ("setSrc - id %s, title %s, mimeType %s, isYoSsai %b, isAmtSsai %b, " +
333+ Log .i (WebUtil .DEBUG , String .format ("setSrc - id %s, title %s, resumePosition %d, mimeType %s, isYoSsai %b, isAmtSsai %b, " +
326334 "isImaDai %b, adTag %s, midRoll %s, license %s, url %s" ,
327335 id ,
328336 channelName == null && muxData != null && muxData .hasKey ("videoTitle" ) ? muxData .getString ("videoTitle" ) : channelName ,
337+ resumePosition ,
329338 mimeType ,
330339 adProperties [1 ] != null ,
331340 adProperties [2 ] != null ,
@@ -360,6 +369,7 @@ public void setSrc(final ReactTVExoplayerView videoView, @Nullable ReadableMap s
360369 apsTestMode ,
361370 Watermark .fromMap (metadata ),
362371 limitedSeekRange ,
372+ resumePosition ,
363373 shouldSaveSubtitleSelection ,
364374 selectedSubtitleTrack ,
365375 preferredAudioTracks ,
@@ -687,42 +697,17 @@ public static Map<String, String> toStringMap(@Nullable ReadableMap readableMap)
687697 @ Override
688698 public Map <String , Integer > getCommandsMap () {
689699 return MapBuilder .of (
690- "seekToNow" ,
691- COMMAND_SEEK_TO_NOW ,
692- "seekToTimestamp" ,
693- COMMAND_SEEK_TO_TIMESTAMP ,
694- "seekToResumePosition" ,
695- COMMAND_SEEK_TO_RESUME_POSITION ,
696700 "seekToPosition" ,
697701 COMMAND_SEEK_TO_POSITION ,
698702 "replaceAdTagParameters" ,
699- COMMAND_REPLACE_AD_TAG_PARAMETERS ,
700- "limitSeekableRange" ,
701- COMMAND_LIMIT_SEEKABLE_RANGE
703+ COMMAND_REPLACE_AD_TAG_PARAMETERS
702704 );
703705 }
704706
705707 @ Override
706708 public void receiveCommand (final ReactTVExoplayerView root , int commandId , @ Nullable ReadableArray args ) {
707709 // This will be called whenever a command is sent from react-native.
708710 switch (commandId ) {
709- case COMMAND_SEEK_TO_NOW :
710- Log .i (WebUtil .DEBUG , "resumeToNow" );
711- root .resumeTo (C .TIME_UNSET );
712- break ;
713- case COMMAND_SEEK_TO_TIMESTAMP :
714- String timestamp = args .getString (0 );
715- Log .i (WebUtil .DEBUG , "resumeToTimeStamp " + timestamp );
716- long positionMs = root .parseTimestamp (timestamp );
717- if (positionMs != ResumePositionHandler .RESUME_UNSET ) {
718- root .resumeTo (positionMs );
719- }
720- break ;
721- case COMMAND_SEEK_TO_RESUME_POSITION :
722- long resumeMs = args .getInt (0 ) * 1000 ;
723- Log .i (WebUtil .DEBUG , "resumeToPosition " + resumeMs );
724- root .resumeTo (resumeMs );
725- break ;
726711 case COMMAND_SEEK_TO_POSITION :
727712 long seekToMs = args .getInt (0 ) * 1000 ;
728713 Log .i (WebUtil .DEBUG , "seekToPosition " + seekToMs );
@@ -731,9 +716,6 @@ public void receiveCommand(final ReactTVExoplayerView root, int commandId, @Null
731716 case COMMAND_REPLACE_AD_TAG_PARAMETERS :
732717 root .replaceAdTagParameters (args .getMap (0 ) != null ? args .getMap (0 ).toHashMap () : null );
733718 break ;
734- case COMMAND_LIMIT_SEEKABLE_RANGE :
735- root .setLimitedSeekRange (generateRange (args .getMap (0 )));
736- break ;
737719 }
738720 }
739721
0 commit comments