在iOS上与youtube-ios-player-helper第三方库集成时出错

时间:2014-05-20 05:41:49

标签: ios youtube youtube-iframe-api

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

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

4 个答案:

答案 0 :(得分: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"];

希望能帮到你!

答案 1 :(得分:6)

您需要复制资产/ 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"];

答案 2 :(得分: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()
}

答案 3 :(得分:-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'