How to set proxy on MediaPlayer

£可爱£侵袭症+ 提交于 2019-12-03 21:01:24
yorkw

Unfortunately MediaPlayer API doesn't provide a ready-to-use method for proxy setting at the moment.

how can I do it?

There is a possible workaround but quite dirty:

  1. Download the media contents from the remoteUrl http://remotehost:80/music, using whatever technology you familiar with, socket, httpClient and etc. and handle proxy authentication properly here.
  2. Open a socket locally (on your mobile device) and write the downloaded data to this socket's OutputStream, what we actually want is republish the downloaded contents to a localUrl http://localhost:8081/music running on our mobile device.
  3. Feed this localUrl to your MediaPlayer: mediaPlayer.setDataSource(localURL); instead of mediaPlayer.setDataSource(remoteURL);.

Related Materials:

Hope this make sense.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!