AVPlayer and MPMoviePlayerController differences [closed]

NOTE as of iOS9, Apple has deprecated the MPMoviePlayerController: The MPMoviePlayerController class is formally deprecated in iOS 9. (The MPMoviePlayerViewController class is also formally deprecated.) To play video content in iOS 9 and later, instead use the AVPictureInPictureController or AVPlayerViewController class from the AVKit framework, or the WKWebView class from WebKit. Copied from the MPMoviePlayerController … Read more

AVFoundation, how to turn off the shutter sound when captureStillImageAsynchronouslyFromConnection?

I used this code once to capture iOS default shutter sound (here is list of sound file names https://github.com/TUNER88/iOSSystemSoundsLibrary): NSString *path = @”/System/Library/Audio/UISounds/photoShutter.caf”; NSString *docs = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; NSData *data = [NSData dataWithContentsOfFile:path]; [data writeToFile:[docs stringByAppendingPathComponent:@”photoShutter.caf”] atomically:YES]; Then I used third-party app to extract photoShutter.caf from Documents directory (DiskAid for Mac). Next step … Read more

Looping a video with AVFoundation AVPlayer?

You can get a Notification when the player ends. Check AVPlayerItemDidPlayToEndTimeNotification When setting up the player: ObjC avPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerItemDidReachEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:[avPlayer currentItem]]; this will prevent the player to pause at the end. in the notification: – (void)playerItemDidReachEnd:(NSNotification *)notification { AVPlayerItem *p = [notification object]; [p seekToTime:kCMTimeZero]; } this will rewind … Read more

How to play video with AVPlayerViewController (AVKit) in Swift

Swift 3.x – 5.x Necessary: import AVKit, import AVFoundation AVFoundation framework is needed even if you use AVPlayer If you want to use AVPlayerViewController: let videoURL = URL(string: “https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4”) let player = AVPlayer(url: videoURL!) let playerViewController = AVPlayerViewController() playerViewController.player = player self.present(playerViewController, animated: true) { playerViewController.player!.play() } or just AVPlayer: let videoURL = URL(string: “https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4”) … Read more

How do I export UIImage array as a movie?

Take a look at AVAssetWriter and the rest of the AVFoundation framework. The writer has an input of type AVAssetWriterInput, which in turn has a method called appendSampleBuffer: that lets you add individual frames to a video stream. Essentially you’ll have to: 1) Wire the writer: NSError *error = nil; AVAssetWriter *videoWriter = [[AVAssetWriter alloc] … Read more

How to play a sound using Swift?

Most preferably you might want to use AVFoundation. It provides all the essentials for working with audiovisual media. Update: Compatible with Swift 2, Swift 3 and Swift 4 as suggested by some of you in the comments. Swift 2.3 import AVFoundation var player: AVAudioPlayer? func playSound() { let url = NSBundle.mainBundle().URLForResource(“soundName”, withExtension: “mp3”)! do { … Read more

Making the iPhone vibrate

From “iPhone Tutorial: Better way to check capabilities of iOS devices”: There are two seemingly similar functions that take a parameter kSystemSoundID_Vibrate: 1) AudioServicesPlayAlertSound(kSystemSoundID_Vibrate); 2) AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); Both of the functions vibrate the iPhone. But, when you use the first function on devices that don’t support vibration, it plays a beep sound. The second function, on … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)