Create mediaplayer alternate for live stream android - android

In reference to my question at:
Android Lollipop prepareAsync() takes a long time to return
I would like to go to a lower level. Does anyone know of a way to set up and play a live stream WITHOUT using a MediaPlayer object? Nothing fancy, just connect and play. No retrieval of song info or anything else.
Please see my other question (still unanswered) for details.

Related

Check/observe what is currently being played by the Android system

I'm looking for a solution to observe what the app is currently playing. At minimum I would need to know what URI is being used to play Media and what is current playback position.
We are giving developers API with media content (MP3/HLS files) and to give them the best experience we are asking them to send various events to our API. Based on those events we can prepare better content for their users. We would like to ease the process of tracking events by implementing library that will be responsible for tracking those events. To do it we need to observe/query what their app is currently playing and what is a playback position. That's why I'm looking for a solution that will let me do this without caring too much what kind of player app is using (MediaPlayer, ExoPlayer or any other solution).
Is there any tool that will let me check those informations?

Get currently active AudioSessions or AudioOutput

I'm trying to create a Visualizer with the Visualizer Class. The documentation says to use "0" as session id to get the audio output, however this seems to be deprecated and only results in an error.
I searched for ways to get the currently active AudioSession ID's but can't find anything that remotely helps me out. All samples only provide info on how to do it with playing music by yourself, but I want to use it for visualizing Spotify and other music or videos being played, so that's not an option for me.
I know that it IS possible. There are apps like HueManic that work completely fine. I just can't find any information on how it would be still possible.

How could I get the current time of the currently played video? from VLC Player for Android

Let's say I'm playing a video on VLC player for Android [Img].
And at any point while watching it I could trigger a script that should get the value of the current time [Img] to append it to a text file. How could I get the current time of the currently played video at the time at which I triggered the script?
Note: I need to develop a separate tool from VLC player (not embedded within it) so the method of getting the current time value should consider this.
My thoughts trying to get to a solution:
Thought 1:
I'm not sure if Tasker or Automagic can trigger some script to get the current time value.
Thought 2: There's a tool that can read values stored by third-party applications directly from memory called Cheat Engine for Desktops, recommended by Ascorbin. I'm not sure if we can use something similar for Android to get the current time value directly from memory.
As CommonsWare was suggesting, without an API it is going to be very tricky to get that info.
So maybe one option is to use the VLC SDK (libVLC) to develop a lightweight player that uses VLC's engine, while keeping the feature you want to get?

Accessing Metadata from currently playing audio. (Builtin or External App)

I am trying to develop an app/widget for which I need display the currently playing information (metadata) of an audio track.
This would be trivial if I was also writing the MediaPlayer myself, as I could simply access the MediaStore and bring up the info, however, I do not wish to compete with the plethora of existing apps on this front. I want to be able to pull this inforrmation from the builtin audio player or other app such as SongBird or PowerAMP.
I should be able to do this with PowerAMP using their [API][1], but have, but I really want a solution that works for the stock android player and others too.
I was hoping to be able to grab the information from the AudioManager, but that seems only to allow me to query the current state (Music is playing et) and I can set my intent to play music, etc... But no access to metadata from someone elses app.
So my thought is this cannot be done easily. My thoughts are that I could maybe access this info from the info bar at the top as the now playing info is printed up there. It might be an ugly hack though...
For a moment I got excited about the RemoteControlClient.MetadataEditor from 4.0, but then I figured out that it was for writing that information to a stream that can be sent to the physical remote, rather than allowing you to create a software remote. Damn!
Does anyone have any ideas?
[1]: http://forum.powerampapp.com/index.php?/topic/1034-updated-for-20-poweramp-api-lib-and-sample-applications/ Power AMP
I've written a guide for implementing this.
Basically, you need to have access to hidden classes of android.jar library. Then you have to extend IRemoteControlDisplay$Stub class, and implement it's methods.
After that you register your RemoteControlDisplay with hidden method - AudioManager#registerRemoteControlDisplay.
There is just way too much to explain in one answer, so read my guide on XDA-Developers.
Here is the link:
http://forum.xda-developers.com/showpost.php?p=44513199
Also, I'm currently working on a library which will simplify the process of implementing you remote media controls.
I should be able to do this with PowerAMP using their [API][1], but have, but I really want a solution that works for the stock android player and others too.
There is no documented and supported API for the AOSP Music app or the Google Play Music app, AFAIK. They certainly are not in the Android SDK.
I am not aware of an Android ecosystem standard for media players exposing this information, let alone a roster of apps that support such a standard. You are welcome to work with the developers of such apps and encourage them to create and adopt a standard.
My thoughts are that I could maybe access this info from the info bar at the top as the now playing info is printed up there.
It is not possible to spy on other applications' Notifications, for obvious privacy and security reasons.
For a moment I got excited about the RemoteControlClient.MetadataEditor from 4.0, but then I figured out that it was for writing that information to a stream that can be sent to the physical remote, rather than allowing you to create a software remote. Damn!
Surely there's a way to access the Remote Control Client metadata on Android 4.0, because the lock screen is able to access it when media is playing.
I'm not a developer at all, but I've tried to do a bit of poking around in the AOKP sources and this is my limited understanding of how it works. At least in AOKP (and presumably AOSP as well, then), it appears that the lockscreen uses core/java/com/android/internal/widget/TransportControlView.java to draw the music control widget on the lockscreen, which in turn uses media/java/android/media/IRemoteControlDisplay.aidl for data retrieval. At the very least, it may be useful to poke around in TransportControlView.java to see if you can figure out how the lockscreen widget works.

Android streaming sound

I am doing a streamed musicplayer for android.
I have tried with MediaPlayer
mp.setDataSource("http://www.myServerPage.com/songUrl.mp3");
mp.prepare();
mp.start();
and it works but not good.
The prepare state is very slow and often the application is freezing.
I have searched a lot on forums and tutorials and as far as I can see this is the common way of doing it.
Do anyone know is it is another way of opening up a stream to play music from a server or have any good advices, maybe in NDK or by some other inputstream?
Thanks for the help.
/micke
The Media Playback article is pretty clear about how to deal with remote media sources: call prepareAsync() and set a listener to get notified when the source is ready for playing.
The reason for this is exactly what you're experiencing:
(...) the call to prepare() can take a long time to execute, because it
might involve fetching and decoding media data. So, as is the case
with any method that may take long to execute, you should never call
it from your application's UI thread. Doing that will cause the UI
to hang until the method returns, which is a very bad user experience
and can cause an ANR (Application Not Responding) error.
I suggest you go over the mentioned article for some more information and pointers that may help you with further development.

Categories

Resources