How to integrate Vimeo on Android and Website with specific user access - android

we have purchased a VIMEO account for video streaming. Our websites and android app are running and the user-level restriction to contents is managed by firebase generated token. Now I want to integrate the VIMEO video's to be accessed by our site and app and want to ensure those videos to be accessed by the desired user only with the corresponding token.
we are now just showing the videos on our site using iframe + domain-level protection + making it private though it can be downloaded sometimes. but it is not possible to manage different user levels to access different videos only. Also struggling to integrate it in android for domain-level protection. Is it like a hardcoded client token to show videos on App or I have to use Vimeo player or API and how?
Saw some documentation for android but those seem unclear to me. Please suggest

It was really painful experience of support we are getting with the paid service from vimeo, their documention for specific or popular use-cases are super unclear. I did manage to implement my use case though not sure that whether it is the best practice or not. I will describe the the experience as details possible :
We moved from Vimeo Plus to Vimeo Pro account (As noone can even get the access of vimeo GET api or video file access from from api without Pro account which is must)
for our Website use-case we have hidden the private video from vimeo and only allowed it to be embedded in our site (though if anyone check the network he can use the the server responded html with limited time token anywhere for short time)
for Android use-case as it is browserless we followed https://github.com/vimeo/vimeo-networking-java and used hardcoded access-token for that and played in exoplayer (as I will have to encrypt it later or I have to r&d more for dynamically get access token for limited time when playing video using Oauth. But the problem is the documentation is super unclear which didn't even properly illustrate the life span of different tokens just said it depends on the way of creating or scope)
Coding :
confBuilder = new Configuration.Builder(accessToken);
// this access token has public+private+video file access created in the vimeo account manually
configuration = confBuilder.build();
VimeoClient.initialize(configuration);
VimeoClient.getInstance().fetchContent(url, CacheControl.FORCE_NETWORK, new ModelCallback<Video>(Video.class){
//here url should be like "videos/{video_id}" otherwise it wasn't working whatever the url was
#Override
public void success(Video video) {
//progressBar.setVisibility(View.GONE);
if(video != null){
Play play = video.getPlay();
if (play != null) {
//in my case "play" was null, but here I should get the direct link to varioud resolution files
VideoFile dashFile = play.getDashVideoFile();
String dashLink = dashFile.getLink();
// load link
VideoFile hlsFile = play.getHlsVideoFile();
String hlsLink = hlsFile.getLink();
// load link
ArrayList<VideoFile> progressiveFiles = play.getProgressiveVideoFiles();
String linkToMp4File = progressiveFiles.get(0).getLink();
//loadVideo();
}
//I got the link from here
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();
finalLink = link;
// load link
RunExoplayerPlayerWithThisLink();
// but this is http link which will redirect to https link which u have to handle in exoplayer
}
}
}
#Override
public void failure(VimeoError error) {
progressBar.setVisibility(View.GONE);
Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_SHORT).show();
}
});
Now I have to handle Http to Https redict link in exoplayer which is restricted
in exoplayer by default. so you have to set "allowCrossProtocolRedirects" to "true" in DefaultHttpDataSourceFactory which will be needed in MediaSource while playing video in exoplayer :
DefaultHttpDataSourceFactory factory;
ExtractorsFactory extractorsFactory;
MediaSource mediaSource;
factory = new DefaultHttpDataSourceFactory("exoplayer_video",null, DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS,true);
extractorsFactory = new DefaultExtractorsFactory();
mediaSource = new ExtractorMediaSource(videoUri, factory, extractorsFactory,null,null);
Give me any suggestion in this topic if you think that the way could be better specially regarding access_token.specific user access implementation, I think cannot be fully possible. I just can send the link after authentication or checking user access from backend.
But there is still an issue regarding Android 10 platform (api 29) which doesn't allow some method used in the current version of the Vimeo Networking library regarding "sslSocketFactory" (Caused by: java.lang.IllegalStateException: Unable to extract the trust manager on Android10Platform, sslSocketFactory is class com.android.org.conscrypt.OpenSSLSocketFactoryImpl) which I asked (solved) in another post (Vimeo Networking Library Crash for Android 10 platform (api29))

Related

Chromecast receiver application cannot play widevine drm protected content from Android sender application

I'm using receiver application from Expressplay's site for chromecast. https://www.expressplay.com/developer/test-apps/#ccplayer.
I've tested it from the browser by passing license URL along with the widevine stream path. It played the video, means that the receiver is working fine.
The problem appears when I try to play content from an android sender application. I'm passing the license URL in a json object.
My android sender code is as follows.
private MediaInfo buildMediaInfo() {
MediaMetadata movieMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE);
movieMetadata.putString(MediaMetadata.KEY_SUBTITLE, "Subtitle");
movieMetadata.putString(MediaMetadata.KEY_TITLE, "Title");
jsonObj = new JSONObject();
try{
jsonObj.put("licenseUrl","https://wv.test.expressplay.com/hms/wv/rights/?ExpressPlatToken=****");
}catch (JSONException e){
Log.e(null,"Failed to add description to the json object", e);
}
return new MediaInfo.Builder("stream path.mpd")
.setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
.setContentType("video/mp4")
.setMetadata(movieMetadata)
.setCustomData(jsonObj)
//.setStreamDuration(player.getDuration())
.build();
}
I'm guessing that the problem maybe with recevier's code for the case of playing from android in setting the licenseUrl.
My receiver code setting license URL is as following.
if (event.data.customData && event.data.customData.licenseUrl) {
console.log('setting license URL');
host.licenseUrl = event.data.customData.licenseUrl;
}
event.data.customData.licenseUrl license URL is not getting set in case of android.
Result while playing from android sender is Black screen.
When playing from browser sender is plays the video.
CORS is enabled on the S3 server which is hosting the video contents.
Can Anyone tell what am I doing wrong?
Does the JSON object passed from android not setting license URL ? If yes then how to resolve it?
Thank you in advance for your kind interest and worthy time to my problem. :)
I figured out that in my Receiver app event.data.customData was undefined while connecting from android sender application.
So I used event.data.media.customData
And accessed the key as follow:
if(event.data.media.customData['licenseUrl'] !== null){
console.log('setting license URL from mobile');
host.licenseUrl = event.data.media.customData.licenseUrl;
}
That was it! :)
If you haven't done so, check DRM support wherein it was stated that,
To fully support content protected with Digital Rights Management (DRM), you need to implement a Custom Receiver. With a Custom Receiver, you can set up authentication and tailor your application according to your DRM requirements.
Note that, your receiver app accesses the Receiver API with the following reference:
//www.gstatic.com/cast/sdk/libs/receiver/2.0.0/cast_receiver.js
Also, to develop a custom receiver application, you will need to register your app with the Google Cast SDK Developer Console.
Then, for the Android Sender App, check the following:
prerequisites
ensure that the correct Google Play services APK is installed on a user's device since updates might not reach all users immediately.
add the basic Cast features to your app, go to Integrate Cast v3 into your Android App.

Is there any way to retrieve only completed video not live streaming?

HI I am developing an android app. I'm using Youtube API v3.
As I mention on question title, Is there way? because I send command to Youtube server, they return video and live streaming.
I tried to find options to exclude live streaming video but I couldn't.
Try using videos.list to retrieve non-livestreaming videos in Youtube. Use the HTTP request
GET https://www.googleapis.com/youtube/v3/videos
to perform the operation.
Give the Try-it a go to see the results in your browser right now.
Since you're using Android, this code snippet from the same page might give you an idea:
// Call the YouTube Data API's youtube.videos.list method to
// retrieve the resources that represent the specified videos.
YouTube.Videos.List listVideosRequest = youtube.videos().list("snippet, recordingDetails").setId(videoId);
VideoListResponse listResponse = listVideosRequest.execute();
List<Video> videoList = listResponse.getItems();

Video's suddenly stopped playing from Youtube API

We've been using the Youtube API in our Android Application for about 3 months now, we removed alot of old video's the last couple of days and updated our MYSQL server where the video ID's are stored.
We made 60 video's add dynamically (using the MYSQL) in our main screen, and i've added about 6 video's 'hardcoded', so nothing should have gone wrong there.
Suddenly all the video's won't play inside the application and give the error "There was a problem while playing, touch to retry". I can keep tapping but nothing happens. I do see that it is loading the right video.
If I keep tapping the bottom right corner, where the link to the youtube web/app is, then it will load the video inside the normal youtube application. It is working fine inside the normal Youtube App.
What I tried so far:
Restarted my device
Uninstall my application and installing it again
Switch from WiFi to 3G
Tested a friends phone who also has the application
Generating a new Youtube_API_KEY and adding it to the application
Tried multiple Youtube accounts, even tested without being logged into Youtube
None of the above mentioned attempts worked.
Does anyone mayby has a clue where to look?
I had an issue earlier with the YouTube API, and the bug was introduced with a specific version of the YouTube app. That is, the presence of the bug in my application depended on the installed version of YouTube.
If you go to Settings > Apps > YouTube, tap Uninstall Updates, you can install another version of YouTube directly with an .apk file downloaded from here, for example.
Install an earlier version of YouTube for a temporary solution. You may want to raise an issue at the issue tracker for YouTube, and wait for the fix.
I encountered such a problem, some videos can be played only in the YouTube player. To circumvent this problem, we had to pump out all the videos from youtube and use the id of the video.
have you tried this code snippet
/**
* Method used to play video in a new activity
*
* #param context the activity context
* #param url the url of the youtube video to be played
*/
public static void playVideo(Context context, String url) {
String ytId = extractYTId(url);
if (ytId != null && ytId != "") {
Intent videoIntent = YouTubeStandalonePlayer.createVideoIntent((Activity) context, DEVELOPER_KEY, ytId, 0, false, false);
context.startActivity(videoIntent);
} else {
Toast.makeText(context, "this is not youtube url!", Toast.LENGTH_SHORT).show();
}
}
you just have to add youtube Api .jar and call this method then hope so your video will play..
enjoy your code time:)
If you go to Settings > Apps > YouTube, tap Uninstall Updates, you can install another version of YouTube directly with a .apk file downloaded from here for example.

Android app - private viemo videos not playing

I'm currently developing an android mobile app. I see that private Vimeo videos are not playing. Check the attached screen shot. Also note that the android app is still on development mode and not uploaded to Google. Please help me in this regard.
Regards,
Niladri!
private vimeo video not playing
That picture appears to be accessing vimeo.com directly to view videos. At vimeo.com, private videos can only be viewed if you are logged in (which is unrelated to the API).
If you want to play a private video in your application you will need to follow one of the following workflows:
Embedded in a webview
Mark your video as hidden from vimeo, yet embeddable, in your video's settings
Make an API request to /videos/{video_id} and extract the embed code from the response body (response.embed.html)
Put the embed code in your webview's html
Played in the Native Player (Vimeo PRO only)
Mark your video with any privacy setting
Make an API request to /videos/{video_id}
Find the collection of video files (response.files)
Loop through the video files to find the best height and width for your target player
Load the link into your native player
You can read more about the Vimeo API at https://developer.vimeo.com/api, and https://developer.vimeo.com/api/endpoints
If you want to play private Vimeo videos of your Vimeo account in an Android Application then follow the steps below:
Go to your video privacy settings and mark it as hidden from Vimeo and embed anywhere.
Make an API request to this endpoint: https://api.vimeo.com/users/{your_user_id}/videos
Get the embed.html string from the API response.
Load embed.html obtained in the previous step into your WebView.
For Vimeo Android SDK: https://github.com/vimeo/vimeo-networking-java
You can retrieve the Video endpoint by calling an auth-enabled REST API and then play it using a player(I used Exoplayer in android).
Follow below steps:
API Registration: You will need an application registered with the Vimeo API. If you do not already have an application registered, you can do so here.
You can generate an access token in the Authentication tab once you select your app from the list here.
With this access token you'll be able to make any requests that the access token's scope allows. You will NOT be able to switch accounts if you only supply the access token.
Call rest API with the access token in the header like below
Endpoint:
https://api.vimeo.com/videos/{VIDEO_ID}
Header:
Authorization:bearer ACCESS_TOKEN
VIDEO_ID is the id of video uploaded to Vimeo(Some number eg: 45334535)
ACCESS_TOKEN is the token you got after API Registration
This steps worked for me. I hope this will help someone.
We have a special google's SDK for YouTube for instance. On the other side AOS does not support Adobe Flash. Maybe its just has an unsupported by AOS video codec used by vimeo service? That could be the reason why you cant watch vimeo videos via WebView/browser.
Did you check for Vimeo official Android SDK if such thing does exist at least?
Also check this
And a little suggest: try to use SO search and google - it helps in most cases :)

Uploads videos to Youtube programmatically

I'm trying to upload video to youtube programmatically.
I tried with
YouTubeService service = new YouTubeService(clientID,developer_key);
service.setUserCredentials("email", "password");
But it throws ServiceException stating that com.google.gdata.util.AuthenticationException: Error connecting with login URI
How to proceed ?
It seems like you didn't set up your authentication.
I suggest to use Data API v3. Here's a great java UPLOAD example.
I also open sourced an Android upload example (YouTube Direct Lite) using ServiceIntent. Feel free to check it out.

Categories

Resources