在控制台中获得奇怪的打印语句

时间:2013-03-06 17:02:50

标签: iphone ios objective-c youtube

我在我的应用中嵌入了一个youtube链接,如下所示

- (void)embedYouTube:(NSString *)urlString frame:(CGRect)frameSize inView:(UIImageView*)imageView {
    NSString *embedHTML = @"\
    <html><head>\
    <style type=\"text/css\">\
    body {\
    background-color: transparent;\
    color: white;\
    }\
    </style>\
    </head><body style=\"margin:0\">\
    <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
    width=\"%0.0f\" height=\"%0.0f\"></embed>\
    </body></html>";
    NSString *html  = [NSString stringWithFormat:embedHTML, urlString, frameSize.size.width, frameSize.size.height];
    videoView       = [[UIWebView alloc] initWithFrame:frameSize];
    [videoView loadHTMLString:html baseURL:nil];
    [imageView  addSubview:videoView];

}

但是,当我正在播放视频时,控制台正在向我投掷如下的长测试

setting movie path: http://r20---sn-tt17rn7s.c.youtube.com/videoplayback?fexp=917000%2C906357%2C923121%2C914071%2C916624%2C920704%2C912806%2C902000%2C922403%2C922405%2C929901%2C913605%2C925006%2C906938%2C931202%2C908529%2C904830%2C920201%2C930101%2C930603%2C906834%2C926403%2C913570%2C901451&newshard=yes&cp=U0hVR1ZMUF9GS0NONV9ORlRDOlZKNFRXTmNDY2NS&sver=3&itag=18&mt=1362588975&id=6e1254edbdac474b&ms=au&mv=m&source=youtube&sparams=cp%2Cid%2Cip%2Cipbits%2Citag%2Cratebypass%2Csource%2Cupn%2Cexpire&ipbits=8&ratebypass=yes&expire=1362612211&ip=66.207.201.14&key=yt1&upn=3o0EU_taOns&cpn=6QDoUVzCQUiAeBqm&signature=C609660EDEB083FFC1ABD1F781EDA222B6F04C66.CA4A052F0E17C10D866EB3D302A258571322C185  

我在我的代码中搜索setting move pathno recored found。赫克来自哪里以及如何摆脱这个。

2 个答案:

答案 0 :(得分:2)

这是一种将stderr重定向到缓冲区的可能方法,它允许你过滤掉特定的消息(但是个人看起来比它的价值更麻烦......但另一方面这些消息可能会使调试变得烦人): Turn off console logging for specific objects

扩展@dununized的答案(尽管我还没有测试过):

bool should_show(char *buffer) {
    return !stncmp("setting movie path", buffer, 18); // untested code...
}

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void) {
        size_t const BUFFER_SIZE = 2048;

        // Create a pipe
        int pipe_in_out[2];
        if (pipe(pipe_in_out) == -1)
            return;

        // Connect the 'in' end of the pipe to the stderr
        if (dup2(pipe_in_out[1], STDERR_FILENO) == -1)
            return;

        char *buffer = malloc(BUFFER_SIZE);
        if (buffer == 0)
            return;

        for (;;)
        {
            // Read from the 'out' end of the pipe
            ssize_t bytes_read = read(pipe_in_out[0], buffer, BUFFER_SIZE);
            if (bytes_read <= 0)
                break;

            // Filter and print to stdout
            if (should_show(buffer)) // TODO: Apply filters here
                fwrite(buffer, 1, bytes_read, stdout);
        }

        free(buffer);
        close(pipe_in_out[1]);
    });

答案 1 :(得分:1)

  

设置电影路径:

它来自javascript音频播放器,位于youtube.com。