Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added scaling support

  • Loading branch information...
commit 116ddee0649fc4a3154d5b0f1d5159df225ef187 1 parent 76e7ffb
@mdales authored
View
8 MediaPlayer/Classes/MPMoviePlayerController.h
@@ -57,6 +57,13 @@ enum {
};
typedef NSInteger MPMoviePlaybackState;
+typedef enum {
+ MPMovieScalingModeNone,
+ MPMovieScalingModeAspectFit,
+ MPMovieScalingModeAspectFill,
+ MPMovieScalingModeFill
+} MPMovieScalingMode;
+
extern NSString *const MPMoviePlayerPlaybackDidFinishReasonUserInfoKey;
// notifications
@@ -82,6 +89,7 @@ extern NSString *const MPMovieDurationAvailableNotification;
@property (nonatomic, readonly) MPMoviePlaybackState playbackState;
@property (nonatomic) MPMovieRepeatMode repeatMode;
@property (nonatomic, readonly) NSTimeInterval duration;
+@property (nonatomic) MPMovieScalingMode scalingMode;
- (id)initWithContentURL: (NSURL*)url;
View
13 MediaPlayer/Classes/MPMoviePlayerController.m
@@ -26,6 +26,17 @@ @implementation MPMoviePlayerController
@synthesize movieSourceType=_movieSourceType;
@synthesize playbackState=_playbackState;
@synthesize repeatMode=_repeatMode;
+@synthesize scalingMode=_scalingMode;
+
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+- (void)setScalingMode:(MPMovieScalingMode)scalingMode
+{
+ _scalingMode = scalingMode;
+ movieView.scalingMode = scalingMode;
+}
///////////////////////////////////////////////////////////////////////////////
@@ -149,6 +160,8 @@ - (id)initWithContentURL:(NSURL *)url
movieView = [[UIInternalMovieView alloc] initWithMovie: movie];
+ self.scalingMode = MPMovieScalingModeAspectFit;
+
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(loadStateChangeOccurred:)
name: QTMovieLoadStateDidChangeNotification
View
4 MediaPlayer/Classes/UIInternalMovieView.h
@@ -9,11 +9,15 @@
#import <UIKit/UIKit.h>
#import <QTKit/QTKit.h>
+#import "MPMoviePlayerController.h"
+
+
@interface UIInternalMovieView : UIView {
@private
QTMovieLayer *movieLayer;
}
@property (nonatomic, retain) QTMovie* movie;
+@property (nonatomic, assign) MPMovieScalingMode scalingMode;
- (id)initWithMovie: (QTMovie*)movie;
View
30 MediaPlayer/Classes/UIInternalMovieView.m
@@ -12,6 +12,36 @@
@implementation UIInternalMovieView
@synthesize movie=_movie;
+@synthesize scalingMode=_scalingMode;
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+- (void)setScalingMode:(MPMovieScalingMode)scalingMode
+{
+ _scalingMode = scalingMode;
+
+ switch (scalingMode)
+ {
+ case MPMovieScalingModeNone:
+ movieLayer.contentsGravity = kCAGravityCenter;
+ break;
+
+ case MPMovieScalingModeAspectFit:
+ movieLayer.contentsGravity = kCAGravityResizeAspect;
+ break;
+
+ case MPMovieScalingModeAspectFill:
+ movieLayer.contentsGravity = kCAGravityResizeAspectFill;
+ break;
+
+ case MPMovieScalingModeFill:
+ movieLayer.contentsGravity = kCAGravityResize;
+ break;
+
+ }
+}
+
///////////////////////////////////////////////////////////////////////////////
//
View
4 MediaPlayer/MediaPlayer.xcodeproj/project.pbxproj
@@ -18,6 +18,7 @@
4C16781B13C71E6200814195 /* UIInternalMovieView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C16781913C71E6200814195 /* UIInternalMovieView.m */; };
4C16787D13C71FB900814195 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C16787C13C71FB900814195 /* UIKit.framework */; };
4C16789F13C7206500814195 /* QTKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C16789E13C7206500814195 /* QTKit.framework */; };
+ 4C72FDF613C746E800D3E453 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C72FDF513C746E800D3E453 /* QuartzCore.framework */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -46,6 +47,7 @@
4C16787213C71F8A00814195 /* UIKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = UIKit.xcodeproj; path = ../UIKit/UIKit.xcodeproj; sourceTree = "<group>"; };
4C16787C13C71FB900814195 /* UIKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = UIKit.framework; sourceTree = SOURCE_ROOT; };
4C16789E13C7206500814195 /* QTKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QTKit.framework; path = System/Library/Frameworks/QTKit.framework; sourceTree = SDKROOT; };
+ 4C72FDF513C746E800D3E453 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8DC2EF5B0486A6940098B216 /* MediaPlayer.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MediaPlayer.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
@@ -55,6 +57,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ 4C72FDF613C746E800D3E453 /* QuartzCore.framework in Frameworks */,
4C16789F13C7206500814195 /* QTKit.framework in Frameworks */,
4C16787D13C71FB900814195 /* UIKit.framework in Frameworks */,
14EFB1BB1211DB5300D19B0C /* Cocoa.framework in Frameworks */,
@@ -75,6 +78,7 @@
0867D691FE84028FC02AAC07 /* UIKit */ = {
isa = PBXGroup;
children = (
+ 4C72FDF513C746E800D3E453 /* QuartzCore.framework */,
4C16789E13C7206500814195 /* QTKit.framework */,
4C16787C13C71FB900814195 /* UIKit.framework */,
08FB77AEFE84172EC02AAC07 /* Classes */,
Please sign in to comment.
Something went wrong with that request. Please try again.