First of all, I'm not good at english. sorry.
What I want to make is music broadcasting service.
When I select music from android device, it sended to the server in real time, and server broadcasts it to another.
But I don't know how to send mp3 file to server in real time.
Can I get some ideas or samples?
Please help me....I searching for example codes for a long time but I can get anything....
I have tried AudioStream, but it looks like can send MIC only.
When you select a music file, mp3 for instance, there will be no ACTION broadcast. So you can't capture this operation through BoradcastReceiver.
You can create an app for user to choose when they select a music file, then you can send the file to server as you like in your app. This can be done by adding intent-filter in your Manifest file.
Hope this helps you.
Related
I tried using a Android phone to cast to Chromecast device by Youtube app. I added some Videos to queue, then I used another phone to cast to Chromecast device. The second one automatically knows the videos added to queue on the first one.
I don't know how Youtube app can do this?
EDIT I guess Youtube app uses one custom data channel besides Media channel. When Video is added to queue, sender app will send somethings (eg: videoId) to receiver. Receiver will save it in array of video ID. When another phone connects to Chromecast device, It'll receiver array of video ID from the receiver. Can anyone give other solutions? Thanks
I guess what you are asking is how you can create a play list, potentially shared by multiple devices. If that is the case, you have a couple of choices:
keep the playlist in the receiver: this is the simplest option. This will be a simple array on the receiver, kept in memory, which will go away when application ends. A custom receiver is required and it can implement the methods such as "append, insert, get, clear, ... to provide what the senders need. When each sender connects, it can ask (calling 'get' for example) for the current "queue" and then can modify the queue by other methods such as 'clear', 'append', 'insert', .... Note that there is no long-term persistence on the receiver (local storage is available but will be cleared as son as the app is gone).
keep the playlist in the cloud: you need to do most of the things that you do in the previous option but you also persist the playlist to the cloud; the advantage is that playlist lasts beyond the life of a session (this may or may not be desired). In addition, sender apps can potentially get the playlist fro the cloud directly, if needed.
The important thing is that the main storage for your playlist is not your sender devices; they don't know (and shouldn't know) abut the presence of other senders in the eco-system.
On the receiver side, we recently published a simple sample that sows how the notion of (local) playlist can be implemented; that is a simplified example but is enough to show that with minimal work, you can take advantage of the Media Channel; for more sophisticated handling of a shared queue, you definitely need an out-of-bound channel/namespace to handle all the additional api's that I mentioned above.
In chromecast
i want to send different kinds of url(mp4/mp3/png..) to the receiver,but how does the receiver to show them dynamically?
this is: how does the receiver recogonize what kind of the RemoteMedia received?
In the current version of the SDK, there is nothing from the framework side to help you with that directly. You can include the mimetype in the metadata and retrieve that on your receiver and do as you see fit. That said, if your media is only audio or video, things are better since the video element can handle both and you can just treat them the same but for images, you have to do some other work. Another approach is to look at the extension and try to guess the type but that is not fully reliable.
thanks for previous replies,
Is it possible to get package name of active and runningin service(background) music player. I can able to get the music actions(metachage or playstateChange) but when i use intent.getPackagename, im getting null. can anyone guide me on how to get the package name of music player.
Thanks!
Supplying the file URL and open it in browser does not make sense, because this URLs expire after a wile.
No, insofar as there is nothing magic in Android that denotes a "music player" from anything else.
I can start my application by simply putting the phone on a NFC-tag. But I would like to take the idea one step further. Imagine a simple time-tracking application with two NFC-tags. The first will start (and download) the application and register a starttime. The other will also start (and download) the application, but register a stoptime.
My problem I'd like to solve is that I don't want my phone to know about these tags. The application should not need to have a list of tag-ids programmed and know what actions that is connected to each id. The tag should carry the information needed to start the action on the phone with the correct parameters.
Are there any information about how to accomplish this scenario? I have installed "nfc-eclipse-plugin" but doesn't understand how to use it to get my goal and even less how to get my application to read the extra data.
Thanks in advance
Roland
Your tags should be capable of storing NDEF messages. Such messages are automatically read out by Android and passed to your app in an Intent. Automatically installing and/or starting your app can be accomplished by putting an Android Application Record in your tag. Any additional information ("start" or "stop" indication) can be stored in a proprietary record.
You probably want to put the AAR as the last record of the NDEF message, as it is detected and acted upon by Android automatically, but is only supported since ICS. To make automatic installation work with Gingerbread, you can put an additional URI record or SmartPoster record with a Google Play Store link in it as the first record of the message. Your app should then filter (ACTION_NDEF_DISCOVERED) for this URI, so it will also start automatically on Gingerbread.
I have an application that scans the sd-card and make a list of video files stored in it. Then there is an option of playing the video files. All I want to know is
1- How can I register various actions or notifications like Action.Media.Unmount, Action.Media.Bad.Removal etc in my Manifest file
2- How can I use the braodcast receiver in my code.. I have tried couple of codes but they didn't work. If someone can give me of an example here, I shall be greatly thankful..
Thanks all
You really should read the documentation. It's a fairly simple method to register a BroadcastReceiver for those Intents.
Just read here and here.
If, after reading you still have some kind of problem, just say what error are you getting and the code/xml you're using.