avfoundation

Xcode 8 Swift 3 Pitch-altering sounds

寵の児 提交于 2019-12-07 14:52:31
问题 So, I asked this question before on the Apple Developer Forums but never got a proper answer, so I thought I'd ask it here: I'm trying to make a simple game with a hit sound that has a different pitch whenever you hit something. I thought it'd be simple, but it ended up with a whole lot of stuff (most of which I completely copied from someone else): func hitSound(value: Float) { let audioPlayerNode = AVAudioPlayerNode() audioPlayerNode.stop() engine.stop() // This is an AVAudioEngine defined

How do I loop a video with AVFoundation without unwanted pauses at the end?

巧了我就是萌 提交于 2019-12-07 14:43:55
问题 I am trying to play a video clip that loops indefinitely. I am doing this the way Apple recommends; by setting up a notification that gets triggered by AVPlayerItemDidPlayToEndTimeNotification: @property(nonatomic) AVPlayer *videoPlayer; @property(nonatomic) AVPlayerItem *videoPlayerItem; -(void)loadVideo { NSURL *url = [[NSBundle mainBundle] URLForResource:filename withExtension:extension]; AVURLAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil]; NSString *tracksKey = @"tracks";

Crash when toggling access to Camera and Photos [duplicate]

落花浮王杯 提交于 2019-12-07 14:32:48
问题 This question already has answers here : App crashed in iOS 6 when user changes Contacts access permissions (2 answers) Closed 4 years ago . I have a collection view (standard flow layout) where the first cell is displaying a live camera feed, and the rest of the cells are displaying photos from the user's library using iOS 8's new Photos Framework. Everything renders and works great. When opening for the first time, I'm prompted for access to the Camera and to the Photos library, as expected

how to use AVAssetWriter to write h264 strem into video?

孤人 提交于 2019-12-07 14:29:41
问题 I want to make the h.264 stream from server to a video file, but when I used assetwrite.finishwrite , the XCode reports Video /var/mobile/Applications/DE4196F1-BB77-4B7D-8C20-7A5D6223C64D/Documents/test.mov cannot be saved to the saved photos album: Error Domain=NSOSStatusErrorDomain Code=-12847 "This movie format is not supported." UserInfo=0x5334830 {NSLocalizedDescription=This movie format is not supported.}" Below is my code: data is the h.264 frame, just one frame, it might be i frame or

Getting Current Time of a Video (Player - Swift)

橙三吉。 提交于 2019-12-07 14:20:04
问题 I set up a video player using Player (using AVFoundation). I am trying to access and manipulate currentTime of the video however, the library is only providing duration of the video but not currentTime. I am tweaking the demo project of Player. Please check 'Updated' section below instead of here: A friend told me I can achieve using that approach, but I couldn't really get how to adapt this approach in this case. [NSTimer scheduledTimerWithInterval:1.0 target:self selector:@selector

AVCaptureDevice doesnt find any device

谁说我不能喝 提交于 2019-12-07 13:31:09
问题 This line of code is the problem I got today (macOS app): NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]; After I update Xcode, the system is alway got me empty devices array. The thing is, the old projects(created before the update) work as expected. What's going on here...? Does anyone has the same problem? ------------UPDATE------------ I found this not just happened to my mac, also on the company's. And it does affect my work. 回答1: I think I found the answer...

Set maximum recording duration,while video recording from iphone app

烂漫一生 提交于 2019-12-07 13:31:04
问题 In my iPhone app,a user can record the video.I want to set the maximum allowed time of recording is to 30seconds.How to do that,any ideas ? using this code -(BOOL)startCameraControllerFromViewController:(UIViewController*)controller usingDelegate:(id )delegate { if (([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == NO) || (delegate == nil) || (controller == nil)) { return NO; } UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init]

Swift 3 : How to export video with text using AVVideoComposition

一曲冷凌霜 提交于 2019-12-07 12:41:46
问题 I am trying to use AVVideoComposition to add some text on top of a video and save the video. This is the code I use: I Create an AVMutableComposition and AVVideoComposition var mutableComp = AVMutableComposition() var mutableVidComp = AVMutableVideoComposition() var compositionSize : CGSize? func configureAsset(){ let options = [AVURLAssetPreferPreciseDurationAndTimingKey : "true"] let videoAsset = AVURLAsset(url: Bundle.main.url(forResource: "Car", withExtension: "mp4")! , options : options)

AVAudioEngine inputNode's format changes when playing an AVAudioPlayerNode

我只是一个虾纸丫 提交于 2019-12-07 11:17:48
问题 I'll start with a simple "playground" view controller class I've made that demonstrates my problem: class AudioEnginePlaygroundViewController: UIViewController { private var audioEngine: AVAudioEngine! private var micTapped = false override func viewDidLoad() { super.viewDidLoad() configureAudioSession() audioEngine = AVAudioEngine() } @IBAction func toggleMicTap(_ sender: Any) { guard let mic = audioEngine.inputNode else { return } if micTapped { mic.removeTap(onBus: 0) micTapped = false

AVCaptureTorchModeAuto does not continuously update torch mode

江枫思渺然 提交于 2019-12-07 09:45:54
问题 I am writing an app that automatically turns on the torch on the back of an iOS device depending on lighting conditions. The app renders a live camera view, and does not record the video. I have tried using AVCaptureTorchModeAuto , but it only seems to measure the brightness of the image at the start of the capture session, and set the torch accordingly. The setting then does not change afterwards, regardless of the brightness of the camera image. It is possible to have the system adjust the