【问题标题】:Error when integrating with youtube-ios-player-helper third party library on iOS在 iOS 上与 youtube-ios-player-helper 第三方库集成时出错
【发布时间】:2014-07-08 05:51:15
【问题描述】:

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

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

【问题讨论】:

    标签: ios youtube youtube-iframe-api


    【解决方案1】:

    在 YTPlayerView.m 中

    编辑:

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

    收件人:

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

    希望能帮到你!

    【讨论】:

    • 谢谢,它节省了我很多时间。
    • 我已经替换了代码。但它显示了一些没有播放视频的文本
    【解决方案2】:

    您需要复制 Assets/YTPlayerView-iframe-player.html 到主包来解决这个问题。

    只是放入bundle,并替换App开始寻找的地方

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

    【讨论】:

      【解决方案3】:

      拖放

      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()
      }
      

      【讨论】:

        【解决方案4】:

        您没有提供您有问题的插件版本。 如果这是 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'
        

        【讨论】:

          猜你喜欢
          • 2017-08-15
          • 2020-01-12
          • 1970-01-01
          • 2014-08-04
          • 2016-10-29
          • 2016-01-04
          • 2023-03-29
          • 2015-08-07
          • 2016-04-26
          相关资源
          最近更新 更多