Expose currentPlaybackTime when live stream video (#1944)

* added trackId to exoplayer onLoad callback

* added trackInfo to bandwidth callback

* syntax fix

* syntax fix

* version update

* sending complete logcat for media playback exception ExoPlaybackException

* version bump

* package publish changes

* Live playback fix

* Version bump

* import fix

* version bump

* configurable preferredForwardBufferDuration

* configurable preferredForwardBufferDuration

* version update

* Exposing time

* exo player window current tsp

* return type

* Current window timestamp in epoch

* iOS changes

* version update

* Updated package.json

* updated version

* CurrentTime bug fix

* Updated package.json

* Updated currentPlaybackTime

* Updated currentPlayback logic

* Updated package.json

* Bug fix

* Added semicolon

* updated package.json

* Updated ReactVideoView

* updated verison

* Revert package.json changes

* Update ReactVideoView.java

* Use standard log

* Document preferredForwardBufferDuration (iOS)

* Document currentPlaybackTime

* Document trackId

* Update CHANGELOG.md

* Update CHANGELOG.md

* Update README.md

* Update CHANGELOG.md

Co-authored-by: anubansal <anu.bansal@curefit.com>
Co-authored-by: Sivakumar J <sivakumar@curefit.com>
Co-authored-by: parikshit <parikshit@curefit.com>
Co-authored-by: anubansal92 <40559524+anubansal92@users.noreply.github.com>
Co-authored-by: Rishu Agrawal <rishu.agrawal@v.curefit.com>
Co-authored-by: rishu-curefit <54575330+rishu-curefit@users.noreply.github.com>
This commit is contained in:
Param Aggarwal
2020-05-15 12:55:19 +05:30
committed by GitHub
parent e3009c60e1
commit 0b914ef2b9
7 changed files with 73 additions and 14 deletions

View File

@@ -64,6 +64,7 @@ static int const RCTVideoUnset = -1;
NSDictionary * _selectedAudioTrack;
BOOL _playbackStalled;
BOOL _playInBackground;
float _preferredForwardBufferDuration;
BOOL _playWhenInactive;
BOOL _pictureInPicture;
NSString * _ignoreSilentSwitch;
@@ -105,6 +106,7 @@ static int const RCTVideoUnset = -1;
_controls = NO;
_playerBufferEmpty = YES;
_playInBackground = false;
_preferredForwardBufferDuration = 0.0f;
_allowsExternalPlayback = YES;
_playWhenInactive = false;
_pictureInPicture = false;
@@ -265,6 +267,7 @@ static int const RCTVideoUnset = -1;
}
CMTime currentTime = _player.currentTime;
NSDate *currentPlaybackTime = _player.currentItem.currentDate;
const Float64 duration = CMTimeGetSeconds(playerDuration);
const Float64 currentTimeSecs = CMTimeGetSeconds(currentTime);
@@ -276,6 +279,7 @@ static int const RCTVideoUnset = -1;
@"playableDuration": [self calculatePlayableDuration],
@"atValue": [NSNumber numberWithLongLong:currentTime.value],
@"atTimescale": [NSNumber numberWithInt:currentTime.timescale],
@"currentPlaybackTime": [NSNumber numberWithLongLong:[@(floor([currentPlaybackTime timeIntervalSince1970] * 1000)) longLongValue]],
@"target": self.reactTag,
@"seekableDuration": [self calculateSeekableDuration],
});
@@ -354,6 +358,7 @@ static int const RCTVideoUnset = -1;
// perform on next run loop, otherwise other passed react-props may not be set
[self playerItemForSource:source withCallback:^(AVPlayerItem * playerItem) {
_playerItem = playerItem;
[self setPreferredForwardBufferDuration:_preferredForwardBufferDuration];
[self addPlayerItemObservers];
[self setFilter:_filterName];
[self setMaxBitRate:_maxBitRate];
@@ -995,6 +1000,12 @@ static int const RCTVideoUnset = -1;
_playerItem.preferredPeakBitRate = maxBitRate;
}
- (void)setPreferredForwardBufferDuration:(float) preferredForwardBufferDuration
{
_preferredForwardBufferDuration = preferredForwardBufferDuration;
_playerItem.preferredForwardBufferDuration = preferredForwardBufferDuration;
}
- (void)setAutomaticallyWaitsToMinimizeStalling:(BOOL)waits
{
_automaticallyWaitsToMinimizeStalling = waits;

View File

@@ -32,6 +32,7 @@ RCT_EXPORT_VIEW_PROPERTY(muted, BOOL);
RCT_EXPORT_VIEW_PROPERTY(controls, BOOL);
RCT_EXPORT_VIEW_PROPERTY(volume, float);
RCT_EXPORT_VIEW_PROPERTY(playInBackground, BOOL);
RCT_EXPORT_VIEW_PROPERTY(preferredForwardBufferDuration, float);
RCT_EXPORT_VIEW_PROPERTY(playWhenInactive, BOOL);
RCT_EXPORT_VIEW_PROPERTY(pictureInPicture, BOOL);
RCT_EXPORT_VIEW_PROPERTY(ignoreSilentSwitch, NSString);