Android Question YouTube - There was a problem with the server [400]

alon

Active Member
Licensed User
Longtime User
Hi all,

I am using YouTubeStandalonePlayer lib, and for the last 2 weeks.
I am getting this error when trying to play a video from YouTube.
if anyone have any idea what is the problem, I will be glad to know.

by the way I was trying to change my api key and also a different video id , but with no luck.


B4X:
YouTube.StartVideo(Starter.sMyYouTubeDevKey , sVideoID, 0, False, True)

attached the screen with error.


Is it deprecated ?


Thanks In Advance.
 

Attachments

  • WhatsApp Image 2023-07-25 at 15.16.39.jpeg
    WhatsApp Image 2023-07-25 at 15.16.39.jpeg
    94.2 KB · Views: 77
Last edited:

drgottjr

Expert
Licensed User
Longtime User
the player is deprecated, but that doesn't mean you can't use it. it may or may
not be phased out, in accordance with google's whims.
if the reason for the error is not posted or you don't want to ask google what the
problem is, there isn't too much that can be done here. we don't even know which
resource you were trying to access. and error 400 just means a bad request.
if you want to post your code (minus your key), i'm sure someone here would
be happy to try to duplicate the error and, possibly, derive more information for you.
 
Upvote 0

alon

Active Member
Licensed User
Longtime User
the player is deprecated, but that doesn't mean you can't use it. it may or may
not be phased out, in accordance with google's whims.
if the reason for the error is not posted or you don't want to ask google what the
problem is, there isn't too much that can be done here. we don't even know which
resource you were trying to access. and error 400 just means a bad request.
if you want to post your code (minus your key), i'm sure someone here would
be happy to try to duplicate the error and, possibly, derive more information for you.
Hi thanks,

I was trying to ask google but with no much help from their side.
I am attaching the project maybe someone here will have any idea.

link to download my project: https://webapps.binaw.com/binawfile/PlayHumash.zip

thanks
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
YTSAP, she is deadšŸ˜¢ you'll need this: https://developers.google.com/youtube/iframe_api_reference
it looks like you'll run the selected videos in a frame in a webview. the documentation even provides the script you need.
since i was using the standalone player myself, i'll be looking into the iframe_api more closely. webview does play videos,
so i'm optimistic.

update:
i haven't tried the api yet, but i did this, and it worked easy enough. i don't know how it meshes with your use case:
B4X:
    Dim myYouTubeVideoUrl As String = "https://www.youtube.com/embed/XUTXU6fy94E"
 
    Dim dataUrl As String = $"<html>
    <body>
    <h2>Video From YouTube</h2>
    <br>
    <iframe width='80%' src='${myYouTubeVideoUrl}' frameborder='0' allowfullscreen/>
    </body>
    </html>"$

    webview.LoadHtml( dataUrl )


update #2:
still haven't used the new api, but you can also play youtube directly in a webview. for my purposes, the frame or the full webview do what i need. you're probably looking for something more integrated, i'm guessing, so you'll have to check out the api.
 

Attachments

  • alon.png
    alon.png
    9.5 KB · Views: 59
Last edited:
Upvote 0

alon

Active Member
Licensed User
Longtime User
YTSAP, she is deadšŸ˜¢ you'll need this: https://developers.google.com/youtube/iframe_api_reference
it looks like you'll run the selected videos in a frame in a webview. the documentation even provides the script you need.
since i was using the standalone player myself, i'll be looking into the iframe_api more closely. webview does play videos,
so i'm optimistic.

update:
i haven't tried the api yet, but i did this, and it worked easy enough. i don't know how it meshes with your use case:
B4X:
    Dim myYouTubeVideoUrl As String = "https://www.youtube.com/embed/XUTXU6fy94E"
 
    Dim dataUrl As String = $"<html>
    <body>
    <h2>Video From YouTube</h2>
    <br>
    <iframe width='80%' src='${myYouTubeVideoUrl}' frameborder='0' allowfullscreen/>
    </body>
    </html>"$

    webview.LoadHtml( dataUrl )


update #2:
still haven't used the new api, but you can also play youtube directly in a webview. for my purposes, the frame or the full webview do what i need. you're probably looking for something more integrated, i'm guessing, so you'll have to check out the api.
Thanks I will try that
 
Upvote 0

alon

Active Member
Licensed User
Longtime User
YTSAP, she is deadšŸ˜¢ you'll need this: https://developers.google.com/youtube/iframe_api_reference
it looks like you'll run the selected videos in a frame in a webview. the documentation even provides the script you need.
since i was using the standalone player myself, i'll be looking into the iframe_api more closely. webview does play videos,
so i'm optimistic.

update:
i haven't tried the api yet, but i did this, and it worked easy enough. i don't know how it meshes with your use case:
B4X:
    Dim myYouTubeVideoUrl As String = "https://www.youtube.com/embed/XUTXU6fy94E"
 
    Dim dataUrl As String = $"<html>
    <body>
    <h2>Video From YouTube</h2>
    <br>
    <iframe width='80%' src='${myYouTubeVideoUrl}' frameborder='0' allowfullscreen/>
    </body>
    </html>"$

    webview.LoadHtml( dataUrl )


update #2:
still haven't used the new api, but you can also play youtube directly in a webview. for my purposes, the frame or the full webview do what i need. you're probably looking for something more integrated, i'm guessing, so you'll have to check out the api.
Hi,
It is working and I can manage with that , the only problem is that the full screen is not working.

Thanks
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
i don't know which of the "solutions" you're going with, but if i simply show youtube in a webview, i get full screen. if you're using the api or your own iframe, you're going to have to figure out if it's possible or not. once you start using javascript, there could be many ways to configure things. no one else here has posted to this thread, so you may be on your own. i'll try a couple things, but what you have now may be all that you're going to get.
 
Upvote 0
Top