avfoundation

How to Play Audio in Background Swift?

帅比萌擦擦* 提交于 2019-12-27 10:40:07
问题 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 AVFoundation import MediaPlayer import GoogleMobileAds class ViewController: UIViewController, GADInterstitialDelegate { @IBOutlet weak var exitMapButton: UIButton! @IBOutlet weak var radarMap: UIWebView! var interstitial: GADInterstitial! func

Why is this mp3 file not streaming [duplicate]

岁酱吖の 提交于 2019-12-27 01:49:17
问题 This question already has answers here : Playing back audio using AVAudioPlayer iOS 7 (3 answers) Closed 4 years ago . I am attempting to play this mp3 file using `avPlayer` however I simply get silence when I attempt to play. I do not receive any errors and here is my code @IBAction func Test(sender: AnyObject) { println("Preparing to play") let urlString = "http://www.mp3juices.cc/get/3/194751031/x_ambassadors_-_renegades/" let url = NSURL(string: urlString) var avPlayer = AVPlayer(URL: url

How to convert ++ or — in Swift 3? [duplicate]

*爱你&永不变心* 提交于 2019-12-25 19:30:15
问题 This question already has answers here : ++ is deprecated it will be removed in swift 3 [closed] (2 answers) Closed 2 years ago . I have the following code I am trying to convert to Swift 3 and am getting this weird error "Cannot convert value of type Bool to expected argument type Int". The issue arises when I get rid of the "++". I am also linking to the stack overflow question I want to fully convert. Thanks! Here is the previous code and the code I tried to convert to: Previous code func

Getting byte Data from File

孤人 提交于 2019-12-25 14:39:10
问题 WHAT IM DOING I am trying to get an audio file (could be up to an hour long. eg. a Podcast) that I've recorded with AVAudioRecorder to be uploaded to our backend. In addition to being uploaded to the server it needs to be able to be "Paused" and "Resumed" if the user chooses. Because of this, I believe, I need to use dataWithBytesNoCopy:buffer on the NSData class to achieve this. WHERE IM AT I know for a fact I can get the data with using the passed self.mediaURL property: if (self.mediaURL)

AVPlayer & AVAudioSession

馋奶兔 提交于 2019-12-25 08:58:11
问题 I'm going insane with one issue when trying to stream audio from a radio service. I get it to run in the background fine, setting the required background mode in my .plist file. However, as soon as the audio is interrupted (or if i exit the application before the stream has successfully started) my application (i presume) is supended, as it no longer gives me feedback on e.g a change in connection. I'd like to accomplish this, so that i can manage stream quality etc even when the application

Capturing still image with AVFoundation

依然范特西╮ 提交于 2019-12-25 08:20:35
问题 I'm currently creating a simple application which uses AVFoundation to stream video into a UIImageView . To achieve this, I created an instance of AVCaptureSession() and an AVCaptureSessionPreset() : let input = try AVCaptureDeviceInput(device: device) print(input) if (captureSession.canAddInput(input)) { captureSession.addInput(input) if (captureSession.canAddOutput(sessionOutput)) { captureSession.addOutput(sessionOutput) previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)

AVAudioPlayer hiccups the app sometimes

五迷三道 提交于 2019-12-25 06:36:14
问题 I am working on a simple game and after every screen touch, an animation is happening on a small UIImageView and this happen very well and the app is running smoothly with CADisplayLink as the timer. I added an mp3 file to play after every touch with 1 second lengh as AVAudioPlayer imagine a sound like : Bip So the first time that I touch the screen first hiccup happens an the app freeze for less than a second that I can say it is ok coz it's the first time that the sound allocate memory. The

Loading and Playing Audio with avaudioplayer, UITableView NSURL

我们两清 提交于 2019-12-25 05:20:16
问题 I have a table view of audio objects, each with a url property. I'm looking for the fastest way (for the user) to play each audio file on touch. I tried getting the data first from the url: -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSURL *audioURL = [NSURL URLWithString:(NSString *)[[[self.objects objectAtIndex:indexPath.row] objectForKey:@"audioFile"] url]]; NSData *audioData = [NSData dataWithContentsOfURL:audioURL]; NSError *error; self

Obj. C - QR Reading application runs too slow

不羁岁月 提交于 2019-12-25 04:14:22
问题 I made an QR Code reading application with AVFoundation by tutorial on this site (tutorial of Appcoda). After reading QR code, the app shows an UIAlertView. But it takes nearly 2 minutes (sometimes more than 3mins). I'll paste the whole ViewController.m file here. I hope it is enough. (UIAlertView is in captureOutput method) // // ViewController.m // Yuvio // // Created by İhsan Batuğhan YILMAZ on 29/08/15. // Copyright © 2015 Farabius. All rights reserved. // #import "ViewController.h"

Query for optimal pixel format when capturing video on iOS?

允我心安 提交于 2019-12-25 03:55:39
问题 The AVFoundation Programming Guide states that the preferred pixel formats when capturing video are: for iPhone 4: kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange or kCVPixelFormatType_32BGRA for iPhone 3G: kCVPixelFormatType_422YpCbCr8 or kCVPixelFormatType_32BGRA (There are no recommendations [yet] for the iPhone 5 or for iPad devices with cameras.) There is however no help provided as to how I should go about and determine what device the app is currently running on. And what if the