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

[TIMOB-19040] :Replace MPMoviePlayerController in Ti.Media.VideoPlayer with AVPlayerViewController #8721

Merged
merged 49 commits into from
Nov 14, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
282ebef
Merge branch 'master' of https://github.com/appcelerator/titanium_mobile
hansemannn Jul 8, 2015
8673080
Merge branch 'master' of https://github.com/appcelerator/titanium_mobile
hansemannn Jul 10, 2015
746f1c7
[TIMOB-19040] MPMoviePlayer deprecation 1
hansemannn Jul 13, 2015
d8e8a32
[TIMOB-19040] MPMoviePlayer deprecation 1
hansemannn Jul 30, 2015
6f35822
Merge branch 'master' of https://github.com/appcelerator/titanium_mob…
hansemannn Jul 30, 2015
923cb51
[TIMOB-19040] MPMoviePlayer deprecation 2
hansemannn Aug 17, 2015
c48fd4e
Merge master
hansemannn Aug 22, 2015
d0bec83
Merge branch 'master' of https://github.com/appcelerator/titanium_mob…
hansemannn Aug 22, 2015
49e9210
[TIMOB-19040] MPMoviePlayer deprecation 3
hansemannn Aug 24, 2015
ae29a97
Restore KitchenSink app.js
hansemannn Sep 3, 2015
d5e62d6
[TIMOB-19040] MPMoviePlayer deprecation 4
hansemannn Sep 3, 2015
70d2990
[TIMOB-19040] MPMoviePlayer deprecation 4
hansemannn Sep 3, 2015
5ad6fa9
Update events / observer
hansemannn Sep 21, 2015
f5589c4
Support iOS9 PiP, resizing, play, pause & stop
hansemannn Sep 23, 2015
e5651d9
Remove deprecated methods, support autoplay
hansemannn Sep 23, 2015
f2a7575
Improve iOS8 backward compatibility
hansemannn Sep 24, 2015
e2d934e
Add another sample video to KitchenSink
hansemannn Sep 24, 2015
1ca221b
Re-support thumbnail generation
hansemannn Sep 24, 2015
b2ccd83
Re-support initialPlaybackTime, fullscreen mode
hansemannn Sep 25, 2015
9dc5fec
[TIMOB-19040] Add more functionality, adjust style
hansemannn Aug 7, 2016
bff3571
Merge branch 'master' of github.com:appcelerator/titanium_mobile into…
hansemannn Aug 8, 2016
5ad1550
Merge branch 'master' of github.com:appcelerator/titanium_mobile into…
hansemannn Dec 12, 2016
b420867
Merge branch 'PR-8194' into TIMOB-19040
vijaysingh-axway Dec 21, 2016
e18eb16
[TIMOB-19040]:iOS9: Replace MPMoviePlayerController in
vijaysingh-axway Dec 21, 2016
28503a8
[TIMOB-19040]:added showSontrols property added
vijaysingh-axway Dec 22, 2016
0539dc9
overlayview addition property exposed.
vijaysingh-axway Dec 22, 2016
1010932
[TIMOB-19040]: iOS Overlayview added and deprecated properties removed.
vijaysingh-axway Dec 27, 2016
e4375e0
[TIMOB-19040]: Deprecated properties removed.
vijaysingh-axway Dec 27, 2016
d5075a2
[TIMOB-19040]: player status property added
vijaysingh-axway Dec 27, 2016
89085e8
[TIMOB-19040]: Unnecesssary properties removed
vijaysingh-axway Dec 27, 2016
fd063a5
[TIMOB-19040]: Notification configured again as url changes
vijaysingh-axway Dec 28, 2016
942c9ef
[TIMOB-19040]: Doc updated
vijaysingh-axway Dec 30, 2016
c0dff04
Merge branch 'master' into TIMOB-19040
vijaysingh-axway Oct 31, 2017
5e563f3
Update VideoPlayer.yml
hansemannn Nov 1, 2017
d348213
Update MediaModule.m
hansemannn Nov 1, 2017
8212744
[TIMOB-19040] : audiosessionmode method removed
vijaysingh-axway Nov 2, 2017
1e3809d
Merge branch 'master' into TIMOB-19040
hansemannn Nov 2, 2017
7716bbc
Merge branch 'master' into TIMOB-19040
hansemannn Nov 7, 2017
cf93d99
Merge branch 'master' into TIMOB-19040
vijaysingh-axway Nov 8, 2017
82f6805
[TIMOB-19040] : Fix setInitialPlaybackTime issue
vijaysingh-axway Nov 8, 2017
5fd0bd8
[TIMOB-19040] : linting issue fixed
vijaysingh-axway Nov 8, 2017
f5e9068
[TIMOB-19040] : demos/KitchenSink/Resources/another.mp4
vijaysingh-axway Nov 8, 2017
a8a0e18
[TIMOB-19040] : Doc updated
vijaysingh-axway Nov 9, 2017
446f703
[TIMOB-19040] : requestThumbnailImagesAtTimes supported
vijaysingh-axway Nov 13, 2017
5554f12
Merge branch 'master' into TIMOB-19040
vijaysingh-axway Nov 13, 2017
3ea12ad
[TIMOB-19040] : Doc updated
vijaysingh-axway Nov 13, 2017
30ba65f
[TIMOB-19040] : Updated docs
vijaysingh-axway Nov 14, 2017
9f1795a
[TIMOB-19040] : Special character removed from doc
vijaysingh-axway Nov 14, 2017
21a2c7e
[TIMOB-19040] : Unit tests added
vijaysingh-axway Nov 14, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 1 addition & 10 deletions apidoc/Titanium/Media/VideoPlayer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,6 @@ examples:
methods:

- name: cancelAllThumbnailImageRequests
deprecated:
platforms: [iphone, ipad]
since: '7.0.0'
notes: This method has been removed for iOS in Titanium SDK 7.0.0 as of the official deprecation by Apple.
removed: '7.0.0'
summary: Cancels all pending asynchronous thumbnail requests.
description: |
Asynchronous thumbnail requests initiated with
Expand Down Expand Up @@ -610,7 +605,6 @@ properties:

- name: fullscreen
deprecated:
platforms: [iphone, ipad]
since: '7.0.0'
notes: This method has been removed for iOS in Titanium SDK 7.0.0 as of the official deprecation by Apple.
removed: '7.0.0'
Expand Down Expand Up @@ -639,7 +633,6 @@ properties:

- name: loadState
deprecated:
platforms: [iphone, ipad]
since: "7.0.0"
notes: On iOS, use <Titanium.Media.VideoPlayer.moviePlayerStatus> instead.
summary: Returns the network load state of the movie player.
Expand All @@ -654,9 +647,8 @@ properties:

- name: mediaControlStyle
deprecated:
platforms: [iphone, ipad]
since: "7.0.0"
notes: On iOS, use <Titanium.Media.VideoPlayer.scalingMode> instead.
notes: On iOS, use <Titanium.Media.VideoPlayer.showsControls> instead.
summary: The style of the playback controls.
description: |
Mobile web only supports <Titanium.Media.VIDEO_CONTROL_NONE> and
Expand Down Expand Up @@ -768,7 +760,6 @@ properties:

- name: repeatMode
deprecated:
platforms: [iphone, ipad]
since: '7.0.0'
notes: This method has been removed for iOS in Titanium SDK 7.0.0 as of the official deprecation by Apple.
removed: '7.0.0'
Expand Down
6 changes: 6 additions & 0 deletions iphone/Classes/MediaModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
#import <AssetsLibrary/AssetsLibrary.h>
#endif
#import "TiUIiOSLivePhoto.h"
#ifdef USE_TI_MEDIAVIDEOPLAYER
#import "TiMediaVideoPlayerProxy.h"
#endif

// by default, we want to make the camera fullscreen and
// these transform values will scale it when we have our own overlay
Expand Down Expand Up @@ -351,6 +354,9 @@ - (NSString *)MEDIA_TYPE_LIVEPHOTO
MAKE_SYSTEM_PROP(VIDEO_LOAD_STATE_UNKNOWN, AVPlayerStatusUnknown);
MAKE_SYSTEM_PROP(VIDEO_LOAD_STATE_PLAYABLE, AVPlayerStatusReadyToPlay);
MAKE_SYSTEM_PROP(VIDEO_LOAD_STATE_FAILED, AVPlayerStatusFailed);

MAKE_SYSTEM_PROP(VIDEO_TIME_OPTION_NEAREST_KEYFRAME, VideoTimeOptionNearestKeyFrame);
MAKE_SYSTEM_PROP(VIDEO_TIME_OPTION_EXACT, VideoTimeOptionExact);
#endif

- (TiMediaMusicPlayer *)systemMusicPlayer
Expand Down
6 changes: 6 additions & 0 deletions iphone/Classes/TiMediaVideoPlayerProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@
#import <AVKit/AVKit.h>
#import <MediaPlayer/MediaPlayer.h>

enum {
VideoTimeOptionNearestKeyFrame = 0,
VideoTimeOptionExact,
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use NS_Enums.


@interface TiMediaVideoPlayerProxy : TiViewProxy {
@protected
AVPlayerViewController *movie;
MPMoviePlayerViewController *cont;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did you add the deprecated API again here?

AVPlayerItem *item;
NSRecursiveLock *playerLock;
BOOL playing;
Expand Down
64 changes: 61 additions & 3 deletions iphone/Classes/TiMediaVideoPlayerProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ - (void)setOverlayView:(id)proxy
- (void)setBackgroundView:(id)proxy
{
DEPRECATED_REPLACED_REMOVED(@"Media.VideoPlayer.backgroundView", @"7.0.0", @"7.0.0", @"Media.VideoPlayer.overlayView");
[self setOverlayView:proxy];
}

- (NSNumber *)playing
Expand Down Expand Up @@ -258,12 +259,12 @@ - (NSNumber *)allowsAirPlay

- (void)setMediaControlStyle:(NSNumber *)value
{
DEPRECATED_REPLACED_REMOVED(@"Media.VideoPlayer.mediaControlStyle", @"4.1.0", @"7.0.0", @"Media.VideoPlayer.scalingMode");
DEPRECATED_REPLACED_REMOVED(@"Media.VideoPlayer.mediaControlStyle", @"4.1.0", @"7.0.0", @"Media.VideoPlayer.showsControls");
}

- (NSNumber *)mediaControlStyle
{
DEPRECATED_REPLACED_REMOVED(@"Media.VideoPlayer.mediaControlStyle", @"4.1.0", @"7.0.0", @"Media.VideoPlayer.scalingMode");
DEPRECATED_REPLACED_REMOVED(@"Media.VideoPlayer.mediaControlStyle", @"4.1.0", @"7.0.0", @"Media.VideoPlayer.showsControls");
return NUMINT(0);
}

Expand Down Expand Up @@ -380,6 +381,59 @@ - (void)setVolume:(NSNumber *)newVolume
YES);
}

- (void)requestThumbnailImagesAtTimes:(id)args
{
ENSURE_ARG_COUNT(args, 3);
ENSURE_TYPE([args objectAtIndex:0], NSArray);
ENSURE_TYPE([args objectAtIndex:1], NSNumber);
ENSURE_TYPE([args objectAtIndex:2], KrollCallback);

NSArray *array = [args objectAtIndex:0];
if ([array count] > 0) {
NSMutableArray *cmTimeArray = [NSMutableArray arrayWithCapacity:[array count]];

for (NSNumber *time in array) {
CMTime cmTime = CMTimeMakeWithSeconds([time floatValue], 1);
[cmTimeArray addObject:[NSValue valueWithCMTime:cmTime]];
}
TiThreadPerformOnMainThread(^{
AVAssetImageGenerator *imageGenerator = [AVAssetImageGenerator assetImageGeneratorWithAsset:[[[movie player] currentItem] asset]];
NSNumber *option = [args objectAtIndex:1];

if ([option intValue] == VideoTimeOptionExact) {
imageGenerator.requestedTimeToleranceBefore = kCMTimeZero;
imageGenerator.requestedTimeToleranceAfter = kCMTimeZero;
}

[imageGenerator cancelAllCGImageGeneration];

RELEASE_TO_NIL(thumbnailCallback);
callbackRequestCount = [array count];
thumbnailCallback = [[args objectAtIndex:2] retain];

[imageGenerator generateCGImagesAsynchronouslyForTimes:cmTimeArray
completionHandler:^(CMTime requestedTime, CGImageRef _Nullable imageRef, CMTime actualTime, AVAssetImageGeneratorResult result, NSError *_Nullable error) {
NSMutableDictionary *event = [TiUtils dictionaryWithCode:[error code] message:[TiUtils messageFromError:error]];

if (error == nil) {
UIImage *image = [[UIImage alloc] initWithCGImage:imageRef];
TiBlob *blob = [[[TiBlob alloc] _initWithPageContext:[self pageContext] andImage:image] autorelease];
[event setObject:blob forKey:@"image"];
[image release];
}
[event setObject:NUMDOUBLE(actualTime.value / actualTime.timescale) forKey:@"time"];

[self _fireEventToListener:@"thumbnail" withObject:event listener:thumbnailCallback thisObject:nil];

if (--callbackRequestCount <= 0) {
RELEASE_TO_NIL(thumbnailCallback);
}
}];
},
NO);
}
}

- (NSNumber *)pictureInPictureEnabled
{
return NUMBOOL([TiUtils isIOS9OrGreater] && [movie allowsPictureInPicturePlayback]);
Expand All @@ -404,7 +458,11 @@ - (void)setShowsControls:(NSNumber *)value

- (void)cancelAllThumbnailImageRequests:(id)value
{
DEPRECATED_REMOVED(@"Media.VideoPlayer.cancelAllThumbnailImageRequests", @"7.0.0", @"7.0.0")
TiThreadPerformOnMainThread(^{
AVAssetImageGenerator *imageGenerator = [AVAssetImageGenerator assetImageGeneratorWithAsset:[[[movie player] currentItem] asset]];
[imageGenerator cancelAllCGImageGeneration];
},
NO);
}

- (TiBlob *)thumbnailImageAtTime:(id)args
Expand Down