Skip to content

Commit 4ed3e00

Browse files
committed
AVFoundationQueuePlayer: Version 2.0, 2016-09-13
Updated to Swift 3 Demonstrates how to create a movie queue playback app using only the AVQueuePlayer and AVPlayerLayer classes of AVFoundation (not AVKit). You’ll find out how to manage a queue compromised of local, HTTP-live-streamed, and progressive-download movies. You’ll also see how to implement play, pause, skip, volume adjustment, time slider updating, and scrubbing.
1 parent d8a5c61 commit 4ed3e00

File tree

66 files changed

+3217
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+3217
-0
lines changed
169 KB
Binary file not shown.
6.46 MB
Binary file not shown.
156 KB
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[
2+
{
3+
"title" : "Video File",
4+
"mediaResourceName" : "ElephantSeals.mov",
5+
"thumbnailResourceName" : "LocalVideoThumb.png"
6+
},
7+
{
8+
"title" : "Audio File",
9+
"mediaResourceName" : "Drums.m4a",
10+
"thumbnailResourceName" : "LocalAudioThumb.png"
11+
},
12+
{
13+
"title" : "HTTP Live Stream",
14+
"mediaURL" : "https://devimages.apple.com.edgekey.net/samplecode/avfoundationMedia/AVFoundationQueuePlayer_HLS2/master.m3u8",
15+
"thumbnailResourceName" : "HLSThumb.png"
16+
},
17+
{
18+
"title" : "Progressive Download",
19+
"mediaURL" : "https://devimages.apple.com.edgekey.net/samplecode/avfoundationMedia/AVFoundationQueuePlayer_Progressive.mov",
20+
"thumbnailResourceName" : "ProgressiveThumb.png"
21+
}
22+
]
Loading

AVFoundationQueuePlayer/LICENSE.txt

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Sample code project: AVFoundationQueuePlayer-iOS: Using a Mixture of Local File Based Assets and HTTP Live Streaming Assets with AVFoundation
2+
Version: 2.0
3+
4+
IMPORTANT: This Apple software is supplied to you by Apple
5+
Inc. ("Apple") in consideration of your agreement to the following
6+
terms, and your use, installation, modification or redistribution of
7+
this Apple software constitutes acceptance of these terms. If you do
8+
not agree with these terms, please do not use, install, modify or
9+
redistribute this Apple software.
10+
11+
In consideration of your agreement to abide by the following terms, and
12+
subject to these terms, Apple grants you a personal, non-exclusive
13+
license, under Apple's copyrights in this original Apple software (the
14+
"Apple Software"), to use, reproduce, modify and redistribute the Apple
15+
Software, with or without modifications, in source and/or binary forms;
16+
provided that if you redistribute the Apple Software in its entirety and
17+
without modifications, you must retain this notice and the following
18+
text and disclaimers in all such redistributions of the Apple Software.
19+
Neither the name, trademarks, service marks or logos of Apple Inc. may
20+
be used to endorse or promote products derived from the Apple Software
21+
without specific prior written permission from Apple. Except as
22+
expressly stated in this notice, no other rights or licenses, express or
23+
implied, are granted by Apple herein, including but not limited to any
24+
patent rights that may be infringed by your derivative works or by other
25+
works in which the Apple Software may be incorporated.
26+
27+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
28+
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
29+
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
30+
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
31+
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
32+
33+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
34+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36+
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
37+
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
38+
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
39+
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
40+
POSSIBILITY OF SUCH DAMAGE.
41+
42+
Copyright (C) 2016 Apple Inc. All Rights Reserved.

AVFoundationQueuePlayer/Objective-C/AVFoundationQueuePlayer-iOS.xcodeproj/project.pbxproj

+383
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
Copyright (C) 2016 Apple Inc. All Rights Reserved.
3+
See LICENSE.txt for this sample’s licensing information
4+
5+
Abstract:
6+
Application delegate.
7+
*/
8+
9+
@import UIKit;
10+
11+
@interface AAPLAppDelegate : UIResponder <UIApplicationDelegate>
12+
13+
@property (strong, nonatomic) UIWindow *window;
14+
15+
@end
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
Copyright (C) 2016 Apple Inc. All Rights Reserved.
3+
See LICENSE.txt for this sample’s licensing information
4+
5+
Abstract:
6+
Application delegate.
7+
*/
8+
9+
#import "AAPLAppDelegate.h"
10+
11+
@implementation AAPLAppDelegate
12+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
Copyright (C) 2016 Apple Inc. All Rights Reserved.
3+
See LICENSE.txt for this sample’s licensing information
4+
5+
Abstract:
6+
View containing an AVPlayerLayer.
7+
*/
8+
9+
@import UIKit;
10+
11+
@class AVPlayer;
12+
13+
@interface AAPLPlayerView : UIView
14+
@property AVPlayer *player;
15+
@property (readonly) AVPlayerLayer *playerLayer;
16+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
Copyright (C) 2016 Apple Inc. All Rights Reserved.
3+
See LICENSE.txt for this sample’s licensing information
4+
5+
Abstract:
6+
View containing an AVPlayerLayer.
7+
*/
8+
9+
@import Foundation;
10+
@import AVFoundation;
11+
#import "AAPLPlayerView.h"
12+
13+
14+
@implementation AAPLPlayerView
15+
16+
- (AVPlayer *)player {
17+
return self.playerLayer.player;
18+
}
19+
20+
- (void)setPlayer:(AVPlayer *)player {
21+
self.playerLayer.player = player;
22+
}
23+
24+
// override UIView
25+
+ (Class)layerClass {
26+
return [AVPlayerLayer class];
27+
}
28+
29+
- (AVPlayerLayer *)playerLayer {
30+
return (AVPlayerLayer *)self.layer;
31+
}
32+
33+
@end
34+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
Copyright (C) 2016 Apple Inc. All Rights Reserved.
3+
See LICENSE.txt for this sample’s licensing information
4+
5+
Abstract:
6+
View controller containing a player view and basic playback controls.
7+
*/
8+
9+
@import UIKit;
10+
11+
12+
@class AAPLPlayerView;
13+
14+
@interface AAPLPlayerViewController : UIViewController
15+
16+
@property (readonly) AVQueuePlayer *player;
17+
18+
/*
19+
@{
20+
NSURL(asset URL) : @{
21+
NSString(title) : NSString,
22+
NSString(thumbnail) : UIImage
23+
}
24+
}
25+
*/
26+
@property NSMutableDictionary *loadedAssets;
27+
28+
@property CMTime currentTime;
29+
@property (readonly) CMTime duration;
30+
@property float rate;
31+
32+
@end

0 commit comments

Comments
 (0)