小编Alo*_*nha的帖子

如何使用AvAudiorecorder将音频录制为mp3文件

如何使用AvAudiorecorder.im将音频录制为mp3文件,使用以下代码进行录音机设置

recordSetting1 =  [NSDictionary dictionaryWithObjectsAndKeys:
                  [NSNumber numberWithInt:AVAudioQualityMin],AVEncoderAudioQualityKey,
                  [NSNumber numberWithInt:16], 
                   AVEncoderBitRateKey,
                   [NSNumber numberWithInt: 2], 
                   AVNumberOfChannelsKey,
                   [NSNumber numberWithFloat:44100.0], 
                   AVSampleRateKey,nil];
Run Code Online (Sandbox Code Playgroud)

iphone record avaudiorecorder

7
推荐指数
2
解决办法
1万
查看次数

下载多个文件使用NSURLSession并在后台状态下保持其进度

我已经使用NSURLSession下载单个文件,它工作正常,现在我必须在后台下载三个文件,还必须管理他们在UIProgress中的进度.我的下载单个代码的代码如下.

- (IBAction)startBackground:(id)sender 
{
    // Image CreativeCommons courtesy of flickr.com/charliematters
    NSString *url = @"http://farm3.staticflickr.com/2831/9823890176_82b4165653_b_d.jpg";
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
    self.backgroundTask = [self.backgroundSession downloadTaskWithRequest:request];
    [self setDownloadButtonsAsEnabled:NO];
    self.imageView.hidden = YES;
    // Start the download
    [self.backgroundTask resume];
}

- (NSURLSession *)backgroundSession
{
    static NSURLSession *backgroundSession = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        NSURLSessionConfiguration *config = [NSURLSessionConfiguration backgroundSessionConfiguration:@"com.shinobicontrols.BackgroundDownload.BackgroundSession"];
        backgroundSession = [NSURLSession sessionWithConfiguration:config delegate:self delegateQueue:nil];
    });
    return backgroundSession;
}

#pragma mark - NSURLSessionDownloadDelegate methods
- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didWriteData:(int64_t)bytesWritten totalBytesWritten:(int64_t)totalBytesWritten totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite
{
    double …
Run Code Online (Sandbox Code Playgroud)

nsurlconnection ios ios7 nsurlsession

7
推荐指数
1
解决办法
6428
查看次数

录制声音并以改变的音高播放

我必须实现一个iphone应用程序,它将在你开始讲话时记录用户的声音,并改变录制声音的音高并播放.我能够在AVAudiorecorder的帮助下录制声音检测音频,并使用Dirac库我改变了录制声音的音高.这种方法的问题是输出声音足够嘈杂.我得到了使用SoundEngine的响应,但我没有得到实现它的方法.任何人都可以解释一下其他任何实现方法吗?

my code//
        -(void)initialSetup
    { 
        count=0; 
        silenceTime=0;

    //[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error: nil];
    recordSetting = [[NSMutableDictionary alloc] init];
    [recordSetting setValue:[NSNumber numberWithInt:kAudioFormatAppleLossless] forKey:AVFormatIDKey];
    [recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey]; 
    [recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];
    recordedTmpFile = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat: @"%.0f.%@",[NSDate timeIntervalSinceReferenceDate]*1000.0,                  @"caf"]]];
    recorder = [[ AVAudioRecorder alloc] initWithURL:recordedTmpFile settings:recordSetting error:&error];
    //recorder = [[ AVAudioRecorder alloc] init];
    [recorder setDelegate:self];
    [recorder updateMeters];
    [recorder prepareToRecord];
    //[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayAndRecord error: nil];
    //In Order To Move Sound To The Speaker
    //UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
    //AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof(audioRouteOverride),&audioRouteOverride);

    NSArray …
Run Code Online (Sandbox Code Playgroud)

iphone ios

5
推荐指数
0
解决办法
3588
查看次数

在iOS中删除单元格时UICollectionView的动画时间

我正在使用集合视图,我第一次需要删除click.which正在为我工​​作的集合视图的单元格.但我正在努力与UIcollectionview的动画时间.它总是一样的.我怎么能增加删除单元格时减少动画时间.我也将该代码放在uianimation块中,但它不起作用.这是我的删除代码,任何建议将非常感谢,谢谢.

  [self.collectionView performBatchUpdates:^{
  NSArray* itemPaths = [self.collectionView indexPathsForSelectedItems];
  // Delete the items from the data source.
  [self deleteItemsFromDataSourceAtIndexPaths:itemPaths];
  // Now delete the items from the collection view.
  [self.collectionView deleteItemsAtIndexPaths:tempArray
  } completion:nil];  
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ios uicollectionview

4
推荐指数
1
解决办法
4751
查看次数

Singleton类静态变量每次设置为nil

我正在制作一个单身课程供我使用.我见过单例类的代码是这样的:

//First Example

+ (id)sharedManager {
    static MyManager *sharedMyManager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sharedMyManager = [[self alloc] init];
     });
    return sharedMyManager;
 }


 //Second Example

static SingletonSample *sharedObject;

+ (SingletonSample*)sharedInstance {
    if (sharedObject == nil) {
        sharedObject = [[super allocWithZone:NULL] init];
    }
    return sharedObject;
}
Run Code Online (Sandbox Code Playgroud)

秒似乎很好,可以理解.但我很困惑在第一个例子中,每次将sharedMyManager设置为nil并且每次都有一个共享管理器的分配,我怀疑的是第一个例子将如何返回类的相同引用(Singleton).

谢谢.

shared objective-c grand-central-dispatch ios

2
推荐指数
1
解决办法
1630
查看次数

想要在应用程序进入后台时保持AVPlayer播放

我必须使用avplayer播放mp3文件,但是当我去背景时它会停止,我如何保持它在背景状态下播放.任何建议都将受到高度赞赏.谢谢.

iphone xcode4 avaudiosession avplayer ios7

1
推荐指数
2
解决办法
4627
查看次数