Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

It is posible to cast or stream (Android-Chromecast) a local File?

I am developing a little music Player and I am trying to cast the current song to Chromecast. My app is based on Folders, so I manage mp3 or flac Files as songs.

I am following this Google Developers tutorial and I have written my Android Sender with the Media Chanel. If I do this, a song uploaded to dropbox plays succesfully on my TV.

    MediaMetadata mediaMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MUSIC_TRACK);

    MediaInfo mediaInfo = new MediaInfo.Builder(
    "https://dl.dropboxusercontent.com/u/56292608/MySong.mp3")
    .setContentType("audio/mp3")
    .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
    .setMetadata(mediaMetadata)
    .build()

mRemoteMediaPlayer.load(mApiClient, mediaInfo, true)

Is any way to cast or stream a File in order to set an URL?

I try with:

Uri.fromFile(myFile).toString()

but i can't send the file. Is any way to build the MediaInfo object reference from a local File path? If not, is any easy way to create a stream from a local path and send this stream to Chromecast?

In other case, it would be better transfering directly the multimedia sound from device with another approach?

Thanks for all

like image 491
Juanjo Avatar asked Dec 14 '25 17:12

Juanjo


1 Answers

It is possible. Most ways that I have encountered involve:

  1. Create a barebones HTTP web server on the Android device.
  2. Direct Chromecast to stream from your phone using the web server.
  3. The web server then streams the file to the Chromecast.
like image 124
Knossos Avatar answered Dec 16 '25 09:12

Knossos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!