Reputation: 367
I want to play the Vimeo video in my android app by using Vimeo Official library : Vimeo networking library with the help of VideoView or ExoPlayer
The basic requirements for native playback are:
User must be logged in. User must be the owner of the video. User must be PRO or higher (or the app must have the "can access owner's video files" capability). The token must have the video_files scope. User must be the owner of the API app making the request.
Upvotes: 0
Views: 368
Reputation: 367
Here is my complete code that helps me to play the video in android app by using Vimeo networking library
Presenting the final code
public class PlayActivity extends AppCompatActivity {
VideoView videoView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_play);
videoView = findViewById(R.id.player);
// Getting access Token
String accessToken = getString(R.string.access_token);
Configuration.Builder configBuilder = new Configuration.Builder(accessToken)
.enableCertPinning(false);
//Vimeo Client autenticated
VimeoClient.initialize(configBuilder.build());
// the video uri; if you have a video, this is video.uri
you should use URI in this format eg. I use the URI in 2nd format https://api.vimeo.com/me/videos/123456789
final String uri = "https://api.vimeo.com/me/videos/123456789";
VimeoClient.getInstance().fetchNetworkContent(uri, new ModelCallback<Video>(Video.class) {
@Override
public void success(Video video) {
Toast.makeText(PlayActivity.this, "Sucessful" + video, Toast.LENGTH_SHORT).show();
ArrayList<VideoFile> videoFiles = video.files;
Log.i("TAG1", "videoFiles " + videoFiles);
if (videoFiles != null && !videoFiles.isEmpty()) {
VideoFile videoFile = videoFiles.get(0); // you could sort these files by size, fps, width/height
String link = videoFile.getLink();
Log.i("TAG2", "link " + link);
// load link
// use the link to play the video by **EXO Player** or **Video View**
// Start your video player here
}
}
@Override
public void failure(VimeoError error) {
Log.i("TAG3", "vimeo error : " + error.getErrorMessage());
Toast.makeText(PlayActivity.this, "failure due to " + error.getErrorMessage(), Toast.LENGTH_SHORT).show();
}
});
}
}
Upvotes: 0