I want to send local mp3 files from my device to Chromecast. I allready have a version of Nanohttpd running and it works well, i can play my songs on my tv without problems with:
MediaMetadata mediaMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MUSIC_TRACK);
MediaInfo mediaInfo = new MediaInfo.Builder(
"http://192.168.0.XX:8080")
.setContentType("audio/mp3")
.setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
.setMetadata(mediaMetadata)
.build()
mRemoteMediaPlayer.load(mApiClient, mediaInfo, true) .....
...where "http://192.168.0.XX:8080" is my server url.
Now, i want to add a cover to my mediaMetadata, but, for this, i need to serve de picture file also, since this picture is sended as WebImage to Cromecast like this:
mediaMetadata.addImage(new WebImage(Uri.parse("My Url in Nanohttpd ")));
It could be possible to create a WebImage directly from resource??
If not, is any way to serve bouth (song and picture) simultaneously? Maybe I can serve the song in http: //192.168.0.XX:8080/song and the picture at http: //192.168.0.XX:8080/image or something like that, but i don't know how...
Here is my current Nanohttpd serve method:
@Override
public Response serve(String uri, Method method,
Map<String, String> header,
Map<String, String> parameters,
Map<String, String> files) {
String mediasend = "audio/mp3";
FileInputStream fis = null;
File song = new File(songLocalPath);
Log.e("Creando imputStream", "Size: ");
try {
fis = new FileInputStream(song);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Response.Status st = Response.Status.OK;
return new NanoHTTPD.Response(st, mediasend, fis,song.length());
}
Every aproach for this will be wellcome.
Well, finally I change serve method to have 2 URLS and distinguish between them:
And in the Sender App, to send the song:
and for the Album cover: