Как воспроизводить личные файлы Vimeo в Exo Player в Android - PullRequest
0 голосов
/ 23 апреля 2020
private void getVideo() {
        String uri = baseUrl +videoId;
        VimeoClient.getInstance().fetchNetworkContent(uri, new ModelCallback<Video>(Video.class) {
            @Override
            public void success(Video video) {

                ArrayList<VideoFile> videoFiles = video.files;
                if(videoFiles != null && !videoFiles.isEmpty()) {
                    VideoFile videoFile = videoFiles.get(0); // you could sort these files by size, fps, width/height
                    String link = videoFile.getLink();

                    initializePlayer(link);
                }
               // playVideoWebView(video.embed != null ? video.embed.html : null);
            }

            @Override
            public void failure(VimeoError error) {
                // voice the error
                Log.d("video_", "failure: "+error.getDeveloperMessage());
            }
        });
    }

Я получил такую ​​ссылку: http://player.vimeo.com/external/ {videoId} .sd.mp4? S = {aKey} & profile_id = {aProfileId} & oauth2_token_id = {aToekn}

 private void initializePlayer(String url) {

        player = ExoPlayerFactory.newSimpleInstance(this);

        Uri uri = Uri.parse(url);
        MediaSource mediaSource = buildMediaSource(uri);
        playerView.setPlayer(player);
        player.setPlayWhenReady(playWhenReady);
        player.seekTo(currentWindow, playbackPosition);
        player.prepare(mediaSource, false, false);


    }

private MediaSource buildMediaSource(Uri uri) { 
    DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, "exoplayer-codelab");
    return new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(uri);
 } 

Экран плеера черный и ничего не воспроизводится.

...