The AVFoundation framework provides both Objective-C and Swift interfaces for editing and playing audio-visual media in a Mac OSX or iOS application. Questions using this framework should include this tag.
Questions tagged [avfoundation]
6407 questions
440
votes
0 answers
Capture image via captureStillImageAsynchronouslyFromConnection with no shutter sound
There are a lot of questions about this problem on SO:
AVFoundation, how to turn off the shutter sound when captureStillImageAsynchronouslyFromConnection?
How can I mute the capture sound in AVFoundation?
I wish i could mute shutter sound of camera…

k06a
- 17,755
- 10
- 70
- 110
248
votes
19 answers
How to play a sound using Swift?
I would like to play a sound using Swift.
My code worked in Swift 1.0 but now it doesn't work anymore in Swift 2 or newer.
override func viewDidLoad() {
super.viewDidLoad()
let url:NSURL = NSBundle.mainBundle().URLForResource("soundName",…

Michel Kansou
- 2,851
- 4
- 13
- 22
233
votes
12 answers
Making the iPhone vibrate
How can the iPhone be set to vibrate once?
For example, when a player loses a life or the game is over, the iPhone should vibrate.

some_id
- 29,466
- 62
- 182
- 304
199
votes
9 answers
How do I export UIImage array as a movie?
I have a serious problem: I have an NSArray with several UIImage objects. What I now want to do, is create movie from those UIImages. But I don't have any idea how to do so.
I hope someone can help me or send me a code snippet which does something…

Nuker
- 2,577
- 5
- 21
- 32
189
votes
15 answers
How to play video with AVPlayerViewController (AVKit) in Swift
How do you play a video with AV Kit Player View Controller in Swift?
override func viewDidLoad() {
super.viewDidLoad()
let videoURLWithPath = "http://****/5.m3u8"
let videoURL = NSURL(string: videoURLWithPath)
…

orazz
- 2,178
- 2
- 15
- 16
152
votes
22 answers
Looping a video with AVFoundation AVPlayer?
Is there a relatively easy way of looping a video in AVFoundation?
I've created my AVPlayer and AVPlayerLayer like so:
avPlayer = [[AVPlayer playerWithURL:videoUrl] retain];
avPlayerLayer = [[AVPlayerLayer playerLayerWithPlayer:avPlayer]…

orj
- 13,234
- 14
- 63
- 73
120
votes
12 answers
Check play state of AVPlayer
Is there a way to know whether an AVPlayer playback has stalled or reached the end?

Egil
- 4,265
- 4
- 20
- 13
109
votes
12 answers
dyld: Library not loaded: @rpath/libswiftAVFoundation.dylib
I have just updated to Xcode 7 and swift 2 and finished fixing the errors that come with the transition. I finally got the project to build, but after the launch screen I get an error saying:
dyld: Library not loaded:…

coracora
- 1,337
- 3
- 9
- 12
94
votes
9 answers
AVFoundation, how to turn off the shutter sound when captureStillImageAsynchronouslyFromConnection?
I am trying to capture an image during a live preview from the camera, by AVFoundation captureStillImageAsynchronouslyFromConnection. So far the program works as expected. However, how can I mute the shutter sound?

ohho
- 50,879
- 75
- 256
- 383
89
votes
10 answers
Knowing when AVPlayer object is ready to play
I'm trying to play an MP3 file that is passed to an UIView from a previous UIView (stored in a NSURL *fileURL variable).
I'm initializing an AVPlayer with:
player = [AVPlayer playerWithURL:fileURL];
NSLog(@"Player created:%d",player.status);
The…

mvishnu
- 1,150
- 1
- 12
- 15
87
votes
1 answer
AVPlayer and MPMoviePlayerController differences
I am developing an iPhone application that needs to play videos.
So far, I learned that there are at least two API's for achieving this; AVPlayer and MPMoviePlayerController.
What are the main differences?

suse
- 10,503
- 23
- 79
- 113
73
votes
6 answers
Maintaining good scroll performance when using AVPlayer
I'm working on an application where there is a collection view, and cells of the collection view can contain video. Right now I'm displaying the video using AVPlayer and AVPlayerLayer. Unfortunately, the scrolling performance is terrible. It seems…

Antonio
- 988
- 1
- 7
- 12
71
votes
4 answers
How to play audio in background with Swift?
As you see I'm streaming an audio broadcast. But when I press the home button and exit the app streaming stops or I cannot hear. How can I continue streaming in background and listen it from lock screen?
ViewController.Swift
import UIKit
import…

do it better
- 4,627
- 6
- 25
- 41
70
votes
20 answers
AVCaptureVideoPreviewLayer orientation - need landscape
My app is landscape only. I'm presenting the AVCaptureVideoPreviewLayer like this:
self.previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
[self.previewLayer setBackgroundColor:[[UIColor blackColor]…

soleil
- 12,133
- 33
- 112
- 183
65
votes
7 answers
AVCaptureVideoPreviewLayer doesn't fill up whole iPhone 4S Screen
AVCaptureVideoPreviewLayer *avLayer =
[AVCaptureVideoPreviewLayer layerWithSession:session];
avLayer.frame = self.view.frame;
[self.view.layer addSublayer:avLayer];
I use AVCaptureVideoPreviewLayer to display video on the view.
But…

Rafer
- 1,170
- 2
- 10
- 15