Tag: audio

UILocalNotification声音不停止播放

我已经设置了一个自定义的.aif 30秒文件作为本地通知声音名称。 下面是我的调度本地通知的代码。 //Function to schedule local notification -(void)schedulelocalnotification:(NSDate *)particularfiredate ringtone: (NSString *)particularringtone name:(NSString *)alarmname info:(NSDictionary *)dicttext { UILocalNotification *notification = [[UILocalNotification alloc] init]; notification.fireDate = particularfiredate; notification.soundName = [arrayAIFFFiles objectAtIndex:[arraysoundfilesnames indexOfObject:particularringtone]]; notification.alertBody = alarmname; notification.userInfo = dicttext; [[UIApplication sharedApplication] scheduleLocalNotification:notification]; } 但是,当设备被locking,并且用户滑动通知进入应用程序时,即使用户进入应用程序,声音也会继续播放。 即使用户退出/卸载应用程序,它仍会继续播放。 请提出可能的原因。 – (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { [[NSUserDefaults standardUserDefaults] setValue:@"0" forKey:@"demo"]; […]

AudioFileSetProperty返回'kAudioFileUnsupportedPropertyError(pty?)'

编写audio文件的元数据时遇到困难: AudioFileID fileID = nil; AudioFileOpenURL((__bridge CFURLRef) url, kAudioFileReadWritePermission, 0, &fileID ); CFDictionaryRef piDict = nil; UInt32 piDataSize = sizeof(piDict); AudioFileGetProperty( fileID, kAudioFilePropertyInfoDictionary, &piDataSize, &piDict ); NSLog(@"%@", (__bridge NSDictionary *)piDict); NSMutableDictionary *dict = (__bridge NSMutableDictionary*)piDict; [dict setObject:@"NEW ALBUM NAME" forKey:@"album"]; piDict = (__bridge CFDictionaryRef)dict; piDataSize = sizeof(dict); OSStatus status = AudioFileSetProperty(fileID, kAudioFilePropertyInfoDictionary, piDataSize, &piDict); 第6行的NSLog为我提供了一个ID3信息的好字典。 […]

AudioQueue如何查找排队数据的播放长度

我正在使用AudioQueuestream一些歌曲,我的问题是我怎么能告诉已排队的缓冲区播放的长度? 我想一次stream两秒钟的数据,我遇到的问题是我怎么知道有多less字节实际上对应于两秒钟的音乐(所以我总是可以提前两秒钟)。 谢谢 丹尼尔

在我的应用程序中访问内置的iOS闹钟声音

我正在构build一个倒数计时器应用程序,并想知道我是否可以访问内置时钟应用程序中的声音剪辑列表,还是必须创build我自己的声音剪辑?

AVPlayer播放单声道audio立体声 – >单声道

在我的iPad / iPhone应用程序中,我使用AVPlayer播放video。 video文件有一个立体声音轨,但我只需要在单声道播放此音轨的一个通道。 部署目标是iOS 6.我怎样才能做到这一点? 非常感谢你的帮助。

核心audio:当一个数据包= 4个字节时,一个数据包如何能够=一个字节

我正在学习核心audio中的核心audio转换服务,我在他们的示例代码中被这个例子所震惊: while(1) { // wrap the destination buffer in an AudioBufferList AudioBufferList convertedData; convertedData.mNumberBuffers = 1; convertedData.mBuffers[0].mNumberChannels = mySettings->outputFormat.mChannelsPerFrame; convertedData.mBuffers[0].mDataByteSize = outputBufferSize; convertedData.mBuffers[0].mData = outputBuffer; UInt32 frameCount = packetsPerBuffer; // read from the extaudiofile CheckResult(ExtAudioFileRead(mySettings->inputFile, &frameCount, &convertedData), "Couldn't read from input file"); if (frameCount == 0) { printf ("done reading from file"); return; } // […]

如何在iOS应用程序中播放m3uaudiostream

我正在尝试使用Xcode 4.5.2创buildiOS / iPhone广播应用程序。 我想播放@“http://xx.xxxxxxx.com/8111/radio.m3u”播放,暂停,音量控制,并能够在后台function/多任务处理上播放。 AVFoundation ,我已经添加了AVFoundation , Mediaplayer和AudioToolBox框架。 我添加了play,暂停和滑块对象到xib。 ViewController.h @interface ViewController : UIViewController @property (strong,nonatomic) MPMoviePlayerController *myPlayer; @property (weak, nonatomic) IBOutlet UISlider *myslider; – (IBAction)playButtonPressed; – (IBAction)myslider:(id)sender; @end ViewController.m #import "ViewController.h" #import <MediaPlayer/MediaPlayer.h> @interface ViewController () { UISlider *volumeSlider; } @end @implementation ViewController – (void)viewDidLoad { [super viewDidLoad]; [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; UIBackgroundTaskIdentifier newTaskId […]

iOS Core Audio:在kAudioFormatFlagsCanonical和kAudioFormatFlagsAudioUnitCanonical之间转换

我需要在这个格式之间转换: format.mSampleRate = 44100.0; format.mFormatID = kAudioFormatLinearPCM; format.mFormatFlags = kAudioFormatFlagsCanonical | kLinearPCMFormatFlagIsNonInterleaved; format.mBytesPerPacket = sizeof(AudioUnitSampleType); format.mFramesPerPacket = 1; format.mBytesPerFrame = sizeof(AudioUnitSampleType); format.mChannelsPerFrame = 2 ; format.mBitsPerChannel = sizeof(AudioUnitSampleType)*8; 和这种格式 format.mSampleRate = 44100.0; format.mFormatID = kAudioFormatLinearPCM; format.mFormatFlags = kAudioFormatFlagsAudioUnitCanonical; format.mBytesPerPacket = sizeof(AudioUnitSampleType); format.mFramesPerPacket = 1; format.mBytesPerFrame = sizeof(AudioUnitSampleType); format.mChannelsPerFrame = 2; format.mBitsPerChannel = sizeof(AudioUnitSampleType)*8; 在audio呈现callback的范围内有下面的代码,buffer []是第二种格式,array […]

AVPlayerViewController使用纯audioAVPlayer

刚开始与AVKit,我想播放一些audio。 在Mastering Modern Media Playback中使用新的AVPlayerViewController会很好,所以我有一个现成的播放/暂停/searchUI。 我基本上有一个容器视图的故事板,有一个embedded到AVPlayerViewController的segue。 然后我使用: override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if (segue.identifier == "embedAudio") { var playerViewController:AVPlayerViewController = segue.destinationViewController as AVPlayerViewController playerViewController.player = AVPlayer(URL: NSURL(string: "http://dts.podtrac.com/redirect.mp3/files.serialpodcast.org/sites/default/files/podcast/1420057326/serial-s01-e01.mp3")) } } 它embedded很好,并播放,但它有一个大的黑色的QuickTime符号video将是。 我想知道是否有办法让它看起来更像音乐或播客应用程序。

在iOS背景模式下继续播放来自html5播放器的audio

我们使用Sencha touch在html5和javascript中构build了我们的面向音乐的应用程序。 为了分发,我们用UIwebView把它包装在Xcode中。 一切运行正常,除了一件事情没有奏效:以多任务模式播放audio。 我知道一般的想法:在info.plist中添加UIBackgroundModes。 完成。 现在我们甚至可以在后台模式下播放audio。 直到我们达到歌曲的结尾。 要开始下一首歌曲,我们必须再次将应用程序放在前台,或者我们可以点击iPhoneaudio控制器上的播放或“下一首歌曲”button。 经过一番研究,我发现了一个很有希望的解决方法:“ 在iOS4上播放背景以播放audio ”,其中解决方法是编辑AVAudioSessionCategoryPlayback并使用UIBackgroundTaskIdentifier。 对于我来说,问题就在于(就像我发现的其他解决scheme一样),这些解决scheme总是假定audio是用AVaudioPlayer或MPMusicPlayerController播放的。 但在我的情况下,我用户都没有,我们的audio是由UIwebView中包裹我们的HTML5播放器播放。 当audio播放器是html5 / javascript播放器时,任何人都有关于如何在iOS多任务模式下继续播放audio的build议?