提交 788352d5 编写于 作者: Z Zhang Rui

ios: add IJKAVMoviePlayerController

上级 db0dfef1
......@@ -19,6 +19,9 @@
E6716E4E1807EA5000B3FBC1 /* IJKFFMrl.m in Sources */ = {isa = PBXBuildFile; fileRef = E6716E4D1807EA5000B3FBC1 /* IJKFFMrl.m */; };
E672D6F318D3445100C51FF9 /* IJKMediaModule.m in Sources */ = {isa = PBXBuildFile; fileRef = E672D6F218D3445100C51FF9 /* IJKMediaModule.m */; };
E672D6F418D345C100C51FF9 /* IJKMediaModule.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = E672D6F118D3445100C51FF9 /* IJKMediaModule.h */; };
E67C4E0519D15B3200415CEE /* IJKAVPlayerLayerView.m in Sources */ = {isa = PBXBuildFile; fileRef = E67C4E0419D15B3200415CEE /* IJKAVPlayerLayerView.m */; };
E67C4E0819D15EEA00415CEE /* IJKAVMoviePlayerController.m in Sources */ = {isa = PBXBuildFile; fileRef = E67C4E0719D15EEA00415CEE /* IJKAVMoviePlayerController.m */; };
E67C4E0A19D2BFF100415CEE /* IJKAVMoviePlayerController.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = E67C4E0619D15EEA00415CEE /* IJKAVMoviePlayerController.h */; };
E6903EC217EAF6C500CFD954 /* IJKMediaPlayback.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = E6903EC117EAF6C500CFD954 /* IJKMediaPlayback.h */; };
E6903FC717EAFC2C00CFD954 /* libavcodec.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E6903FC217EAFC2C00CFD954 /* libavcodec.a */; };
E6903FC817EAFC2C00CFD954 /* libavformat.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E6903FC317EAFC2C00CFD954 /* libavformat.a */; };
......@@ -61,6 +64,7 @@
dstPath = "include/${PRODUCT_NAME}";
dstSubfolderSpec = 16;
files = (
E67C4E0A19D2BFF100415CEE /* IJKAVMoviePlayerController.h in CopyFiles */,
E672D6F418D345C100C51FF9 /* IJKMediaModule.h in CopyFiles */,
E62139BF180FAE5F00553533 /* IJKFFOptions.h in CopyFiles */,
E6F727BE17F40C390043623F /* IJKFFMoviePlayerController.h in CopyFiles */,
......@@ -95,6 +99,10 @@
E6716E4D1807EA5000B3FBC1 /* IJKFFMrl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IJKFFMrl.m; sourceTree = "<group>"; };
E672D6F118D3445100C51FF9 /* IJKMediaModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IJKMediaModule.h; path = IJKMediaPlayer/IJKMediaModule.h; sourceTree = "<group>"; };
E672D6F218D3445100C51FF9 /* IJKMediaModule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IJKMediaModule.m; path = IJKMediaPlayer/IJKMediaModule.m; sourceTree = "<group>"; };
E67C4E0319D15B3200415CEE /* IJKAVPlayerLayerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IJKAVPlayerLayerView.h; path = IJKMediaPlayer/IJKAVPlayerLayerView.h; sourceTree = "<group>"; };
E67C4E0419D15B3200415CEE /* IJKAVPlayerLayerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IJKAVPlayerLayerView.m; path = IJKMediaPlayer/IJKAVPlayerLayerView.m; sourceTree = "<group>"; };
E67C4E0619D15EEA00415CEE /* IJKAVMoviePlayerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IJKAVMoviePlayerController.h; path = IJKMediaPlayer/IJKAVMoviePlayerController.h; sourceTree = "<group>"; };
E67C4E0719D15EEA00415CEE /* IJKAVMoviePlayerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IJKAVMoviePlayerController.m; path = IJKMediaPlayer/IJKAVMoviePlayerController.m; sourceTree = "<group>"; };
E6850E7A195D6ABF00550718 /* ijkavfmsg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ijkavfmsg.h; sourceTree = "<group>"; };
E6903EB917EAF6C500CFD954 /* libIJKMediaPlayer.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libIJKMediaPlayer.a; sourceTree = BUILT_PRODUCTS_DIR; };
E6903EC017EAF6C500CFD954 /* IJKMediaPlayer-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "IJKMediaPlayer-Prefix.pch"; sourceTree = "<group>"; };
......@@ -272,6 +280,7 @@
isa = PBXGroup;
children = (
E6F727B517F2B1690043623F /* IJKMediaPlayer */,
E67C4E0219D15B0600415CEE /* IJKAVMoviePlayerController */,
E66F8DBE17EEC5DE00354D80 /* IJKMPMoviePlayerController */,
E6903EBE17EAF6C500CFD954 /* IJKFFMoviePlayerController */,
);
......@@ -297,6 +306,17 @@
path = ../../ios/IJKMediaPlayer/IJKMediaPlayer;
sourceTree = "<group>";
};
E67C4E0219D15B0600415CEE /* IJKAVMoviePlayerController */ = {
isa = PBXGroup;
children = (
E67C4E0319D15B3200415CEE /* IJKAVPlayerLayerView.h */,
E67C4E0419D15B3200415CEE /* IJKAVPlayerLayerView.m */,
E67C4E0619D15EEA00415CEE /* IJKAVMoviePlayerController.h */,
E67C4E0719D15EEA00415CEE /* IJKAVMoviePlayerController.m */,
);
name = IJKAVMoviePlayerController;
sourceTree = "<group>";
};
E6903EB017EAF6C500CFD954 = {
isa = PBXGroup;
children = (
......@@ -704,6 +724,7 @@
E690403417EAFC6100CFD954 /* ijksdl_vout.c in Sources */,
E6EE92B91878230C009EAB56 /* ijksdl_thread_ios.m in Sources */,
E66F8DC117EEC65200354D80 /* IJKMPMoviePlayerController.m in Sources */,
E67C4E0819D15EEA00415CEE /* IJKAVMoviePlayerController.m in Sources */,
E6EE92B81878230C009EAB56 /* ijksdl_aout_ios_audiounit.m in Sources */,
E6EE92C21878236A009EAB56 /* IJKSDLAudioQueueController.m in Sources */,
E66F8DE717EFD9C300354D80 /* IJKFFMoviePlayerController.m in Sources */,
......@@ -716,6 +737,7 @@
E6EE92BF1878230C009EAB56 /* IJKSDLGLView.m in Sources */,
E6F727BB17F2D9D40043623F /* IJKFFMoviePlayerDef.m in Sources */,
E6EE92BE1878230C009EAB56 /* IJKSDLGLShader.m in Sources */,
E67C4E0519D15B3200415CEE /* IJKAVPlayerLayerView.m in Sources */,
E6F727C217F7C9BA0043623F /* IJKMediaPlayback.m in Sources */,
E6EE92BA1878230C009EAB56 /* ijksdl_vout_ios_gles2.m in Sources */,
E6716E4B1807E5FC00B3FBC1 /* IJKMediaUtils.m in Sources */,
......
/*
* IJKAVMoviePlayerController.h
*
* Copyright (c) 2014 Zhang Rui <bbcallen@gmail.com>
*
* This file is part of ijkPlayer.
*
* ijkPlayer is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* ijkPlayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with ijkPlayer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
File: AVPlayerDemoPlaybackViewController.h
Abstract: UIViewController managing a playback view, thumbnail view, and associated playback UI.
Version: 1.3
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or
redistribute this Apple software.
In consideration of your agreement to abide by the following terms, and
subject to these terms, Apple grants you a personal, non-exclusive
license, under Apple's copyrights in this original Apple software (the
"Apple Software"), to use, reproduce, modify and redistribute the Apple
Software, with or without modifications, in source and/or binary forms;
provided that if you redistribute the Apple Software in its entirety and
without modifications, you must retain this notice and the following
text and disclaimers in all such redistributions of the Apple Software.
Neither the name, trademarks, service marks or logos of Apple Inc. may
be used to endorse or promote products derived from the Apple Software
without specific prior written permission from Apple. Except as
expressly stated in this notice, no other rights or licenses, express or
implied, are granted by Apple herein, including but not limited to any
patent rights that may be infringed by your derivative works or by other
works in which the Apple Software may be incorporated.
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Copyright (C) 2014 Apple Inc. All Rights Reserved.
*/
#import "IJKMediaPlayback.h"
@interface IJKAVMoviePlayerController : NSObject <IJKMediaPlayback>
- (id)initWithContentURL:(NSURL *)aUrl;
@end
/*
* IJKAVPlayerLayerView.h
*
* Copyright (c) 2014 Zhang Rui <bbcallen@gmail.com>
*
* This file is part of ijkPlayer.
*
* ijkPlayer is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* ijkPlayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with ijkPlayer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
File: AVPlayerDemoPlaybackView.h
Abstract: UIView subclass to display the content associated with an AVPlayer
Version: 1.3
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or
redistribute this Apple software.
In consideration of your agreement to abide by the following terms, and
subject to these terms, Apple grants you a personal, non-exclusive
license, under Apple's copyrights in this original Apple software (the
"Apple Software"), to use, reproduce, modify and redistribute the Apple
Software, with or without modifications, in source and/or binary forms;
provided that if you redistribute the Apple Software in its entirety and
without modifications, you must retain this notice and the following
text and disclaimers in all such redistributions of the Apple Software.
Neither the name, trademarks, service marks or logos of Apple Inc. may
be used to endorse or promote products derived from the Apple Software
without specific prior written permission from Apple. Except as
expressly stated in this notice, no other rights or licenses, express or
implied, are granted by Apple herein, including but not limited to any
patent rights that may be infringed by your derivative works or by other
works in which the Apple Software may be incorporated.
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Copyright (C) 2014 Apple Inc. All Rights Reserved.
*/
#import <UIKit/UIKit.h>
@class AVPlayer;
@interface IJKAVPlayerLayerView: UIView
@property (nonatomic, strong) AVPlayer* player;
- (void)setPlayer:(AVPlayer*)player;
- (void)setVideoFillMode:(NSString *)fillMode;
@end
/*
* IJKAVPlayerLayerView.m
*
* Copyright (c) 2014 Zhang Rui <bbcallen@gmail.com>
*
* This file is part of ijkPlayer.
*
* ijkPlayer is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* ijkPlayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with ijkPlayer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
File: AVPlayerDemoPlaybackView.m
Abstract: UIView subclass to display the content associated with an AVPlayer
Version: 1.3
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or
redistribute this Apple software.
In consideration of your agreement to abide by the following terms, and
subject to these terms, Apple grants you a personal, non-exclusive
license, under Apple's copyrights in this original Apple software (the
"Apple Software"), to use, reproduce, modify and redistribute the Apple
Software, with or without modifications, in source and/or binary forms;
provided that if you redistribute the Apple Software in its entirety and
without modifications, you must retain this notice and the following
text and disclaimers in all such redistributions of the Apple Software.
Neither the name, trademarks, service marks or logos of Apple Inc. may
be used to endorse or promote products derived from the Apple Software
without specific prior written permission from Apple. Except as
expressly stated in this notice, no other rights or licenses, express or
implied, are granted by Apple herein, including but not limited to any
patent rights that may be infringed by your derivative works or by other
works in which the Apple Software may be incorporated.
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Copyright (C) 2014 Apple Inc. All Rights Reserved.
*/
#import "IJKAVPlayerLayerView.h"
#import <AVFoundation/AVFoundation.h>
@implementation IJKAVPlayerLayerView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
+ (Class)layerClass
{
return [AVPlayerLayer class];
}
- (AVPlayer*)player
{
return [(AVPlayerLayer*)[self layer] player];
}
- (void)setPlayer:(AVPlayer*)player
{
[(AVPlayerLayer*)[self layer] setPlayer:player];
}
/* Specifies how the video is displayed within a player layer’s bounds.
(AVLayerVideoGravityResizeAspect is default) */
- (void)setVideoFillMode:(NSString *)fillMode
{
AVPlayerLayer *playerLayer = (AVPlayerLayer*)[self layer];
playerLayer.videoGravity = fillMode;
}
- (void)setContentMode:(UIViewContentMode)contentMode
{
[super setContentMode:contentMode];
switch (contentMode) {
case UIViewContentModeScaleToFill:
[self setVideoFillMode:AVLayerVideoGravityResize];
break;
case UIViewContentModeCenter:
[self setVideoFillMode:AVLayerVideoGravityResizeAspect];
break;
case UIViewContentModeScaleAspectFill:
[self setVideoFillMode:AVLayerVideoGravityResizeAspectFill];
break;
case UIViewContentModeScaleAspectFit:
[self setVideoFillMode:AVLayerVideoGravityResizeAspect];
default:
break;
}
}
@end
......@@ -418,7 +418,8 @@ void IJKFFIOStatCompleteRegister(void (*cb)(const char *url,
[self setScreenOn:NO];
[[NSNotificationCenter defaultCenter]
postNotificationName:IJKMoviePlayerPlaybackDidFinishNotification object:self];
postNotificationName:IJKMoviePlayerPlaybackStateDidChangeNotification
object:self];
[[NSNotificationCenter defaultCenter]
postNotificationName:IJKMoviePlayerPlaybackDidFinishNotification
......@@ -447,12 +448,13 @@ void IJKFFIOStatCompleteRegister(void (*cb)(const char *url,
[self setScreenOn:NO];
[[NSNotificationCenter defaultCenter]
postNotificationName:IJKMoviePlayerPlaybackDidFinishNotification object:self];
postNotificationName:IJKMoviePlayerPlaybackStateDidChangeNotification
object:self];
[[NSNotificationCenter defaultCenter]
postNotificationName:IJKMoviePlayerPlaybackDidFinishNotification
object:self
userInfo:@{MPMoviePlayerPlaybackDidFinishReasonUserInfoKey: @(MPMovieFinishReasonPlaybackError)}];
userInfo:@{MPMoviePlayerPlaybackDidFinishReasonUserInfoKey: @(MPMovieFinishReasonPlaybackEnded)}];
break;
}
case FFP_MSG_VIDEO_SIZE_CHANGED:
......
......@@ -26,4 +26,6 @@
#import "IJKFFOptions.h"
#import "IJKFFMoviePlayerController.h"
#import "IJKAVMoviePlayerController.h"
#import "IJKMediaModule.h"
......@@ -31,4 +31,13 @@
+ (NSString*)createTempFileNameInDirectory: (NSString*)aDirectory
withPrefix: (NSString*)aPrefix;
+ (NSError*)createErrorWithDomain: (NSString*)domain
code: (NSInteger)code
description: (NSString*)description
reason: (NSString*)reason;
+ (void)kvoQuietlyRemoveObserver:(NSObject *)anObserver
forKeyPath:(NSString *)keyPath
fromObject:(NSObject *)object;
@end
......@@ -50,4 +50,39 @@
return [NSString stringWithCString:filename encoding:NSASCIIStringEncoding];
}
+ (NSError*)createErrorWithDomain: (NSString*)domain
code: (NSInteger)code
description: (NSString*)description
reason: (NSString*)reason
{
/* Generate an error describing the failure. */
if (description == nil)
description = @"";
if (reason == nil)
reason = @"";
NSString *localizedDescription = NSLocalizedString(description, description);
NSString *localizedFailureReason = NSLocalizedString(reason, reason);
NSDictionary *errorDict = [NSDictionary dictionaryWithObjectsAndKeys:
localizedDescription, NSLocalizedDescriptionKey,
localizedFailureReason, NSLocalizedFailureReasonErrorKey,
nil];
NSError *error = [NSError errorWithDomain:domain
code:0
userInfo:errorDict];
return error;
}
+ (void)kvoQuietlyRemoveObserver:(NSObject *)anObserver
forKeyPath:(NSString *)keyPath
fromObject:(NSObject *)object
{
@try {
[object removeObserver:anObserver forKeyPath:@"status"];
}
@catch (NSException *exception) {
NSLog(@"dup remove observer\n");
}
}
@end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册