Skip to content

Commit

Permalink
fix(ios): fix default value of property pictureInPictureEnabled (#12239)
Browse files Browse the repository at this point in the history
Fixes TIMOB-28221
  • Loading branch information
vijaysingh-axway committed Nov 3, 2020
1 parent cb5a970 commit ba7e5aa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion apidoc/Titanium/Media/VideoPlayer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ properties:
summary: The type of media in the player's current item first track.
exclude-platforms: [android]
type: String
permission: read-only
default: <Titanium.Media.VIDEO_MEDIA_TYPE_VIDEO>
constants: Titanium.Media.VIDEO_MEDIA_TYPE_*

Expand Down Expand Up @@ -625,7 +626,7 @@ properties:
summary: Whether or not the receiver allows Picture in Picture playback.
platforms: [iphone, ipad, macos]
type: Boolean
default: false
default: true
osver: {ios: {min: "9.0"}}

- name: playableDuration
Expand Down
12 changes: 10 additions & 2 deletions iphone/Classes/TiMediaVideoPlayerProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -446,12 +446,20 @@ - (void)requestThumbnailImagesAtTimes:(id)args

- (NSNumber *)pictureInPictureEnabled
{
return @([movie allowsPictureInPicturePlayback]);
if (movie) {
return @(movie.allowsPictureInPicturePlayback);
} else {
RETURN_FROM_LOAD_PROPERTIES(@"pictureInPictureEnabled", @YES);
}
}

- (void)setPictureInPictureEnabled:(NSNumber *)value
{
[movie setAllowsPictureInPicturePlayback:[TiUtils boolValue:value]];
if (movie) {
movie.allowsPictureInPicturePlayback = [TiUtils boolValue:value def:YES];
} else {
[loadProperties setValue:value forKey:@"pictureInPictureEnabled"];
}
}

- (NSNumber *)showsControls
Expand Down
4 changes: 2 additions & 2 deletions tests/Resources/ti.media.videoplayer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe('Titanium.Media.VideoPlayer', () => {

describe.ios('.mediaTypes', () => {
it('is a String', () => {
should(player).have.a.property('mediaTypes').which.is.a.String();
should(player).have.a.readOnlyProperty('mediaTypes').which.is.a.String();
});

it('is one of Ti.Media.VIDEO_MEDIA_TYPE_*', () => {
Expand Down Expand Up @@ -189,7 +189,7 @@ describe('Titanium.Media.VideoPlayer', () => {
});

it('defaults to false', () => { // eslint-disable-line mocha/no-identical-title
should(player.pictureInPictureEnabled).be.false();
should(player.pictureInPictureEnabled).be.true();
});
});

Expand Down

0 comments on commit ba7e5aa

Please sign in to comment.