Alternatives from youtube api

别说谁变了你拦得住时间么 提交于 2021-02-10 15:47:10

问题


hi guys been spending the last month or so creating a youtube app. its almost ready so i sent out for testing to multiple devices.. works fine on google api enabled devices such as phones. but on amazon devices and none google api devices suchas android boxes and firesticks it simply crashes out on startup..

ive been researching the problem for the last few days and worked out its probably the google api.. especially on amazon devices!

so my question is are there any alternatives to the youtube api. that would allow me to keep my current app and not have to change massive chunks of code to get it to work?

i have seen this on another web page github youtube player open source

and wondered if this could be implemented to use the short codes from the youtube urls ("dFlPARW5IX8") because this is the url ive been storing on my database i dont want to have to change all 200+ to ("https://bla bla.co.uk/dFlPARW5IX8")

any advice would be great cheers

****EDIT*****

Ok so on ive been testing the above code this afternoon and this would be really good for what im after.but i seam to have a problem and was wondering if there is a fix?

so this is the code im using to test the api

private String videoId = "6JYIGclVQdw";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    YouTubePlayerView youTubePlayerView = findViewById(R.id.youtube_player_view);
    youTubePlayerView.initialize(
            new YouTubePlayerInitListener() {

                @Override
                public void onInitSuccess(
                        final YouTubePlayer initializedYouTubePlayer) {

                    initializedYouTubePlayer.addListener(
                            new AbstractYouTubePlayerListener() {
                                @Override
                                public void onReady() {
                                    initializedYouTubePlayer.loadVideo((videoId), 0);
                                }
                            });
                }
            }, true);
}

when in full screen and press pause it has a menu that doesnt work and the screen seams to be stretched.. its not just in my app it does it if you go to there github and download there test apps from google play they do it as well.

*****EDIT 2*****

so reading through the errors section of the devs github page it seams to be a recent change to youtubes code. this came in to effect in sept this year. 6 days ago he said he was working on a fix. this brilliant news for me.

来源:https://stackoverflow.com/questions/52990229/alternatives-from-youtube-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!