我
下载.mp3文件并将其存储在我的文档文件夹中
使用AVAudioPlayer我正在播放音频文件。
我将文件路径导入NSData(audioData)并将其链接到AudioPlayer
NSError* error = nil;
self.audioPlayer = [[AVAudioPlayer alloc]initWithData:audioData error:&error];
if (error)
{
NSLog(@"Error with initWithData: %@", [error localizedDescription]);
}
打印“操作无法完成。(OSStatus错误2003334207。)”
我想检查下载的文件是否是有效文件,我用VLC播放它并且效果很好。
如果我记录NSData,那就是..
Printing description of audioData:
<00000018 66747970 33677034 00000000 69736f6d 33677034 00000275 6d6f6f76 0000006c 6d766864 00000000 538580d9 538580d9 000003e8 00000884 00010000 01000000 00000000 00000000 00010000 00000000 00000000 00000000 00010000 00000000 00000000 00000000 40000000 00000000 00000000 00000000 00000000 00000000 00000000 00000002 00000201 7472616b 0000005c 746b6864 00000007 538580d9 538580d9 00000001 00000000 00000884 00000000 00000000 00000000 01000000 00010000 00000000 00000000 00000000 00010000 00000000 00000000 00000000 40000000 00000000 00000000 0000019d 6d646961 00000020 6d646864 00000000 538580d9 538580d9 00001f40 00004420 00000000 0000002c 68646c72 00000000 00000000 736f756e 00000000 00000000 00000000 536f756e 6448616e 646c6500 00000149 6d696e66 00000010 736d6864 00000000 00000000 00000024 64696e66 0000001c 64726566 00000000 00000001 0000000c 75726c20 00000001 0000010d 7374626c 00000045 73747364 00000000 00000001 00000035 73616d72 00000000 00000001 00000000 00000000 00010010 00000000 1f400000 00000011 64616d72 20202000 0083ff00 01000000 20737474 73000000 00000000 02000000 01000000 a0000000 6c000000 a0000000 14737473 7a000000 00000000 20000000 6d000000 34737473 63000000 00000000 03000000 01000000 08000000 01000000 02000000 06000000 01000000 12000000 05000000 01000000 58737463 6f000000 00000000 1200000c 2000000d 2000000d e000000e a000000f 60000010 20000010 e0000011 a0000012 60000013 20000013 e0000014 a0000015 60000016 20000016 e0000017 a0000018 60000019 20000009 8b667265 65000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000da8 6d646174 3cde401f 4c6c5181 acef679a c4075476 c0000669 7ee23418 00001e5a c9f2f3c0 3c286627 1c39a807 2f16d912 786b5d5a 53b0194c 3494b830 4cc3dcb8 aae32110 3cde3a21 1bba0601 af113fd7 2e1b2985 05b9a045 baa561eb 6883d911 360ae780 3c285c35 25e7da01 fe02fb24 e49beac7 213e2578 c63c9ca5 a6ce213f abbbc320 3c204191 187f481c 1689d954 bf53f0ec 542ecb9b d4560cdd a85f42c0 0ecba260 3c425d76 1cdf0005 3a4477f4 cb44695b 57ab984a 1e15a211 072341d8 8d41f9d0 3c223f8b 276c4e0d 1e1092bb 15310464 e46736c2 e9fd193c 58a15569 8f57e790 3c525e1a 4a6ef203 de012b04 e9b3c7ac 7c5ef5e4 c6bd7c70 352cd591 46fb5840 3c38457b 151c8810 9c324aa5 b75d2db7 6fe16b80 52e7a498 3a9e269a cd4cd0c0 3ce05417 4d78a20d 3e10bb24 33d0e94f 9efbd665 d67d7b9e 34a12248 51a45140 3c3a417d 4dd0120b 3e00d7f5 747df235 50f54432 b0d000c4 bafd0e3c 4380ad70 3c205c1a 247fac0d 3e1129f5 32f9512b ac2ae8e2 bb502b8f 15546017 fa7fdf10 3c3e439f 493d3030 9c2ac407 b1c83ecd 23e7b5ad 2d3ea59c c9ecb140 16358040 3ce04d8b 1dd4a21e 1e008b34 0e75ad66 9f44bfc8 e35ced0f cf46f677 158177d0 3c424c21 5aedac05 be094424 21d7289c 3ed6b073 dc449970 a676a822 3b4e8f60 3ce0421c 1e665609 7e0191b4 6647a1dd b1fc1a93 1d69d77c 25bd0f97 545a1a70 3c48557a 2ff2e201 fe018a28 2abe4a72 3da30439 d8fd48ef 0240041b 6435db50 3c0a421d 507eec14 7e10d5c2 d69b9cde fbedb15b 45fa3e06 41287d74 d884d8d0 3c604d80 1dd79825 5e01a137 dd661c1e 491b1ec3 ad4b1472 36b84a90 63a252d0 3ce04835 518c520a 5e11699d c03d7c8a 31cac756 184242e4 b5c2c1ca 53b49980 3c346560 3188960d 5e018926 dd7d35fb 24da17ec ba435f70 f416f8f7 cf876fe0 3cd84d9b 52fd8f00 fe01d1ca ab4681cb 308c7a68 5a030a0a bcab1fe7 d4bc9720 3c445393 213f8a41 fe009c43 aa1d75b8 aae800a9 9e64e2a2 b3057b0e 834583f0 3c424d9f 19515401 bc234dda 93bbf57d 0d63783b c69acfe2 4f337f22 43a059d0 3c1edad6 42effc11 7e12fe11 e255ad45 9eec201c 53980fe1 062cf710 e844b420 3ce05383 107e0205 3e05cf8c f0d653b2 7c8fd687 c1e3e7ee 2d0abb4f c76849a0 3c443e69 42f9ec14 5e03a093 bcad6243 efdab30a 0b8de922 3ec8ec86 73a0ba70 3c44657b 1ba4d213 de017ebc 57fcd5a1 07322702 675f48ca 5df324fb 1659aa90 3c5454d6 18de4604 3e1172d6 f30b1bf5 73ac6a25 ca6a31cd fd31fd13 6b257880 3c166464 7ebd0012 9e01d0c4 3b42de37 36f0a42c 1f9ea890 5b994eca 4442d780 3c56421d 19a6d809 7e1092d5 234340b0 5bf29fdf daee1847 a4478c04 dbd85200 3ce0641d 26de002d be05a335 29daf067 324879b4 1d79de3f ba80feb7 847c0470 3cd85420 1a7f4603 de02c545 7d6465b3 44f70c26 03188e7c 82fc886a ac6dfe60 3c2e5380 22a97400 5e012a14 d770a755 cfee5e2d 0d483783 aa8e9ac4 33317340 3c44721b 1fd16a0d 3e133a84 1e615294 1e3d0c09 beb86664 21ee75d6 8a510e80 3c346223 17feea09 5e0297c5 7aa676da d1940401 930d2d80 7047a925 f49cb320 3c425a5d 431d4603 1e078042 e53c850c 55bc981a 792afe78 b71bbe6c e301bf10 3c44661c 1f5c821c 3e052994 c575165c 2f0ebcf6 8bb7793d 365657ba 62004cf0 3c38a979 56f88211 be124ee4 b277c8a5 6b3a79c1 56741817 e582f70d 189ceb10 3ce06217 1c9c9e1d 3e1962b3 13ca57c6 1ec81c2b a3c0845a 305b3c1d 62f95c70 3c386d7b 193e2603 1e0590b4 296b6f91 48313e52 b50c1044 25bd6848 ed787b80 3ce05391 216b0c05 be152db5 80be358f 8d1383f5 f7b0e52f bd714b72 01dd7d30 3c425a29 199f1089 5e08d434 d18fa47b 8d18f42c 562b7ef3 19809f94 f2c542e0 3c205d96 15c7c61a 7e002665 a79368c7 4b0ae78b 5dad3942 4b9db331 4c8443f0 3c42b824 19262810 de116146 53f15914 ea0ec83e 6e7dd997 50ca4e33 290b7f70 3c285621 42d20803 de015ec5 0c501fa5 70ac3d2f c3342106 25170e67 beafdfc0 3c52437b 16f62d11 fa566d65 0a753183 7a360f68 599c92f0 8500b33c 8dbe3e40 3c424225 24d36c18 7a45cb33 0b03fbd9 e5d8c2e5 404c0d5b d030e22e b543ce50 3cd8537b 19c0781d be0497bb f8711bdd 72be34c8 3c4e543c 9c698a07 512f7080 3c426c1c 21d15603 de043ca6 085d902b 5377cfb6 42f96e9d 611e3a01 00aa3390 3c1a5580 17a90c13 be010fe4 33e6c515 02b9c7ca b123f6fe 48a4ba27 826230b0 3c405227 35808100 de105984 75508691 e3cfa4ea 5773bf0c c0e01c29 08a2b5a0 3c203e1d 50d28609 5e01ee64 1ee6309d 44ddba97 acd11a05 d4bf4cd3 8063e7c0 3c526388 29d5cc02 b68da3f5 cf6206d6 a3d5ede4 74227740 8786dbe5 3b6a8780 3c223e1d 1af7f216 9e026d55 48e42513 a6ae3b7e f362b8cc 4807f695 647dbd00 3c54538a 46b39401 f6985865 0724275d 52f136b4 fabcccc8 8ba8d6ba ec36f5c0 3c203864 1e4b7014 3e018f23 7355d4e9 5dbc76d6 ba20e429 21b28db6 34849060 3c446588 460d9200 be01d3ba fd408c45 0b11e5bc 4e46c941 7f8fb2b9 1bcc47b0 3c4c4178 318a5e31 de019902 fb8b40a4 58a34477 e4f3812a e0798c20 4208b940 3c083f88 4878aa1a 7a4d9177 171c2430 3ddab137 2ecc295a b621ecd9 3e4543b0 3c464024 57f39703 1e1066b5 c1099c4f b7068fdb 9b2bc1c2 02d90770 9653b0e0 3ce05588 193ec60c 36992e3a 9792dc9e f466c9d1 11402c8a 61e19215 23384690 3c504069 4fbc0c10 cb5f8944 5ac5fe70 a90c95ba 8bf1d39f 7a3d1386 497a4460 3c224a26 290fd450 1e052909 4151a891 1a618ecb ae9b7fa7 d1862863 03e16de0 3c425a1d 51d17614 968c6744 7cb4e533 23b9f1d2 294f6502 1476950e 60012bf0 3c53ccb6 d1a6739d 9f8c9fb4 ec5b8d5f f7fa9b6f 08802da9 e63baed5 00951100 3c440879 19e75a00 1e1a2ab4 f2591baf 0fffd415 680ff995 1b5919cd 1b2d5f10 3c4cfba1 a2f8a800 7e0035d3 9fa0091e 7b4cc6b4 293c5bb7 2ca2109b c03d5450 3c201d8c 25d1425c 769c42c5 06ca9344 5e818a9e 772cdefb 5a472763 f7b85190 3cde6971 93848701 7c229dc8 cf77730b 59368657 2da1eb7f 0b148c57 91b861b0 3c283e23 55cf0c07 de119407 15fe8c4b 6ccc377c 6263b194 087acb0a 6a900d90 3c425582 37f3ea24 3e00ef2b cfa007ed f7d3ad10 1308b415 6314a85a 7faf1320 3c344a1f 5af4240b 1c267db8 a9a2dd1d 73a98054 0de8282b e4893c1f f69ca7f0 3c6e4d7b 3fbe440d 3e03862b 9d0ba23f c694131c 1fd648d2 42fab456 d899d920 3c4e4a1d 5550a21c 3e005e56 02cdfe15 aa23bbea cbaafc50 3de68059 5b1a8fb0 3c1a4199 27dc948d 3e000fec 19e093bc 7cde16d5 3c5c5488 d4c45008 238615e0 3c525e25 574d7640 f688d915 afd76f07 bbdfd606 ce0f4ee4 1705b771 3add88c0 3c2c4b90 1dece281 7e013b94 43e5e591 0eeebc1a 94f3f1f5 55ba3ff8 30aa4a40 3c9865a1 192e2e12 7a4576b4 7666b529 0d5fa327 01781568 4ad86552 7069c580 3c184c17 4e67100a 1a564bfa b62528ed db972ea2 8f04a354 9b8d4edb 27afc100 3c50557b 21921e10 fa46e136 5e212dbd 9655d2c5 0f1ad00e 30a49f43 e2346490 3c084415 38d58203 da472657 34b8c7ae b714d9d7 fa014a73 8e97084a 3a67e120 3c485e2d 1f786607 9c276bd8 99e85499 64dd3d73 59165200 50cea61a 20af5c70 3c28501c 85421409 5c367a44 55d01bf5 288180f6 1f12ebe5 5ffab69a 6fad0f40 3c5fbb0d a0dd4ca2 be3f4a66 bf492199 97211db1 2fb3b790 ab77863f 24fa69d0 3c444067 90d91e00 479ffcc4 d6d1e517 215d9f78 dbae7f90 013a8ab8 eb7eb540 3c305590 2c78ae05 5e0323c5 7050e9b3 8c1d8797 cdc95783 a64ede58 a84dcf10 3cde4e5d 4b645222 1699c67c f5017456 0dc9aa05 273ae27c 0ce43b56 f9307870 3c305e1a 2fb36610 fa571126 36200758 4d28dba5 8a3cb7f0 4d6f3683 7a6e3a30 3cde442c 4ff8a614 969c43fb d441566f 567c10db e272bdc7 94459fa2 eb7b9ad0 3c38521d 43a61212 de0027b8 9c63d946 6f948d5e cc186d00 8829bc8e 13db9dd0 3ce05574 1f6d1e18 7e11b338 09370fea 1f845fdb ec5c6508 c0f4a973 206bb470 3c464183 4fd1a412 de10c074 53401bdc ef93b5b5 65f770f2 26f0283d 6d90bbc0 3c324c1c 14d26e12 de02d3c8 f226daa1 29acb7a3 f7f1236e 4150b067 51602890 3c3a5428 53e7f212 7e01c0d2 c38e9751 4fabb69e e2d41cdc 592baf79 24d57400 3c423f95 28d80e0c be013a78 86d3a498 f9cfa07a 9130877d 8351d475 8de6a580 3c48638b 5fa8a401 be112ff3 f35c110d 84a869a8 9ee1d2f0 cd4a1c05 2444da60 3c442220 22777c12 da4608a6 9e943054 a2068d61 a4e33c89 de764da1 175272b0 3c3e5c20 13f4ea0a de00cb57 891d5915 d09d08df 2d3bf3a1 c0deb211 7c9f5da0 3c424020 27f30414 16895013 de7df909 1da1cead 0a3e18ee be5758bc 6d1dce60 3c347b8a 10b80001 3e19ab6a 30573c6d b3020cf9 cd7604ec b881a82c 39bbaa80 3c1a4e64 25c7b008 5c2f1042 7110d08f f4726474 fddc5430 d1cb9059 47ff0f40 3c544386 52d7da1c 1e019967 3b3740eb 3363cd0d eb8bc881 112b80a5 064bf740 3c1a5388 27f99e18 3e104b9b 52111c61 d3cb75b3 0867d9f7 56d513af a99f8a60 3c463f89 51211c21 be132462 85e62731 f566b723 de0f0a77 7380b271 43c97c20 3c425d88 76acf403 8f146e77 bcd3a418 2177013a 479b0f2d 5f34e00c c90a3490 3c344b8b 4d54e405 de00e2f4 9562775c 2df5bafc 6d603ff9 6debf3ca 07f51610 3cdc6788 1994d214 ba479992 0428d751 dc2dfc22 953aab3d e5e98aa0 7dcccc20 3c343d88 17587ca1 3e039946 e84193ce 9123a9a2 75acad72 8718403d ac14f830>
我不相信数据存在问题。请多点亮一点。 感谢。
答案 0 :(得分:3)
NSString mp3file = [NSTemporaryDirectory () stringByAppendingPathComponent: @ "your.mp3"];
NSData * data = [NSData dataWithContentsOfFile: mp3file];
[[AVAudioPlayer alloc] initWithData: data error: & errr];
(或)
NSString mp3file = [NSTemporaryDirectory () stringByAppendingPathComponent: @ "your.mp3"];
[[AVAudioPlayer alloc] initWithContentsOfURL: [NSURL fileURLWithPath: mp3file] error: & errr];
我希望这会有所帮助