13

我正在尝试使用youtube-ios-player-helper库播放 YouTube 视频,但在运行时遇到错误:

Received error rendering template: Error Domain=NSCocoaErrorDomain Code=258 "The operation couldn't be completed. (Cocoa error 258.)"
4

4 回答 4

40

在 YTPlayerView.m

编辑:

NSString *path = [[NSBundle mainBundle] pathForResource:@"YTPlayerView-iframe-player"
                                                 ofType:@"html"
                                            inDirectory:@"Assets"];

至:

NSString *path = [[NSBundle mainBundle] pathForResource:@"YTPlayerView-iframe-player"
                                                 ofType:@"html"];

希望能帮到你!

于 2014-05-23T10:52:33.080 回答
6

您需要将Assets/YTPlayerView-iframe-player.html 复制到主包以解决此问题

或者只是放入捆绑包中,并替换 App 开始寻找的位置

/*NSString *path = [[NSBundle mainBundle] pathForResource:@"YTPlayerView-iframe-player"
     ofType:@"html"
     inDirectory:@"Assets"];*/

NSString *path = [[NSBundle mainBundle] pathForResource:@"YTPlayerView-iframe-player" ofType:@"html"];
于 2014-11-09T11:20:31.343 回答
2

拖放

YTPlayerView-iframe-player.html

YTPlayerView.h

YTPlayerView.m

项目中的文件。

添加桥接头并使用它:

#import "YTPlayerView.h"

转到 YTPlayerView.m 文件:

寻找 :

NSString *path = [[NSBundle mainBundle] pathForResource:@"YTPlayerView-iframe-player"
                                                 ofType:@"html"
                                            inDirectory:@"Assets"];

改成 :

  NSString *path = [[NSBundle mainBundle] pathForResource:@"YTPlayerView-iframe-player"
                                                     ofType:@"html"];

在您的视图控制器中:

利用 :

class ViewController:UIViewController,YTPlayerViewDelegate {

   var playerView = YTPlayerView()

获取 videoID 并加载:

self.playerView.load(withVideoId: videoID)

self.playerView.playVideo()
}
于 2017-03-15T05:30:46.857 回答
-1

您没有提供有问题的插件版本。如果这是 1.5,这里讨论了一个错误:https ://github.com/youtube/youtube-ios-player-helper/issues/160 。

它已经在 master 中修复了,所以,假设你使用的是 Cocoapods,你可以这样做:

pod 'youtube-ios-player-helper', :git=>'https://github.com/youtube/youtube-ios-player-helper', :commit=>'head'
于 2016-03-03T15:43:08.173 回答