1

This code plays the sound:

NSSound *sound = [[NSSound alloc] initWithContentsOfFile:@"/Users/alex/test.ogg"
                                            byReference:NO];
[sound play];

This code does not:

NSData *song = [testingResultsData objectAtIndex:0];
[song writeToFile:@"/Users/alex/test.ogg" atomically:YES];
NSSound *sound = [[NSSound alloc] initWithData:song];
[sound play];

It is the same content in both cases; the only difference is whether it is taken from a file on disk or directly from NSData.

jscs
  • 63,694
  • 13
  • 151
  • 195
Alex
  • 393
  • 6
  • 21
  • 3
    Please some more information. What does not play fine? And what is _testingResultsData_? – Erik S Apr 07 '11 at 22:20
  • How exactly did you check whether `song` does contain the same bytes as /Users/alex/test.ogg? –  Apr 08 '11 at 07:52
  • as u seen, i'm save NSData song at disk. Later, if i using it as initOfContensOfFile, everything work fine/ – Alex Apr 08 '11 at 07:54
  • What is song? Almost likely it's not valid, thus why you get the error. – JohnBrighton Aug 24 '11 at 19:50

0 Answers0