avaudioplayer

AVAudioPlayer returns success but no sound from device

本小妞迷上赌 提交于 2019-12-06 00:04:17
I have a very simple app that I have built to test out AVAudioPlayer. I have a 16s aif file that plays just fine on my Mac. Put it in a simple app and ran on my iPhone but no sound. Sending 'play' to the object returns success and audioPlayerDidFinishPlaying comes back with success after 16 seconds. Still no sound. Have checked the sound volume on the iPhone, just fine. Have checked to make sure my AVAudioPlayer object has volume set at 1.0 - it does. Can anybody help? Here's my code NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"Soothing" ofType:@"aif"]; NSURL *playURL =

How to lower the volume of music in swift?

点点圈 提交于 2019-12-05 23:42:22
问题 I am creating a SpriteKit Game with background music looping. The problem is that the music is too loud. How do I lower the volume? Here is the code I used to set up the music var backGroundMusic = AVAudioPlayer() var bgMusicUrl:NSURL = NSBundle.mainBundle().URLForResource("BackGround", withExtension: "wav") backGroundMusic = AVAudioPlayer(contentsOfURL:bgMusicUrl, error: nil) backGroundMusic.numberOfLoops = (-1) backGroundMusic.prepareToPlay() backGroundMusic.play() 回答1: Have you tried this?

iOS6 AVAudioPlayer - AAC audio file duration always return 0

烂漫一生 提交于 2019-12-05 23:07:40
I'm porting an app that works with aac audio files to iOS6 and I've found an strange behavior, when I try to get the duration of the (valid) aac audio file, it's always returns 0, in iOS4 and iOS5 it works fine. ¿Is there any bug on AvAudioPlayer class that affects duration property? I have read about some troubles with the currentTime property. Here's the code: NSURL* urlFichero = [NSURL fileURLWithPath:rutaFichero]; avaPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL: urlFichero error:nil]; segundos = avaPlayer.duration; NSLog(@"[ControladorFicheros] Fichero: '%@' Duración: '%f'",

How to cross fade between AVAudioPlayers

走远了吗. 提交于 2019-12-05 18:05:38
I want to use AVAudioPlayer and cross fade more than 2 mp3 files. I have 5 mp3 files and 5 pages "myScrollView" with UIScrollView class and pagingEnabled = YES. When user move page, I want to play each songs for each page with volume fade out for previous mp3 file and fade in for next mp3. Please help this problem. This is not cross fading operation. But, this can fade-in/out one at a time with new thread using NSOperation and fade-in/out effects can be added to the thread in any order. I found Linear fade Object MXAudioPlayerFadeOperation created by Andrew Mackenzie-Ross on 30/11/10. mackross

AVAudioEngine crashes when I unplug headphones during a call

霸气de小男生 提交于 2019-12-05 16:10:12
问题 Here is what I see in the log: 16:33:20.236: Call is Dialing 16:33:21.088: AVAudioSessionInterruptionNotification 16:33:21.450: AVAudioSessionRouteChangeNotification 16:33:21.450: ....change reason CategoryChange 16:33:21.539: AVAudioEngineConfigurationChangeNotification 16:33:21.542: Starting Audio Engine 16:33:23.863: AVAudioSessionRouteChangeNotification 16:33:23.863: ....change reason OldDeviceUnavailable 16:33:23.860 ERROR: [0x100a70000] AVAudioIONodeImpl.mm:317: __

iPhone - start multiple instances of AVAudioPlayer simultaneously

隐身守侯 提交于 2019-12-05 14:26:06
I am using multiple instances of AVAudioPlayer to play multiple audio files simultaneously. I run a loop to start playing the audio files (prepareToPlay is called beforehand and the loop only makes a call to the play method) But invariably, one of the players does not play in sync. How can I ensure that all the 4 players start playing audio simultaneously? Thanks. Unfortunately, you can't. AVAudioPlayer doesn't provide any mechanism for fine-grained control of start time. The currentTime property sets the point in the file to read from, it doesn't guarantee when the AVAudioPlayer instance will

Why do the Lock Screen audio controls disappear when I pause AVAudioPlayer?

青春壹個敷衍的年華 提交于 2019-12-05 13:24:47
问题 I'm using an instance of AVAudioPlayer to play an audio file. The app is configured to play audio in the background and an appropriate audio session is set. I am also successfully receiving remote control events. Here's the code: #import "ViewController.h" #import <AVFoundation/AVFoundation.h> @interface ViewController () @property (nonatomic) AVAudioPlayer *player; @end @implementation ViewController @synthesize player; - (BOOL)canBecomeFirstResponder { return YES; } - (void)viewDidLoad {

MPMediaItem not playing in AVAudioPlayer using MPMediaItemPropertyAssetURL

痴心易碎 提交于 2019-12-05 11:47:35
I have this code, to find and play a MPMediaItem: MPMediaPropertyPredicate *predicate = [MPMediaPropertyPredicate predicateWithValue:self.persistentIDOfSongToPlay forProperty:MPMediaItemPropertyPersistentID comparisonType:MPMediaPredicateComparisonContains]; NSSet *predicateSet = [NSSet setWithObject:predicate]; MPMediaQuery *searchQuery = [[MPMediaQuery alloc] initWithFilterPredicates:predicateSet]; NSArray *queryResults = [searchQuery items]; NSLog(@"count: %i", queryResults.count); MPMediaItem *item = [queryResults objectAtIndex:0]; NSLog(@"item: %@", item); NSURL *itemURL = [item

Playing audio file while recording video in iOS

风格不统一 提交于 2019-12-05 07:26:23
I want to play audio file while recording with camera. I used AVAudioPlayer for playing audio and AVCamCaptureManager for recording. But when audio starts to play, preview screen is freezing. What should i do? Thanks for your helping. Here is the code. (I'm working on AVCam example.) This is preview part. if ([self captureManager] == nil) { AVCamCaptureManager *manager = [[AVCamCaptureManager alloc] init]; [self setCaptureManager:manager]; [[self captureManager] setDelegate:self]; if ([[self captureManager] setupSession]) { AVCaptureVideoPreviewLayer *newCaptureVideoPreviewLayer = [

Two action methods for an UIButton; next track and seek forward:

≯℡__Kan透↙ 提交于 2019-12-05 06:43:07
问题 I am creating a music player application and it need that 2 actions to be called from a single button, one to skip to next track by touch up inside event and other to fast forward the curenttrack incase of a 'long press'. I don't know which event is pointing to this long press, i thought it to be touch down, but it worked only while holding the button. When i released the button, the track was skipped to next item. pls help AVAudioPlayer *appSoundPlayer;// declared in .h file In m file, the