Skip to content
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

fix(ios): fix default value of property pictureInPictureEnabled #12239

Merged
merged 4 commits into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the related unit test should be modified to assert the property is 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