avaudioplayer

AVAudioPlayer rate

老子叫甜甜 提交于 2019-12-19 03:12:20
问题 So I'm trying to play a sound file at a different rate in iOS 5.1.1, and am having absolutely no luck. So far I have tried setting the rate of the AVAudioPlayer: player = [[AVAudioPlayer alloc] initWithContentsOfURL:referenceURL error:&error]; player.enableRate = YES; player.rate = 1.5; player.numberOfLoops = 0; player.delegate = self; [player prepareToPlay]; [player play]; with no luck at all, the sound plays but just ignores the rate I give it. I have also tried AVPlayer: avPlayer = [

Start playing sound in background on iOS?

与世无争的帅哥 提交于 2019-12-18 17:26:35
问题 I'm trying to do something similar to Tile.app. When it shows a notification, it plays a sound. That seems simple enough-- use UILocalNotification and include the sound file name. But local notifications limit sounds to no more than 30 seconds, and Tile's sound keeps playing for a whole lot longer than that. I expect it's looping, and it continues until I can't stand the noise any more. The sound also plays even if the phone's mute switch is on, which doesn't happen with local notifications.

Trying to fix AVAudioPlayer lag on its initial use

不羁的心 提交于 2019-12-18 17:25:21
问题 This issue has shown up in several other question here on SO: Slow start for AVAudioPlayer the first time a sound is played Delay in playing sounds using AVAudioPlayer I've tried implementing the fixes suggested but none of them are solving my problem. My application presents the user with a grid of objects to touch, when an object is touched a sound is played. This works great except on the initial touch there is a delay of ~2 seconds. To get around this I initialize my audio player with a

AVAudioPlayer and AirPlay - possible?

谁说我不能喝 提交于 2019-12-18 16:57:27
问题 I'm trying to ascertain whether it's possible to toggle AirPlay support using the AVAudioPlayer class. From what I have read: AirPlay is a technology that lets your application stream audio to Apple TV and to third-party AirPlay speakers and receivers. AirPlay support is built in to the AV Foundation framework and the Core Audio family of frameworks. Any audio content you play using these frameworks is automatically made eligible for AirPlay distribution. Once the user chooses to play your

Detect ring/silent switch position change

谁说我不能喝 提交于 2019-12-18 13:01:48
问题 I'm working on an app for which I would like to: respect the ring/silent switch when playing audio, and display an icon indicating that sound is muted when the ring/silent switch is set to silent. Requirement 1 is easy: I'm using AVAudioSessionSoloAmbient as my app's audio session category, so that my audio session will mute itself when the ring/silent switch is off. Requirement 2 seems considerably harder, because I need some sort of callback, notification, or KVO that will allow me to

How to connect the audio to bluetooth when playing using AVPlayer

六月ゝ 毕业季﹏ 提交于 2019-12-18 13:01:27
问题 I am playing the audio from an url using AVPlayer, but when the iPhone is connected to a Bluetooth device it is not playing via Bluetooth, how to play via Bluetooth if it is connected, i see some posts in SO, but none of those are clearly explained. Below is my code. -(void)playselectedsong{ AVPlayer *player = [[AVPlayer alloc]initWithURL:[NSURL URLWithString:urlString]]; self.songPlayer = player; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerItemDidReachEnd:

MP3 playing using AVAudioPlayer not working on device

老子叫甜甜 提交于 2019-12-18 11:09:29
问题 I am testing my app on my 3GS iPhone with iOS 4.2 I am using the following code which plays a sound in my IBAction. It works perfectly in the simulator (both iPad and iPhone) - I hear the sound. NSString *pathToMusicFile1 = [[NSBundle mainBundle] pathForResource:@"alarm" ofType:@"mp3"]; NSError *error; alarmSound = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:pathToMusicFile1] error:&error]; NSLog(@"Song1 Loaded"); if (alarmSound == nil) { NSLog(@"Error playing sound");

detect up volume change swift

若如初见. 提交于 2019-12-18 06:55:11
问题 I'm having problems detecting when someone presses up or down volume button. For the moment I just play a file but I want to know when the user presses the button to show an alert when the volume changes. I'm developing in Swift and I'm using AVFoundation to create this player. For the moment I can't find something that works in Swift. I'm very new to this language. import UIKit import AVFoundation class ViewController: UIViewController { var backgroundMusicPlayer = AVAudioPlayer() override

AVAudioSession Swift

拟墨画扇 提交于 2019-12-18 05:54:38
问题 I am trying to write a swift iOS app that will record the users voice. I have wrote the following code in swift however it fails to request mic permissions from the user. It prints granted yet it never records audio and in the settings pane under privacy it does not list the app. How do I request recording permissions in swift? var session: AVAudioSession = AVAudioSession.sharedInstance() session.requestRecordPermission({(granted: Bool)-> Void in if granted { println(" granted") session

AVAudioPlayer Memory Leak - Media Player Framework

我的梦境 提交于 2019-12-18 05:11:36
问题 I am using AVAudioPlayer object to play an audio. I created an audioPlayer object initially. I play an animation and when ever animation starts I play the audio and pause the audio when the animation is finished. I initially found three memory Leaks using Instruments. (The responsible caller mentioned was RegisterEmbedCodecs). After suggestion from a "ahmet emrah" in this forum to add MediaPlayer framework, the number of leaks reduced to one. And is there any way to completely get rid of it?