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

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();

Related

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

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))

Universal Music Player with own JSON and Youtube Audio Library

As mentioned in this line:
private static final String CATALOG_URL =
"http://storage.googleapis.com/automotive-media/music.json";
This file contains a list of tracks that are hosted by Google online.
So, I guess the complete URL of Jazz_In_Paris.mp3 would be
https://www.youtube.com/audiolibrary/music/Jazz_In_Paris.mp3
but getting 404 Not Found in a same way I have tried
https://www.youtube.com/audiolibrary/music/album_art.jpg
but again same result 404 Not Found
So here are my few small questions:
1. What is the complete URL of `Jazz_In_Paris.mp3` and `album_art.jpg`
2. Where they have used site object "site" : "https://www.youtube.com/audiolibrary/music" in application (in which class and where)
3. Where I have to make changes in my code, If I would like to get JSON from my own Server "http://www.domain.com/services/music.json"
4. How can I create my own Youtube Audio Library, Like in my Library I would like to add my favourite youtube songs
What is the complete URL of Jazz_In_Paris.mp3 and album_art.jpg
http://storage.googleapis.com/automotive-media/album_art.jpg
http://storage.googleapis.com/automotive-media/The_Messenger.mp3
Where they have used site object "site" : "https://www.youtube.com/audiolibrary/music" in application (in which class and where)
this url not used any where in app.
Where I have to make changes in my code, If I would like to get JSON from my own Server "http://www.domain.com/services/music.json"
yes, you can use same json for your app but just change path to your server(just create same json format)
How can I create my own Youtube Audio Library, Like in my Library I would like to add my favourite youtube songs
Universal Music Player: use Google storage client to store music files but you can also create own you tube channel and make private video. use it in your app
EDITED:
"site" json object is useless. this object is json because of previous version of app they have used that. currently not.
youtube channel and Google storage both are different thing. Google storage mainly used to store files which we are able to use in our app.
in you tube every one can upload video which is private/public(if you are going to use that in your app then use private). for more detail check you support articals
i suggest you to use Google Storage API or you can also upload files on your own server!

How to add video duration to youtube v3 api native android

am working on youtube player using youtube v3 api. I tried to add video duration using part=ContentDetails to my video search request, but it keeps returning error for contentDetails/duration. Does anybody have any means of getting around this problem. Here is my search request Url code below.
https://www.googleapis.com/youtube/v3/search?contentDetailsorder=viewCount&q=;&type=video&maxResults=14&part=snippet,&fields=items(id/videoId,snippet/title,snippet/thumbnails,contentDetails/duration)&key= Constants.YOUTUBE_API_KEY;
The Search:List call does not return the duration of a video in its search results. All the fields available can be seen here.
In order to get the duration of the videos call Videos:List with the id field set to a comma delimited list of the videoIds that you get from the search call. For instance:
GET https://www.googleapis.com/youtube/v3/videos?part=contentDetails&id=RgKAFK5djSk%2Cw1oM3kQpXRo&key={YOUR_API_KEY}
you can then access contentDetails\Duration for each of the videos.

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