0xced / XCDYouTubeKit

YouTube video player for iOS, tvOS and macOS
MIT License
2.93k stars 626 forks source link

VIDEO NOT PLAYING (CHECK THIS BEFORE CREATING NEW) #548

Open NikKovIos opened 3 years ago

NikKovIos commented 3 years ago

Ok, every new guy think that it's good to start a new thread about that youtube is not playing. I decided to summarize and create one issue to prevent creating others.

Here are related issues: https://github.com/0xced/XCDYouTubeKit/issues/527 https://github.com/0xced/XCDYouTubeKit/issues/523 https://github.com/0xced/XCDYouTubeKit/issues/515 https://github.com/0xced/XCDYouTubeKit/issues/547 https://github.com/0xced/XCDYouTubeKit/issues/544 https://github.com/0xced/XCDYouTubeKit/issues/543 https://github.com/0xced/XCDYouTubeKit/issues/541 https://github.com/0xced/XCDYouTubeKit/issues/534 https://github.com/0xced/XCDYouTubeKit/issues/531 https://github.com/0xced/XCDYouTubeKit/issues/530 https://github.com/0xced/XCDYouTubeKit/issues/529

Top solutions from them: https://github.com/0xced/XCDYouTubeKit/pull/526 https://github.com/0xced/XCDYouTubeKit/issues/547#issuecomment-893411895 https://github.com/0xced/XCDYouTubeKit/pull/545 https://github.com/0xced/XCDYouTubeKit/issues/541#issuecomment-882188584 https://github.com/0xced/XCDYouTubeKit/issues/530#issuecomment-849851958

But I think that the problem is because the youtube decided to prevent connecting with them without authentication. So now we need to use youtube API Key.
How to create it: https://www.slickremix.com/docs/get-api-key-for-youtube/ Google docs about it: https://developers.google.com/youtube/v3/getting-started?hl=en_US Also take a look: https://github.com/google/google-api-objectivec-client-for-rest/search?q=youtube PR with implementing it: https://github.com/0xced/XCDYouTubeKit/pull/545 However I think in this PR you need to create OWN api key and set in INNERTUBE_API_KEY property.

gonzo-oin commented 3 years ago

Thank you for creating this issue. I follow #545 by using the armendh's fork

pod 'XCDYouTubeKit', git: 'git@github.com:armendh/XCDYouTubeKit.git', branch: 'master'

I created an API key following your explanation link and call setInnertubeApiKey before anything else and it's working great. I'm in Europe if that matter.

        XCDYouTubeClient.setInnertubeApiKey("MY_API_KEY")

Next step should be create an PR with a README update no ?

NikKovIos commented 3 years ago

Next step should be create an PR with a README update no ?

Yep And we need someone, who can merge this MR.

NikKovIos commented 3 years ago

1)

pod 'XCDYouTubeKit', :git => 'https://github.com/armendh/XCDYouTubeKit', :branch => 'master', :commit => '651a6a51c695c5819eb51ba2f98d0b64094315b9'

2) https://console.cloud.google.com/apis/credentials?project=**projectName** image

3)

XCDYouTubeClient.setInnertubeApiKey(**key**)
tungdangplus commented 3 years ago

Thank @NikKovIos . I tried your solution. It's working for me. But it doesn't work with livestream video. Can you check it?

NikKovIos commented 3 years ago

@tungdangplus sorry, don't have time for it. By the way, i'm not a owner of the repo, just a regular senior ios dev. You can find a solution by yourself and put it here. Just spend time.

ryanfrancesconi commented 3 years ago

Thanks for this, Ryan

dcristolovean commented 3 years ago

the problem is this will work... until it won't again. Not the nicest thing to happen when you have dozens of apps in production using it and all clients suddenly can't access some YT content. Happened at least twice already, so it's better to avoid this lib altogether if you're doing any real production work and just go for the official lib.

gonzo-oin commented 3 years ago

@dcristolovean I agree with you but there is no official SDK available on tvOS. What to do then ?

dcristolovean commented 3 years ago

well, yeah, then you're stuck. My advice is for the rest of 99% of the devs that don't use tvOS.

NikKovIos commented 3 years ago

@dcristolovean give a link for the official lib please.

dcristolovean commented 3 years ago

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

"Lib" might be too much to say, but after you play a bit with it, you can fit in it any design and make it behave like needed. You gotta face that YT will not just give you urls to play the content and will require a webview with their content inside in the future. I didn't want to use this myself, preferred to get the URLs with xcdyoutubekit and then play them myself, but after 2-3 big failures over time, when the lib didn't work anymore and I have to republish tens of apps, I gave up on it and just moved to the webview approach.

dcristolovean commented 3 years ago

@dcristolovean I agree with you but there is no official SDK available on tvOS. What to do then ?

Actually, webviews are the way to go there too. Considering that's what youtube_helper does anyway, you can directly use that one or create one yourself. I never coded for tvOS but I'm sure there's a way.

gonzo-oin commented 3 years ago

I never coded for tvOS but I'm sure there's a way.

Sadly, I don't think so: https://github.com/youtube/youtube-ios-player-helper/issues/148

dcristolovean commented 3 years ago

kinda old discussion, 2015.... anyway, another interesting thing:

"It's against the ToS because it won't display the ads."

That's why I said that at some point, surely you won't be able to just get a video url from YT and play it. There are so many reasons why they won't let you do that, I don't see a bright future for XCDYoutube.

dcristolovean commented 3 years ago

defagos commented on Jan 22, 2016

You should really check out XCDYouTubeKit, it works great and supports tvOS as well. @mikerz mikerz commented on Jan 22, 2016

@defagos That's not a good recommendation, as it is against YouTube's terms of service. It bypasses their player and analytics. It should not be used in any production code beyond some fun prototype.

Exactly what I'm saying.

weiran commented 3 years ago

For those looking for an alternative for tvOS, you can link to a video directly on the YouTube app with this URL scheme: youtube://watch/videoID

Anvar102b commented 3 years ago
pod 'XCDYouTubeKit', :git => 'https://github.com/armendh/XCDYouTubeKit', :branch => 'master', :commit => '651a6a51c695c5819eb51ba2f98d0b64094315b9'

https://console.cloud.google.com/apis/credentials?project=**projectName** image

XCDYouTubeClient.setInnertubeApiKey(**key**)

From today today there problems with playing videos with this solution

NikKovIos commented 3 years ago

@Anvar102b place any logs. What is broken? What error?

alexisbronchart commented 3 years ago

Now I have Type 'XCDYouTubeClient' has no member 'setInnertubeApiKey'. I couldn't find any declaration of it? Where is it supposed to be defined?

secret3579 commented 3 years ago

@NikKovIos Thank you so much, it works well. I just wondering why the commit (651a6a51c695c5819eb51ba2f98d0b64094315b9) hasn't been merged yet.

gonzo-oin commented 3 years ago

@secret3579 It should be documented before merging. If you have time to contribute 😉

NikKovIos commented 3 years ago

It would be great if the owner of repo would do something. The community already did a lot!

KODIKAS-NL commented 3 years ago

@tungdangplus I also had issues with livestreams, I fixed my issues here -> https://github.com/KODIKAS-NL/XCDYouTubeKit.git It also seems to work without setting the API key.