-
Notifications
You must be signed in to change notification settings - Fork 23
update: allow starting new views with videoChange without changing AVPlayerItem
#258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 4 commits
1bc83ba
1f018c2
e4cff6d
3dcddb6
2bfe000
09a3432
2d4d79d
24a886a
f5b4d9f
c1a2e49
d7e215c
ee5d0bc
f111186
84de900
06f4de9
1b9c7e7
156022a
b194602
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -403,36 +403,48 @@ - (void)detachAVPlayer { | |
| } | ||
| } | ||
|
|
||
| - (void)dispatchVideoChange { | ||
| // end the current view if it's not already been ended | ||
| if (_state != MUXSDKPlayerStateViewEnd) { | ||
| [self dispatchViewEnd]; | ||
| } | ||
|
|
||
| [self.playDispatchDelegate videoChangedForPlayer:_name]; | ||
| // TODO: test that we have all the metadata we need on the subsequent view. On android we needed to catch up with the current state | ||
|
|
||
| // | ||
| // Special case for AVQueuePlayer | ||
| // In a normal videoChange: world - the KVO for "rate" will fire - and | ||
| // subsequently after that this binding will dispatchPlay. In fact, any time | ||
| // an AVPlayer gets an item loaded into it the KVO for "rate" changes. | ||
| // | ||
| // However, in AVQueuePlayer world - the "rate" doesn't fire when the video is | ||
| // changed. I don't know why, but I guess that is the intended behavior. For that | ||
| // reason, if we're handling a videoChange event and we're dealing with AVQueuePlayer | ||
| // then we have to fire the play event here. | ||
| // | ||
| if (_shouldHandleAVQueuePlayerItem) { | ||
| _shouldHandleAVQueuePlayerItem = false; | ||
| [self dispatchPlay]; | ||
| } | ||
| } | ||
|
|
||
| - (void)monitorAVPlayerItem { | ||
| if ((!_automaticVideoChange && !_didTriggerManualVideoChange) || _isAdPlaying) { | ||
| // The player item could be the the ad itself, and we monitor ads differentlty than main content | ||
| if (_isAdPlaying) { | ||
| return; | ||
| } | ||
|
|
||
| // TODO: IMA has to disable automaticVideoChange and do it manually (for postrolls only) | ||
| if (_state != MUXSDKPlayerStateReady && (_automaticVideoChange || _didTriggerManualVideoChange)) { | ||
| [self dispatchVideoChange]; | ||
| } | ||
|
|
||
| if (_playerItem) { | ||
| if (_didTriggerManualVideoChange) { | ||
| _didTriggerManualVideoChange = false; | ||
| } | ||
| [self dispatchViewEnd]; | ||
| [self stopMonitoringAVPlayerItem]; | ||
|
|
||
| if (_player.currentItem) { | ||
| [self.playDispatchDelegate videoChangedForPlayer:_name]; | ||
| } | ||
|
|
||
| // | ||
| // Special case for AVQueuePlayer | ||
| // In a normal videoChange: world - the KVO for "rate" will fire - and | ||
| // subsequently after that this binding will dispatchPlay. In fact, any time | ||
| // an AVPlayer gets an item loaded into it the KVO for "rate" changes. | ||
| // | ||
| // However, in AVQueuePlayer world - the "rate" doesn't fire when the video is | ||
| // changed. I don't know why, but I guess that is the intended behavior. For that | ||
| // reason, if we're handling a videoChange event and we're dealing with AVQueuePlayer | ||
| // then we have to fire the play event here. | ||
| // | ||
| if (_shouldHandleAVQueuePlayerItem) { | ||
| _shouldHandleAVQueuePlayerItem = false; | ||
| [self dispatchPlay]; | ||
| } | ||
| } | ||
| if (_player && _player.currentItem) { | ||
| _playerItem = _player.currentItem; | ||
|
|
@@ -488,9 +500,11 @@ - (void)stopMonitoringAVPlayerItem { | |
| [self safelyRemovePlayerItemObserverForKeyPath:@"status"]; | ||
| [self safelyRemovePlayerItemObserverForKeyPath:@"playbackBufferEmpty"]; | ||
| _playerItem = nil; | ||
| if (!_isAdPlaying) { | ||
| [MUXSDKCore destroyPlayer: _name]; | ||
| } | ||
| } | ||
|
|
||
| /// Cleans up our Core monitor. Call when we are detaching from an AVPlayer | ||
| - (void)destroyPlayer { | ||
| [MUXSDKCore destroyPlayer: _name]; | ||
| } | ||
|
|
||
| - (void) programChangedForPlayer { | ||
|
|
@@ -775,6 +789,7 @@ - (void)dispatchViewInit { | |
| return; | ||
| } | ||
| [self resetVideoData]; | ||
|
|
||
| MUXSDKPlayerData *playerData = [self getPlayerData]; | ||
| MUXSDKViewInitEvent *event = [[MUXSDKViewInitEvent alloc] init]; | ||
| [event setPlayerData:playerData]; | ||
|
|
@@ -1232,6 +1247,9 @@ - (BOOL) doubleValueIsEqual:(NSNumber *) x toOther:(NSNumber *) n { | |
| } | ||
|
|
||
| - (void)didTriggerManualVideoChange { | ||
| // TODO: Should we deprecate? we no longer need this method. videoChange can happen whenever it's needed now, not just when AVPlayerItem changes | ||
|
||
| // TODO: (continued) on the other hand, it *does* do something specific, since someone could call this method any time before the playeritem changes | ||
| // TODO: (continued again) on the Other other hand, this method is mostly here to support a manual video-change workflow that we want to repalce | ||
| _didTriggerManualVideoChange = true; | ||
| } | ||
| @end | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this refer to external stuff like
MUXSDKCustomerDataor something else?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The customer data, and also more general things like the private stuff in the player binding
I saw some odd stuff with playhead time during the subsequent views after changing, so I think there might still be something to clear. It could be here or in the
player binding(edit: oops, here or in the stores I mean), I'm not really sure