Skip to content

Commit

Permalink
fix(ios): videoplayer crash when setting showsControls earlier than u…
Browse files Browse the repository at this point in the history
…rl property (#12703)

Fixes TIMOB-28217
  • Loading branch information
build committed Apr 8, 2021
1 parent 5c9d3f9 commit e84ce9d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
4 changes: 3 additions & 1 deletion iphone/TitaniumKit/TitaniumKit/Sources/API/TiProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -936,10 +936,11 @@ - (void)fireEvent:(NSString *)type withObject:(id)obj withSource:(id)source prop
NSThread.isMainThread);
}

- (void)setValuesForKeysWithDictionary:(NSDictionary *)keyedValues
- (void)setValuesForKeysWithDictionary:(NSDictionary *)dictionary
{
//It's possible that the 'setvalueforkey' has its own plans of what should be in the JS object,
//so we should do this first as to not overwrite the subclass's setter.
NSDictionary *keyedValues = [dictionary copy];
if ((bridgeCount == 1) && (pageKrollObject != nil)) {
for (NSString *currentKey in keyedValues) {
id currentValue = [keyedValues objectForKey:currentKey];
Expand Down Expand Up @@ -991,6 +992,7 @@ - (void)setValuesForKeysWithDictionary:(NSDictionary *)keyedValues
}
[self setValue:thisValue forKey:thisKey];
}
RELEASE_TO_NIL(keyedValues);
}

DEFINE_EXCEPTIONS
Expand Down
23 changes: 23 additions & 0 deletions tests/Resources/ti.media.videoplayer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,4 +478,27 @@ describe.androidARM64Broken('Titanium.Media.VideoPlayer', () => {
player.addEventListener('playing', () => finish());
win.open();
});

it.ios('App should not crash when setting url after video player creation (TIMOB-28217)', function (finish) {
this.timeout(10000);

win = Ti.UI.createWindow();
player = Ti.Media.createVideoPlayer({
top: 120,
autoplay: false,
backgroundColor: 'blue',
height: 300,
width: 300,
mediaControlStyle: Titanium.Media.VIDEO_CONTROL_DEFAULT,
scalingMode: Titanium.Media.VIDEO_SCALING_ASPECT_FIT,
showsControls: true,
});
player.url = '/movie.mp4';
win.add(player);
win.addEventListener('open', () => {
finish();
});

win.open();
});
});

0 comments on commit e84ce9d

Please sign in to comment.