How to get the universal music player to detect on device music? - android

I'm trying to modify the universal music player app: https://github.com/googlesamples/android-UniversalMusicPlayer
Since I'm trying to build this for AOSP 6.0, I have no Google Play Services or any other Google Apps on my device, and so cannot use any non-android api's or api's that depend on Google Libraries.
The "Music provider" class, seems to visit this url:
http://storage.googleapis.com/automotive-media/music.json
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. It seems the app can stream these files, but for some reason it does not detect the music already on my device. Why is that ? How do I get the app to list the music tracks that are already on my device ?

Try to reimplement MusicProvider class and the setter to set your new Source from local device.
After you can use your new mMusicProvider variable in MusicService class and set the source you need in MusicService's onLoadChildren method.
More details you may see here:
Change the source in UAMP

Related

Android Google Drive API, file Change Notifications not working

I am working on google drive api, I am using https://github.com/googledrive/android-demos but not getting notification.
I am not seeing any notification when I changed metadata of selected file from web.
Does anyone succeeded, please provide a link or demo so that a hurdle can be remove.
I have checked similar question Google Drive Android API Change Notifications not working, as I am unable to comment on this question due to less reputation.
You can use change listeners to receive notifications whenever a specified file or folder has changes to its contents or metadata.
Based from Google Drive API for Androids on how to listen for change events:
A change listener implements the OnChangeListener interface for the
ChangeEvent and receives a direct callback from the Drive service to a
currently connected client application.
You can add a change listener by calling the DriveResourceClient.addChangeListener method, passing in the file or folder you want to receive notifications for.
getDriveResourceClient()
.addChangeListener(file, changeListener)
.addOnSuccessListener(this, listenerToken -> mChangeListenerToken = listenerToken);

Publish a Android private app for multiple clients

What we are dealing with
We have this app which we distribute to our clients in an offline fashion (i.e. not uploaded to Play store). The app flavour distributed to each client is almost identical with a bit of tweak here and there. All our clients share this app to their employees for usage. Basically this is an Enterprise App.
What's the problem
Recently one of our client started using a MDM (Mobility Device management) tool which blocks apps which are not downloaded from Google play. As obviously we got a request from our client to see if we can upload this app on Google play or not.
Important thing here is that we have over 100 clients and the package name of the app provided to each client is actually the same. So it's the same app with a bit of tweak here and there. If we go down the road of publishing the app to the play store, we might end up in a mayhem (we don't wanna upload 100 different apps to the play store - i.e. one for each client). We are doing some optimisation from our end so that multiple clients can use the same app (but we can't make all 100+ clients use the same app.).
What am I looking at ?
I started looking at Android For Work (AFW), Google private apps , Managed Google play and still digesting the stuffs. But to me it looked like just a secure way for enterprises to deploy/publish apps which can be downloaded only on specific devices and under a certain profile (which keeps things separate from user's personal apps and data in case they use the same phone for personal and work purpose).
What solution i am looking for ?
To privately deploy an app (host it with Google or privately host
but listed with Google play in both cases) and let my clients share
this app with their employee.
Each private app for each client should be on its own little
private island. I want to distribute the app with the same package
name to all my clients (From what I have read so far, this might not
be possible with Google play. But I am hoping somebody can point out
facts if I am missing something).
This is my solution:
Creating run-time dynamic app that get data and configs from back-end and render its views and data with its own Client Id.
You can create single app and upload to google play, but you should manage your clients by clientId that makes every app acts separated. This clientId is unique and generated per your clients. This solution have two sides. Android side and server side.
1 - Android side: Our app should have a baseUrl like this in Constants:
baseUrl = "http://yourCorporation.com/{clienId}/api/"
And then all the services of All clients use the same url. clientId is the key point. The difference of you client app is clientId. For generating url of api-call you should do something like this:
Constant.ClientId = scannedQRCode;
url = baseUrl.replace("{client_id}",Contant.ClientId) + apiUrl ;
You must create QR code per your clients that should scanned in app first run. It is good to send QR code after registration to his/her (client of your Clients) email. This QR code have clientId. Therefor every clients have their own services and really works as separated islands, even if you want to change server address, you can put all baseUrl in QR code but this is not suggested, because you have to create server per clients and this is headache.
You can even handle config and UI elements of you app with calling a config api that returns a customConfigDto as json like this:
public class CustomConfigDto {
String colorPrimary ;
String colroPrimaryDark ;
String colorAccent ;
int tabCounts;
//and more...
public String getColorPrimary() {
return colorPrimary;
}
public void setColorPrimary(String colorPrimary) {
this.colorPrimary = colorPrimary;
}
public String getColroPrimaryDark() {
return colroPrimaryDark;
}
public void setColroPrimaryDark(String colroPrimaryDark) {
this.colroPrimaryDark = colroPrimaryDark;
}
public String getColorAccent() {
return colorAccent;
}
public void setColorAccent(String colorAccent) {
this.colorAccent = colorAccent;
}
public int getTabCounts() {
return tabCounts;
}
public void setTabCounts(int tabCounts) {
this.tabCounts = tabCounts;
}
}
And render your views by this configurations. All of this works separated per app by their clientId.
I prefer QR code because it is very handy and classy and fit in your case, however you can enter this clientId with many other ways. This is one of best free and simple QR code generating service, and this is one of best QR-code scanner library for android.
2 - Server Side: You have to handle step1 in server-side and it is very easy. You can have entity calls Client that all other entities have it. Because you should keep all of your data in one place but separated by your clients. You can also map APIs like this in Spring:
#RequestMapping(value = "http://yourCorporation.com/{clienId}/api/customers", method = RequestMethod.GET)
Customers getCustomers(#PathVariable("clienId") Long clientId) {
return customerService.findCustomerByClientId(clientId);
}
Based on what you've said, this sounds more like you can solve this with configuration management than sending each client completely separate APKs.
Google has a private channel, but based on the documentation it seems much more oriented towards having a single membership list (i.e. once you're granted access you have access to the entire private channel) rather than highly customized access (i.e. certain people have access to certain items in the channel).
An alternative that I suggest: have all clients download the same APK. Give each of them a client-specific "activation code" for your app. When the app starts for the first time, it calls a web service and passes it its activation code; on the server side, you use the Activation Code to identify the client and then return data on the correct configuration to the client. Then you can distribute the same APK to everyone on your private channel and configure it remotely once it's installed.
A major advantage of this scheme is that you can have multiple configurations for an organization. Just give the client a choice of several activation codes, each of which will give them a certain configuration. For example, if you have an app that's used by both dock workers and janitors (and I'm just throwing out an example here), you could give the dock workers one activation code and janitors a second activation code and you can then easily give them different configurations.
Google Play now allows a developer to publish an app privately to up to 20 Managed Play organizations (or enterprises). To do so (instructions copied from the help center):
Sign in to the Google Play Console.
Go to Pricing & Distribution > User programs > Managed Google Play.
Check the Turn on advanced managed Google Play features box.
Check the Privately target this app to a list of organizations box.
Click Choose Organizations.
For each organization that you want to publish the app to, enter the Organization ID and a description (or name) and click Add. You can enter up to 20 organizations per app.
The good, long solution:
don't use the same package name for different apps. Create a multimodule project, set one module for the core, shared stuff, and add a module for each client where you can tweak what you need and configurate the package name dynamically based on build type. That way you can use the same package name for your CI server and everything else and have another package name when releasing the app.
The short workaround that may work:
Publish the app as a closed google play beta, and send invitations only to this client. That way he can distribute the app to his employees through play store and the other clients won't notice I can't assure it will work not knowing which MDM tool you are facing, but since beta channel apps don't require unknow origins permissions, you should be fine.
If you want the same package name, you'll have to do something like what EJoshuaS suggested: manage the different configurations inside of one app version. You won't be able to have more than one app with the same package deployed on Google Play.
If you're open to having different packages, you could just change the package name in the Android Manifest for each one and release as a different app. You would need to change the package everywhere you import the R file and you would need to make sure that all class references in your Manifest include the entire class path (<activity android:name="[full.package].MainActivity"> rather than <activity android:name=".MainActivity">). This gets pretty confusing and is terrible in terms of configuration management, so it's not really a great solution in general, but it might work for you.
I started looking at Android For Work (AFW), Google private apps , Managed Google play and still digesting the stuffs.
This would probably be a good fit for AFW.
But to me it looked like just a secure way for enterprises to deploy/publish apps which can be downloaded only on specific devices and under a certain profile
That's what an MDM does, yes, but there's more to it. With Android for Work you also have Managed Configurations which let you pass in a configuration for the app. This can be used to change backend urls, etc.
It for sure supports your second requirement, but I know too little to be certain about the first. While you can privately host and rollout an app on Google Play for Work, I don't know about distributing it privately to multiple clients.
The obvious benefit of using this Google API is that you don't have to build anything yourself. Also most MDMs support those Android for Work APIs, so that a domain admin can buy the app in bulk and distribute them to the employees. Have a look at the AppConfig Community which shows MDM Providers that incorporated those APIs and best practices.
Whatever you decide, you should definitely have a good look at Android for Work as what you are describing is exactly what it is intended for. The initial setup is a pain and there is way too little information about how it all works and plays together, but spending a few days trying to figure it out might be better than just building your own managed solution which you then will have to maintain too.

How to subscribe a user to a youtube channel using an Android app?

I am trying to create a Youtube based application and I can't find any information on how to subscribe the users to different channels.
Is it possible to do it? I can find information about how to do it using php but I'm wasting lots of time with no success trying to do it with Android.
You may want to look at the following content for accessing different Youtube channels?. There are also sample Android apps showing how to use the Youtube API.
To locate the referenced method, use the original source link below. Make sure that you are clicking the YoutubeIntents class or try this direct link. You can find the YoutubeAPI Player on the downloads page and sample applications may be found at this link.
(original source)
Below code will open channel in youtube app.
private void openChannel(){
String channelId = "";// put channel id
Intent intent = YouTubeIntents.createChannelIntent(getContext(),channelId);
startActivity(intent);
}

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!

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

Categories

Resources