0

AVPlayers は HLS を再生しますが、MP4 ビデオでクラッシュします。次の URL を使用しています。また、iOS 用の IMA SDK を使用して広告を再生しています。これは 1 番目の URL で完全に機能しますが、広告を再生せずに 2 番目の URL でアプリがクラッシュします。

iOSバージョンを使用:10.1

//NSString *const kTestAppContentUrl_MP4 = @"http://50.7.149.90:1935/pitvlive/ptvsportsnew3.stream/playlist.m3u8";

NSString *const kTestAppContentUrl_MP4 = @"http://50.7.149.74/vods/trailers/OK Jaanu-Official Trailer.mp4";


> *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid number value (NaN) in JSON write'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001076b634b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010aba621e objc_exception_throw + 48
    2   CoreFoundation                      0x000000010771f265 +[NSException raise:format:] + 197
    3   Foundation                          0x000000010a6efbfe _writeJSONNumber + 302
    4   Foundation                          0x000000010a69a138 _writeJSONValue + 480
    5   Foundation                          0x000000010a6efa12 ___writeJSONObject_block_invoke + 226
    6   CoreFoundation                      0x0000000107646e55 __65-[__NSDictionaryI enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 85
    7   CoreFoundation                      0x0000000107646d6a -[__NSDictionaryI enumerateKeysAndObjectsWithOptions:usingBlock:] + 250
    8   Foundation                          0x000000010a6ef806 _writeJSONObject + 430
    9   Foundation                          0x000000010a69a0dd _writeJSONValue + 389
    10  Foundation                          0x000000010a6efa12 ___writeJSONObject_block_invoke + 226
    11  CoreFoundation                      0x000000010763d9d6 __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 102
    12  CoreFoundation                      0x000000010763d8da -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 202
    13  Foundation                          0x000000010a6ef806 _writeJSONObject + 430
    14  Foundation                          0x000000010a69a0dd _writeJSONValue + 389
    15  Foundation                          0x000000010a699f04 -[_NSJSONWriter dataWithRootObject:options:error:] + 124
    16  Foundation                          0x000000010a699de4 +[NSJSONSerialization dataWithJSONObject:options:error:] + 333
    17  AVPlayer                            0x0000000106c552e4 -[IMAJavascriptDispatcher sendMessage:] + 313
    18  AVPlayer                            0x0000000106c55c5e -[IMAJavascriptSession sendMessage:] + 135
    19  AVPlayer                            0x0000000106c5f40d -[IMABaseManager sendMessage:data:] + 161
    20  AVPlayer                            0x0000000106c5dd1c -[IMABaseManager initializeWithAdsRenderingSettings:] + 1295
    21  AVPlayer                            0x0000000106c5d7f7 -[IMABaseManager initializeWithContentPlayhead:adsRenderingSettings:] + 100
    22  AVPlayer                            0x0000000106c5b336 -[IMAAdsManager initializeWithAdsRenderingSettings:] + 108
    23  AVPlayer                            0x0000000106c5173b -[ViewController adsLoader:adsLoadedWithData:] + 331
    24  AVPlayer                            0x0000000106c59e3f __39-[IMAAdsLoader handleMessageAdsLoaded:]_block_invoke + 94
    25  libdispatch.dylib                   0x000000010d3a9980 _dispatch_call_block_and_release + 12
    26  libdispatch.dylib                   0x000000010d3d30cd _dispatch_client_callout + 8
    27  libdispatch.dylib                   0x000000010d3b38d6 _dispatch_main_queue_callback_4CF + 406
    28  CoreFoundation                      0x000000010767a4f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    29  CoreFoundation                      0x000000010763ff8d __CFRunLoopRun + 2205
    30  CoreFoundation                      0x000000010763f494 CFRunLoopRunSpecific + 420
    31  GraphicsServices                    0x000000010ce2ca6f GSEventRunModal + 161
    32  UIKit                               0x0000000108778964 UIApplicationMain + 159
    33  AVPlayer                            0x0000000106c5215f main + 111
    34  libdyld.dylib                       0x000000010d41f68d start + 1
    35  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
4

1 に答える 1

0

URLにスペースがあったので、誰かからの次の方法を使用してURLをエンコードしました。

- (NSString *) URLEncodedString_ch:(NSString*) str {
NSMutableString * output = [NSMutableString string];
const unsigned char * source = (const unsigned char *)[str UTF8String];
int sourceLen = strlen((const char *)source);
for (int i = 0; i < sourceLen; ++i) {
    const unsigned char thisChar = source[i];
    if (thisChar == ' '){
        [output appendString:@"+"];
    } else if (thisChar == '.' || thisChar == '-' || thisChar == '_' || thisChar == '~' ||
               (thisChar >= 'a' && thisChar <= 'z') ||
               (thisChar >= 'A' && thisChar <= 'Z') ||
               (thisChar >= '0' && thisChar <= '9')) {
        [output appendFormat:@"%c", thisChar];
    } else {
        [output appendFormat:@"%%%02X", thisChar];
    }
}
return output;

}

于 2016-12-16T10:43:10.123 に答える