avfoundation

AVPlayer stops playing and doesn't resume again

狂风中的少年 提交于 2019-12-17 17:25:49
问题 In my application I have to play audio files stored on a web server. I'm using AVPlayer for it. I have all the play/pause controls and all delegates and observers there which work perfectly fine. On playing small audio files everything works great. When a long audio file is played it also starts playing fine but after some seconds the AVPlayer pauses the playing (most probably to buffer it). The issue is it doesn't resume on its own again. It keeps in a pause state and if I manually press the

AVAssetExportSession export fails non-deterministically with error: “Operation Stopped, NSLocalizedFailureReason=The video could not be composed.”

為{幸葍}努か 提交于 2019-12-17 15:57:06
问题 We add subtitles to a video recorded by the user, but the export by our AVAssetExportSession object fails non-deterministically: sometimes it works, and sometimes it doesn't. It's unclear even how to reproduce the error. We noticed the asset tracks seem to get lost during export. Before exporting, there are two tracks (one for audio, one for video) as expected. But checking the number of tracks for the same file URL in exportDidFinish shows 0 tracks. So something seems wrong with the export

Set front-facing camera in Xcode

倾然丶 夕夏残阳落幕 提交于 2019-12-17 15:44:23
问题 Set front-facing camera in Xcode. How can I do that? Set front-facing camera in Xcode. AVCaptureSession *session = [AVCaptureSession new]; if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) [session setSessionPreset:AVCaptureSessionPreset640x480]; else [session setSessionPreset:AVCaptureSessionPresetPhoto]; AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; AVCaptureDeviceInput *deviceInput = [AVCaptureDeviceInput

Get AVAudioPlayer to play multiple sounds at a time

只谈情不闲聊 提交于 2019-12-17 15:37:36
问题 I'm trying to get multiple sounds files to play on an AVAudioPlayer instance, however when one sound plays, the other stops. I can't get more than one sound to play at a time. Here is my code: import AVFoundation class GSAudio{ static var instance: GSAudio! var soundFileNameURL: NSURL = NSURL() var soundFileName = "" var soundPlay = AVAudioPlayer() func playSound (soundFile: String){ GSAudio.instance = self soundFileName = soundFile soundFileNameURL = NSURL(fileURLWithPath: NSBundle

Using existing system sounds in iOS App [swift|

感情迁移 提交于 2019-12-17 15:32:45
问题 Is it possible to use the existing Apple system sounds in my own app? I would like to write a sample app in Swift that does the following steps: Read/Get a list of all available systemSounds on the device (I think they are located in /System/Library/Audio/UISounds/ ) show the list on the screen if I touch a list item, play these sound So its basically the same, like when you choose a new ringtone on your iPhone. I think some apps are using this sounds, or have they copied/bought it? Thanks

Playing many different videos on iphone using AVPlayer

雨燕双飞 提交于 2019-12-17 10:47:38
问题 I'm working on a custom video player for iOS using AVFoundation. The idea is to be able to switch to a different video with a gesture (tap, swipe, whatever). Right now the player is working flawlessly on simulator , but when I test it on an actual device, the view goes blank after 3 or 4 swipes. I've even created playback controls for my player, when the view goes blank, these controls load correctly but do nothing. Any ideas guys? This is the initialization for the player - (id

How can I know users click fast forward and fast rewind buttons on the playback controls in iPhone

我的梦境 提交于 2019-12-17 10:33:20
问题 I want to implement the following things, App is running a music or video (using MPMoviePlayerController ) in background. User double clicks the home button and go to the first screen showing playback controls (fast rewind, play or pause, fast forward buttons) User click fast rewind or fast forward button. Then app play previous or next music or video. For the 3rd step, I should know which button is clicked. (As I naturally know, the currently playing item is paused, stopped.. using

How can I know users click fast forward and fast rewind buttons on the playback controls in iPhone

情到浓时终转凉″ 提交于 2019-12-17 10:33:10
问题 I want to implement the following things, App is running a music or video (using MPMoviePlayerController ) in background. User double clicks the home button and go to the first screen showing playback controls (fast rewind, play or pause, fast forward buttons) User click fast rewind or fast forward button. Then app play previous or next music or video. For the 3rd step, I should know which button is clicked. (As I naturally know, the currently playing item is paused, stopped.. using

Add a Watermark on Video after merging Video and Audio Asset into one in Swift3 iOS

为君一笑 提交于 2019-12-17 10:14:13
问题 I am working on Video based application in Swift3 . As per my requirement I have to merge Video and Audio AVAsset into one, adjust their volumes separately and save the final Video in iPhone Device gallery . This is working fine using below code: func mergeVideoAndMusicWithVolume(assetVideo: AVAsset, assetMusic: AVAsset, startAudioTime: Float64, volumeVideo: Float, volumeAudio: Float){ //To merging a video and a music and set it a volume let dirPaths = NSSearchPathForDirectoriesInDomains(

How to turn a CVPixelBuffer into a UIImage?

流过昼夜 提交于 2019-12-17 07:07:22
问题 I'm having some problems getting a UIIMage from a CVPixelBuffer. This is what I am trying: CVPixelBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(imageDataSampleBuffer); CFDictionaryRef attachments = CMCopyDictionaryOfAttachments(kCFAllocatorDefault, imageDataSampleBuffer, kCMAttachmentMode_ShouldPropagate); CIImage *ciImage = [[CIImage alloc] initWithCVPixelBuffer:pixelBuffer options:(NSDictionary *)attachments]; if (attachments) CFRelease(attachments); size_t width =