Error when integrating with youtube-ios-player-helper third party library on iOS
Asked Answered
P

4

13

I am trying to play a YouTube video with the youtube-ios-player-helper library, but I am encountering an error at runtime:

Received error rendering template: Error Domain=NSCocoaErrorDomain Code=258 "The operation couldn't be completed. (Cocoa error 258.)"
Promiscuity answered 20/5, 2014 at 5:41 Comment(0)
P
40

In YTPlayerView.m

Edit:

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

To:

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

Hope to help you!

Paneling answered 23/5, 2014 at 10:52 Comment(1)
I have replaced the code. but it shows some texts with out playing videoFractionate
S
6

You need copy Assets/YTPlayerView-iframe-player.html to main bundle to fix this issue.

or just put into bundle, and replace where App starts to look for

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

NSString *path = [[NSBundle mainBundle] pathForResource:@"YTPlayerView-iframe-player" ofType:@"html"];
Sanferd answered 9/11, 2014 at 11:20 Comment(0)
T
2

Drag and drop

YTPlayerView-iframe-player.html

YTPlayerView.h

YTPlayerView.m

files in your project.

Add bridging header and use this:

#import "YTPlayerView.h"

Go to YTPlayerView.m file :

Find :

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

Change to :

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

In your View Controller:

use :

class ViewController:UIViewController,YTPlayerViewDelegate {

   var playerView = YTPlayerView()

fetch videoID and load :

self.playerView.load(withVideoId: videoID)

self.playerView.playVideo()
}
Trustful answered 15/3, 2017 at 5:30 Comment(0)
P
-1

You didn't give a version of the plugin you have a problem with. In case this is 1.5, there is a bug discussed here: https://github.com/youtube/youtube-ios-player-helper/issues/160.

It is already fixed in master, so, assuming you are using Cocoapods, you may do this:

pod 'youtube-ios-player-helper', :git=>'https://github.com/youtube/youtube-ios-player-helper', :commit=>'head'
Piliferous answered 3/3, 2016 at 15:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.