Why this Objective-C code won't play an AVPlayerViewController video?

前端 未结 2 471
清歌不尽
清歌不尽 2021-01-03 10:48

Both are in viewDidLoad(). What\'s wrong with this objective-c source file? The swift version works like a charm... Xcode ver. 8.2 iOS 10

Swift (OK):



        
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-03 11:19

    NSString *path = [[NSBundle mainBundle] pathForResource:@"charlie" ofType:@"mp4"];

    Try

    Using [NSURL fileURLWithPath:path] instead of [NSURL URLWithString:path]

    [NSURL fileURLWithPath]

    Or

    [[NSBundle mainBundle] URLForResource:@"charlie" withExtension:@"mp4"]

提交回复
热议问题