URI द्वारा वीडियो चलाने के लिए Vimeo Networking java लाइब्रेरी के साथ एकीकरण करते हुए वीडियो फ़ाइलों को शून्य मान दिया गया है
मैंने अपने Android ऐप में Vimeo नेटवर्किंग लाइब्रेरी का इस्तेमाल किया, वीडियो व्यू द्वारा वीडियो देखने के लिए Vimeo की आधिकारिक लाइब्रेरी का उपयोग किया।
मैं टोकन के साथ एपीआई को प्रमाणित करता हूं
कोड के साथ समस्या यह है कि यह मुझे वीडियोफाइल्स के लिए अशक्त मूल्य देता है । जब मैं कोड टिप्पणी के बीच नीचे उल्लेख बी प्रारूप में लिंक देता हूं
यहाँ मेरा कोड है
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
मुझे नहीं पता कि मुझे कौन सा यूआरआई पास करना चाहिए, इसलिए मैं 2 प्रारूप में यूआरआई पास करता हूं
ए) https://player.vimeo.com/videos/123456789
यह मुझे विफलता विधि से त्रुटि फेंकता है
I / TAG5: Vimeo त्रुटि: पंक्ति 1 कॉलम 1 पथ $ पर विकृत JSON को स्वीकार करने के लिए JsonReader.setLenient (सत्य) का उपयोग करें
ख) https://player.vimeo.com/videos/123456789/config
I / TAG1: वीडियो: com.vimeo.networking.model.Video@0 I / TAG2: VideoFiles अशक्त
तो अंत में मैं लिंक बी का उपयोग करता हूं
final String uri = "https://player.vimeo.com/videos/123456789/config";
GsonDeserializer gsonDeserializer = new GsonDeserializer();
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();
Log.i("TAG1", "Video: " + video);
ArrayList<VideoFile> videoFiles = video.files;
Log.i("TAG2", "VideoFiles " + videoFiles);
// I am getting null Value of **videoFiles** and it's not passing the if block with link b above mentioned
if (videoFiles != null && !videoFiles.isEmpty()) {
VideoFile videoFile = videoFiles.get(0); // you could sort these files by size, fps, width/height
Log.i("TAG3", "VideoFiles " + videoFiles);
String link = videoFile.getLink();
Log.i("TAG4", "link " + link);
// load link
MediaController mediaController = new MediaController(PlayActivity.this);
mediaController.setAnchorView(videoView);
videoView.setVisibility(View.VISIBLE);
videoView.setVideoURI(Uri.parse(link));
videoView.setMediaController(null);
videoView.requestFocus();
videoView.start();
}
}
@Override
public void failure(VimeoError error) {
Log.i("TAG5", "vimeo error : " + error.getErrorMessage());
Toast.makeText(PlayActivity.this, "failure due to " + error.getErrorMessage(), Toast.LENGTH_SHORT).show();
}
});
}
}
जवाब
मुझे बस समाधान मिल गया, इसे यहाँ पोस्ट करने का सोचा। तो यह दूसरे की मदद कर सकता है
इसका उत्तर सीधा है, और मुझे इस प्रारूप में लिंक को दरकिनार कर वीडियोफाइल (TAG1) और लिंक (TAG2) मिला है
https://api.vimeo.com/me/videos/123456789
तो अंतिम कोड इस तरह होगा
final String uri = "https://api.vimeo.com/me/videos/123456789";
इसके अलावा
final String uri = "https://player.vimeo.com/videos/123456789/config";
यहाँ मेरा पूरा कोड है जो मुझे Vimeo नेटवर्किंग लाइब्रेरी का उपयोग करके एंड्रॉइड ऐप में वीडियो चलाने में मदद करता है
अंतिम कोड प्रस्तुत करना
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
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();
}
});
}
}