alexbw/novocaine

Can't play an audio file that was downloaded from server but the data is the same

efimovdk opened this issue · 1 comments

Hello! I am enjoying your framework but have some problems with file reading. I use Novocaine to upload data to parse.com and then retrieve it back. I then can't play what was retrieved.

        PFQuery *q = [PFQuery queryWithClassName:@"Test"];
        [q getObjectInBackgroundWithId:audioId block:^(PFObject * _Nullable object, NSError * _Nullable error) {
            PFFile *file = object[@"file"];
            [file getDataInBackgroundWithBlock:^(NSData * _Nullable data, NSError * _Nullable error) {
                NSString *p = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:@"aha.m4a"];
                [data writeToFile:p atomically:YES];

                self.fileReader = [[AudioFileReader alloc]
                                   initWithAudioFileURL:[NSURL fileURLWithPath:p]
                                   samplingRate:self.audioManager.samplingRate
                                   numChannels:self.audioManager.numOutputChannels];

                [self.fileReader play];

                [self.audioManager setOutputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels)
                 {
                     [wself.fileReader retrieveFreshAudio:data numFrames:numFrames numChannels:numChannels];
                 }];
            }];

I am getting Error: Opening file URL (ExtAudioFileOpenURL) ('dta?'). I compared the data that was uploaded to the one that I downloaded and they are 100% equal. isEquatToData: just says that. What can be the problem? I called play on manager before this block so it doesn't matter.

It's unclear to me if this is an issue with Novocaine, or with the surrounding code. I'm going to close the issue, but if you can demonstrate it's an issue with Novocaine with a contained test case, I will reopen.