ios VLC 2.2.2 出现Your input can't be opened, VLC is unable to open the MRL问题

最近在用 ios VLC 2.2.2 播放h264视频流时,如果视频流服务端出了故障,VLC播放器就会出现“Your input can't be opened, VLC is unable to open the MRL” 的英文提示框,由于VLC这段提示语是英文的,没有多国语言翻译。对于不认识英文的用户,简直就是一段乱码,影响用户体验,故思考如何解决这个问题。

Your input can't be opened
VLC is unable to open the MRL 'file:///var/mobile/Media/DCIM/102APPLE/IMG2728.MOV'. 
Check the log for details.
截图-1

第一种做法: 在VLC源码中找到这段代码,注释掉就可以了! 搜索过程中发现这段代码只存在于2.2.2的一个input.c文件中。


注释掉这段代码,需要重新编译和打包VLC,生成framework,如果你不嫌麻烦,可以试试!

第二种做法:通过 [截图-1] 可以看出这个弹框是ios系统自带的UIAlertView,那么它要显示出来肯定要调用-(void)show;方法,我们利用runtime的方法交换可以对这种情况进行拦截。

具体做法是创建一个UIAlertView的分类,直接拖入项目当中就ok:


//  UIAlertView+VLCLog.h
#import <UIKit/UIKit.h>
@interface UIAlertView (VLCLog)
@end

//  UIAlertView+VLCLog.m
#import "UIAlertView+VLCLog.h"
#import <objc/runtime.h>

@implementation UIAlertView (VLCLog)

//此分类为了拦截VLC无法打开实时流时出现的英文UIAlert弹框
+ (void)load {
    Method sysMethod = class_getInstanceMethod([self class], @selector(show));
    Method myMethod = class_getInstanceMethod([self class], @selector(myShow));
    method_exchangeImplementations(sysMethod, myMethod);
}

- (void)myShow {
    if ([self.message containsString:@"VLC is unable to open the MRL"]) {
        [self dismissWithClickedButtonIndex:0 animated:NO];
    } else {
        [self myShow];
    }
}

@end

也可以拦截该方法,修改Vlc原来那段英文提示语,改为展示给用户看的已翻译的文字。

#import "UIAlertView+VLCLog.h"
#import <objc/runtime.h>

@implementation UIAlertView (VLCLog)

//此分类为了拦截VLC无法打开实时流时出现的英文UIAlert弹框
+ (void)load {
    Method sysMethod = class_getInstanceMethod([self class], @selector(show));
    Method myMethod = class_getInstanceMethod([self class], @selector(myShow));
    method_exchangeImplementations(sysMethod, myMethod);
}

- (void)myShow {
    if ([self.message containsString:@"VLC is unable to open the MRL"]) {
        self.title = GETLANGUAGES(@"输入的地址无法打开", nil);
        self.message = GETLANGUAGES(@"重启视频流服务器试试吧!", nil);
        [self myShow];
    } else {
        [self myShow];
    }
}

@end
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,536评论 25 708
  • 夏日美食如此多,而我独爱凉皮,一直不懂怎么描述夏日吃凉皮时的那种感觉,今天看到物道君的文,其中有一段说出了我的心声...
    菩提非树阅读 233评论 0 0
  • 文/渡 漫漫人生长路,有“回首向来萧瑟处,也无风雨也无晴”的豁达;有“多歧路,今安在”的茫然;亦有“夕阳西下,...
    真谛1阅读 357评论 1 1
  • 今天和李老师去西斗门的风景设计院王院长那里,整理了很多茶叶罐! 王院长和宋卫平的小舅子很熟!说要在宋城边上的翠庄合...
    竺子阅读 455评论 0 0
  • 那十年,只认识a和b 日子简单得像流水账,重复着好像不会厌倦的平淡 相约等待的老树,似乎从未迟到过 曾经是两棵,只...
    易落阅读 239评论 0 2