Unable to embed YouTube video with YTPlayerView NSCocoaErrorDomain Code=258
Asked Answered
G

4

7

Embedding YouTube videos with YTPlayerView doesn't work. It only gives me this error in the log:

2015-12-12 20:19:45.229 Wax-room[8545:3426005] Received error rendering template: Error Domain=NSCocoaErrorDomain Code=258 "The file name is invalid."

So I Googled it and it obviously has something to do with "YTPlayerView-iframe-player.html" is missing. I have tried all the locations suggested but either they are wrong or I am doing something wrong.The documentation is so bad on using it with Swift (2.x), Cocoapods and iOS 9.

https://developers.google.com/youtube/v3/guides/ios_youtube_helper

There is no Assets folder in the pod either.

Just stumbled over this:

The issue is that the YTPlayerView-iframe-player.html file is not being copied over anymore. I reverted back to 0.1.4 and now I see the html page and it works again https://github.com/youtube/youtube-ios-player-helper/issues/160

Its a bug in version 0.1.5 which is the latest. Changed to 0.1.4 and it works now. Check this: https://github.com/youtube/youtube-ios-player-helper/issues/157

Grateful answered 12/12, 2015 at 19:25 Comment(2)
Yup also happened to me.I manually added the files and changed the path of file in the youtubeplayer file :/. Now found a better solution.Tedesco
@MuhammadZohaibEhsan Seems like you just have to set the version number to 0.1.4 and it works without any additional steps.Grateful
P
3

Rather than rolling back to version 0.1.4, you could manually add the YTPlayerView-iframe-player.html to your Xcode project (or the Cocoapods project/target), or point Cocoapods at the master branch:

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

The changes for Podfile didn't help me.

Finally I made it work in these steps.

  1. Remove youtube-ios-player-helper from Podfile
  2. Run 'pod update'
  3. Now you have cleaned up the pod for youtube-ios-player-helper. Now drag YTPlayerView.m, YTPlayerView.h to the project and select "copy files if needed". Copy the YTPlayerView-iframe-player.html to the project folder and add it into the "Supporting Files" group.
  4. In YTPlayerView.m Change from this:

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

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

I have tested this in my mobiles and it works well.

Minnieminnnie answered 2/8, 2016 at 17:55 Comment(0)
P
1

Add "Assets.bundle" included in "youtube-ios-player-helper" folder(after unzipping the project folder from Git) into your xcode project. This fixed the issue for me.

Posner answered 27/7, 2016 at 14:18 Comment(0)
S
0

I changed the pod name in the Podfile from: pod 'youtube-ios-player-helper' (that is what the official documentation tells you to do)

To: pod 'youtube-ios-player-helper-swift'

I also had to change the import to youtube_ios_player_helper_swift on my files, and some methods have slightly different names.

I tried most of the answers above to no avail. I would just get a white rectangle for a view. Hope this works for you.

(As of Nov 2021, pod version 1.1 of the pod 'youtube-ios-player-helper-swift')

Schexnayder answered 9/11, 2021 at 20:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.