I am trying to play android local media on DLNA renders.
I am currently able to play any global visible media on DLNA renderer which have URI starts with http://172.168.1.1:4566/content_media/file1297834.mp3 this media is also play on any web browser,
But when I try to play local media which have file URI like file;//storage/content/media/file.mp3; is not playing on DLNA Renderer.
I am aware of that local file need to remotely visible for playing so I have try some options: -
First One I open a android socket and write file into output stream of socket.
But it is not playable on DLNA device.
I think it is because android socket write row data into out put stream which DLNA renderer is not able to read.
Second I try with "https://github.com/julesbou/simple-framework"
simple framework, It also help to open socket
with it some times media will play on DLNA renderer but it not at every time.
and other problem with it is that it is not taking media item METADATA.
Please suggest some solution for the problem
You can change file path to database id such as http://172_168.1.1:4566/id/5.
File path has the messy word problem in some device.
Related
I have a music player in Android, which uses android.media.MediaPlayer to play music from the SD card.
I would like to add the ability to cast the music to a Chromecast device.
I have played around with the democastplayer demo app. Specifically I tried to get the MediaRouteSelector to work with a 'live audio' route, but the 'cast' action button didn't show (suggesting live audio is not supported perhaps?). I also tried a few other things, but had no luck getting democastplayer to send MP3 audio to Chromecast.
Is streaming/sending local SD MP3 files to Chromecast even possible? If so, are there any sample apps or open source projects I can refer to?
Thanks in advance.
You need to add/write a small web server to your android application so it can serve the local media. Then have your sender application send the url of the media (that your local server is serving) to chromecast so it can play the music directly served from your phone.
Yes, Possible to stream your MP3 files by sending file url to chromecast device you can be using remote media player to load the media file. Refer this sample https://github.com/ovingalafsal/ChromeCastSampleApp it might be helpful
I want to stream an audio mp3 file and then play it through android media player plus I also want to cache this file, so that mediaplayer don't have to stream for recently played tracks.
I have tried using prepareAsync method but it doesn't give me access to buffer content, so I have decided to stream the audio file myself and then pass it to the media player for playing. I have achieved this by following this article here but this approach has a problem i.e. while transferring the file to media player it goes into error mode which causes my player to behave inconsistently.
When media player enters its error mode it doesn't come out of it automatically so I am forced to create a new media player and then re-provide it the downloaded file, this workaround causes the user to experience an undesired pause in the song playing.
So, does any one have improved an version of code given in above link? or do they know a better solution to this problem or is there is actually a library for streaming an audio file in android?
Thanks
The link you provided looks like a less than ideal solution (not to mention outdated). What you probably want is a local proxy server that gives you access to byte data before the MediaPlayer gets it. See my answer here for a little more explanation.
I have a FTP server setup that holds audio files in one of its directories. I would like to stream the audio from the server and play it on my Android phone instead of downloading it and playing it back that way. Also, is it possible to stream it to the MediaPlayer in Android for playback?
The FTP protocol does not support streaming audio or video.
However, you could set up a streaming server on the same box that will do it for you. I've used VLC to stream video and it's pretty easy to set up. Should work for audio too.
http://www.videolan.org/doc/streaming-howto/en/index.html
You can stream video over FTP. It is just a basic transfer protocol and once you have the data streaming to your device you can do what you want with it. Take a look at this tutorial if you want to set up streaming to your phone:
https://www.digitaldrugs.co.uk/wordpress/?p=37
Sure it is possible, the only problem I see is that your media files should be in a continuous file format, such as MP3. See shoutcast streaming for example, it works via http.
yxplayer is what you want, but it might be a bit limited
You can stream mp3 over FTP. Same way you can DL mp3 from ftp and listen to it before it's finished DLing. There's File Managers/Explorers like FX for one that will do this, but all it's streaming stuff is a trial or maybe by now a paid unlockable feature. Look for an open source remedy.
I'm trying to create a HTML5 page with embedded audio. The page has to work on a ZTE BASE Lutea smartphone (Android 2.1) with Opera Mobile 11. Audio format is MP3 but OGG would be fine, too. All files have to be stored local on the smartphones sdcard.
My problem:
While audio plays fine when loaded from a webserver, it fails when files are local. This is definitely not a source path error. The audio file is preloaded and I can alert the correct audio duration. Then, when the audio play() method is called, it throws me a MEDIA_ERR_DECODE.
This is always the same no matter if I use MP3, OGG or the original WAV file. Any idea why there is a decoding problem of local audio files?
EDIT: When I'm opening a local HTML page "file://localhost/sdcard/index.html" in Opera and the page embeds an audio "http://localhost/audio.mp3", it works. Of course I had to install a local webserver and this would be a very bad solution.
Why is the HTTP protocol needed to play an audio file, does something like a local sandbox exist on android?
EDIT: I found that the Video object is able to play local sounds without problems. Unfortunately it's useless to me because I need an invisible audio and in Opera Mobile there is no way to prevent the video from going fullscreen.
With PhoneGap, you should be able to play local audio.
Opera 12 has the same issue. If the audio is played from cache is not working.
I am using appcache.
This worked on Firefox mobile, so we used that.
Hello i am trying to get my android 2.2 app stream music. So far I have been able to stream from a radio station via the mediaPlayer.setDataSource("STREAM HERE")
I have tried with a m3u file and it won't work (unless my m3u file is wrong). Can it support xspf or what other file types?
How could i go about solving this problem?
thanks a lot
The setDataSource() method on the media player will accept file or URIs for a media source. Look at this list to see what media formats the media player accepts: http://developer.android.com/guide/appendix/media-formats.html
I am fairly certain that the media player will not play playlist files like M3U. You would have to create your own M3U player, which could be accomplished via the MediaPlayer method: setOnCompletionListener(MediaPlayer.OnCompletionListener listener)
Register a callback to be invoked when the end of a media source has been reached during playback.
When playback is done, you could start playing the next media resource in your playlist.