Compare commits
1 Commits
master
...
kat/incorp
Author | SHA1 | Date | |
---|---|---|---|
134af2dd23 |
@ -22,7 +22,6 @@ enum class EventTypes(val eventName: String) {
|
|||||||
EVENT_BANDWIDTH("onVideoBandwidthUpdate"),
|
EVENT_BANDWIDTH("onVideoBandwidthUpdate"),
|
||||||
EVENT_CONTROLS_VISIBILITY_CHANGE("onControlsVisibilityChange"),
|
EVENT_CONTROLS_VISIBILITY_CHANGE("onControlsVisibilityChange"),
|
||||||
EVENT_SEEK("onVideoSeek"),
|
EVENT_SEEK("onVideoSeek"),
|
||||||
EVENT_SEEK_COMPLETE("onVideoSeekComplete"),
|
|
||||||
EVENT_END("onVideoEnd"),
|
EVENT_END("onVideoEnd"),
|
||||||
EVENT_FULLSCREEN_WILL_PRESENT("onVideoFullscreenPlayerWillPresent"),
|
EVENT_FULLSCREEN_WILL_PRESENT("onVideoFullscreenPlayerWillPresent"),
|
||||||
EVENT_FULLSCREEN_DID_PRESENT("onVideoFullscreenPlayerDidPresent"),
|
EVENT_FULLSCREEN_DID_PRESENT("onVideoFullscreenPlayerDidPresent"),
|
||||||
@ -72,7 +71,6 @@ class VideoEventEmitter {
|
|||||||
lateinit var onVideoBandwidthUpdate: (bitRateEstimate: Long, height: Int, width: Int, trackId: String) -> Unit
|
lateinit var onVideoBandwidthUpdate: (bitRateEstimate: Long, height: Int, width: Int, trackId: String) -> Unit
|
||||||
lateinit var onVideoPlaybackStateChanged: (isPlaying: Boolean, isSeeking: Boolean) -> Unit
|
lateinit var onVideoPlaybackStateChanged: (isPlaying: Boolean, isSeeking: Boolean) -> Unit
|
||||||
lateinit var onVideoSeek: (currentPosition: Long, seekTime: Long) -> Unit
|
lateinit var onVideoSeek: (currentPosition: Long, seekTime: Long) -> Unit
|
||||||
lateinit var onVideoSeekComplete: (currentPosition: Long) -> Unit
|
|
||||||
lateinit var onVideoEnd: () -> Unit
|
lateinit var onVideoEnd: () -> Unit
|
||||||
lateinit var onVideoFullscreenPlayerWillPresent: () -> Unit
|
lateinit var onVideoFullscreenPlayerWillPresent: () -> Unit
|
||||||
lateinit var onVideoFullscreenPlayerDidPresent: () -> Unit
|
lateinit var onVideoFullscreenPlayerDidPresent: () -> Unit
|
||||||
@ -172,11 +170,6 @@ class VideoEventEmitter {
|
|||||||
putDouble("seekTime", seekTime / 1000.0)
|
putDouble("seekTime", seekTime / 1000.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onVideoSeekComplete = { currentPosition ->
|
|
||||||
event.dispatch(EventTypes.EVENT_SEEK_COMPLETE) {
|
|
||||||
putDouble("currentTime", currentPosition / 1000.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onVideoEnd = {
|
onVideoEnd = {
|
||||||
event.dispatch(EventTypes.EVENT_END)
|
event.dispatch(EventTypes.EVENT_END)
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ import android.os.IBinder;
|
|||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.accessibility.CaptioningManager;
|
import android.view.accessibility.CaptioningManager;
|
||||||
@ -229,7 +228,6 @@ public class ReactExoplayerView extends FrameLayout implements
|
|||||||
*/
|
*/
|
||||||
private boolean isSeeking = false;
|
private boolean isSeeking = false;
|
||||||
private long seekPosition = -1;
|
private long seekPosition = -1;
|
||||||
private boolean isSeekInProgress = false;
|
|
||||||
|
|
||||||
// Props from React
|
// Props from React
|
||||||
private Source source = new Source();
|
private Source source = new Source();
|
||||||
@ -305,16 +303,6 @@ public class ReactExoplayerView extends FrameLayout implements
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private void handleSeekCompletion() {
|
|
||||||
if (player != null && player.getPlaybackState() == Player.STATE_READY && isSeekInProgress) {
|
|
||||||
Log.d("ReactExoplayerView", "handleSeekCompletion: currentPosition=" + player.getCurrentPosition());
|
|
||||||
eventEmitter.onVideoSeekComplete.invoke(player.getCurrentPosition());
|
|
||||||
isSeeking = false;
|
|
||||||
seekPosition = -1;
|
|
||||||
isSeekInProgress = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getPositionInFirstPeriodMsForCurrentWindow(long currentPosition) {
|
public double getPositionInFirstPeriodMsForCurrentWindow(long currentPosition) {
|
||||||
Timeline.Window window = new Timeline.Window();
|
Timeline.Window window = new Timeline.Window();
|
||||||
if(!player.getCurrentTimeline().isEmpty()) {
|
if(!player.getCurrentTimeline().isEmpty()) {
|
||||||
@ -773,8 +761,7 @@ public class ReactExoplayerView extends FrameLayout implements
|
|||||||
.setBandwidthMeter(bandwidthMeter)
|
.setBandwidthMeter(bandwidthMeter)
|
||||||
.setLoadControl(loadControl)
|
.setLoadControl(loadControl)
|
||||||
.setMediaSourceFactory(mediaSourceFactory)
|
.setMediaSourceFactory(mediaSourceFactory)
|
||||||
.build();
|
.build();
|
||||||
player.addListener(self);
|
|
||||||
ReactNativeVideoManager.Companion.getInstance().onInstanceCreated(instanceId, player);
|
ReactNativeVideoManager.Companion.getInstance().onInstanceCreated(instanceId, player);
|
||||||
refreshDebugState();
|
refreshDebugState();
|
||||||
player.addListener(self);
|
player.addListener(self);
|
||||||
@ -1351,7 +1338,6 @@ public class ReactExoplayerView extends FrameLayout implements
|
|||||||
if (events.contains(Player.EVENT_PLAYBACK_STATE_CHANGED) || events.contains(Player.EVENT_PLAY_WHEN_READY_CHANGED)) {
|
if (events.contains(Player.EVENT_PLAYBACK_STATE_CHANGED) || events.contains(Player.EVENT_PLAY_WHEN_READY_CHANGED)) {
|
||||||
int playbackState = player.getPlaybackState();
|
int playbackState = player.getPlaybackState();
|
||||||
boolean playWhenReady = player.getPlayWhenReady();
|
boolean playWhenReady = player.getPlayWhenReady();
|
||||||
Log.d("ReactExoplayerView", "onEvents: playbackState=" + playbackState + ", playWhenReady=" + playWhenReady);
|
|
||||||
String text = "onStateChanged: playWhenReady=" + playWhenReady + ", playbackState=";
|
String text = "onStateChanged: playWhenReady=" + playWhenReady + ", playbackState=";
|
||||||
eventEmitter.onPlaybackRateChange.invoke(playWhenReady && playbackState == ExoPlayer.STATE_READY ? 1.0f : 0.0f);
|
eventEmitter.onPlaybackRateChange.invoke(playWhenReady && playbackState == ExoPlayer.STATE_READY ? 1.0f : 0.0f);
|
||||||
switch (playbackState) {
|
switch (playbackState) {
|
||||||
@ -1385,10 +1371,6 @@ public class ReactExoplayerView extends FrameLayout implements
|
|||||||
playerControlView.show();
|
playerControlView.show();
|
||||||
}
|
}
|
||||||
setKeepScreenOn(preventsDisplaySleepDuringVideoPlayback);
|
setKeepScreenOn(preventsDisplaySleepDuringVideoPlayback);
|
||||||
Log.d("ReactExoplayerView", "Player STATE_READY: currentPosition=" + player.getCurrentPosition());
|
|
||||||
if (isSeekInProgress) {
|
|
||||||
handleSeekCompletion();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case Player.STATE_ENDED:
|
case Player.STATE_ENDED:
|
||||||
text += "ended";
|
text += "ended";
|
||||||
@ -1652,7 +1634,6 @@ public class ReactExoplayerView extends FrameLayout implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPositionDiscontinuity(@NonNull Player.PositionInfo oldPosition, @NonNull Player.PositionInfo newPosition, @Player.DiscontinuityReason int reason) {
|
public void onPositionDiscontinuity(@NonNull Player.PositionInfo oldPosition, @NonNull Player.PositionInfo newPosition, @Player.DiscontinuityReason int reason) {
|
||||||
Log.d("ReactExoplayerView", "onPositionDiscontinuity: reason=" + reason + ", oldPosition=" + oldPosition.positionMs + ", newPosition=" + newPosition.positionMs);
|
|
||||||
if (reason == Player.DISCONTINUITY_REASON_SEEK) {
|
if (reason == Player.DISCONTINUITY_REASON_SEEK) {
|
||||||
isSeeking = true;
|
isSeeking = true;
|
||||||
seekPosition = newPosition.positionMs;
|
seekPosition = newPosition.positionMs;
|
||||||
@ -2156,10 +2137,6 @@ public class ReactExoplayerView extends FrameLayout implements
|
|||||||
|
|
||||||
public void seekTo(long positionMs) {
|
public void seekTo(long positionMs) {
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
Log.d("ReactExoplayerView", "seekTo: positionMs=" + positionMs);
|
|
||||||
isSeekInProgress = true;
|
|
||||||
isSeeking = true;
|
|
||||||
seekPosition = positionMs;
|
|
||||||
player.seekTo(positionMs);
|
player.seekTo(positionMs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,11 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
|||||||
@objc var onVideoProgress: RCTDirectEventBlock?
|
@objc var onVideoProgress: RCTDirectEventBlock?
|
||||||
@objc var onVideoBandwidthUpdate: RCTDirectEventBlock?
|
@objc var onVideoBandwidthUpdate: RCTDirectEventBlock?
|
||||||
@objc var onVideoSeek: RCTDirectEventBlock?
|
@objc var onVideoSeek: RCTDirectEventBlock?
|
||||||
@objc var onVideoSeekComplete: RCTDirectEventBlock?
|
@objc var onVideoSeekComplete: RCTDirectEventBlock? {
|
||||||
|
didSet {
|
||||||
|
print("onVideoSeekComplete set: \(onVideoSeekComplete != nil)")
|
||||||
|
}
|
||||||
|
}
|
||||||
@objc var onVideoEnd: RCTDirectEventBlock?
|
@objc var onVideoEnd: RCTDirectEventBlock?
|
||||||
@objc var onTimedMetadata: RCTDirectEventBlock?
|
@objc var onTimedMetadata: RCTDirectEventBlock?
|
||||||
@objc var onVideoAudioBecomingNoisy: RCTDirectEventBlock?
|
@objc var onVideoAudioBecomingNoisy: RCTDirectEventBlock?
|
||||||
@ -777,6 +781,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
|||||||
let toleranceTime = CMTimeMakeWithSeconds(Float64(tolerance.floatValue), preferredTimescale: Int32(NSEC_PER_SEC))
|
let toleranceTime = CMTimeMakeWithSeconds(Float64(tolerance.floatValue), preferredTimescale: Int32(NSEC_PER_SEC))
|
||||||
|
|
||||||
let currentTimeBeforeSeek = CMTimeGetSeconds(item.currentTime())
|
let currentTimeBeforeSeek = CMTimeGetSeconds(item.currentTime())
|
||||||
|
print("Before seek - Current time: \(currentTimeBeforeSeek), Seeking to: \(time)")
|
||||||
|
|
||||||
// Call onVideoSeek before starting the seek operation
|
// Call onVideoSeek before starting the seek operation
|
||||||
let currentTime = NSNumber(value: Float(currentTimeBeforeSeek))
|
let currentTime = NSNumber(value: Float(currentTimeBeforeSeek))
|
||||||
@ -1676,4 +1681,3 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
|||||||
@objc
|
@objc
|
||||||
func setOnClick(_: Any) {}
|
func setOnClick(_: Any) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user