Seeking / start media at desired position on Chromecast from Android from my own webserver

时间秒杀一切 提交于 2019-12-10 11:54:46

问题


I am currently developing a media application for Android that can cast it's media to a Google Chromecast.

This application is not meant to be published so some of the unorthodox choices I have made (web server, local files etc.) isn't part of the discussion.

The problem is that when I load a media stream to the Chromecast, or seek in the stream, it doesn't change. The callback says it succeeds, but the movie keeps playing from scratch (when I load with initial position) and doesn't change when I perform remoteMediaPlayer.seek(XX).

The movie that is playing locally is a file on the SD card. At the same time, the phone runs a Web server (KWS) and the chromecast is fed with this URL. This works perfecly otherwise - I can play, pause and change the movie playing. No problem there. But I do have the seek problem.

The reason I'm mentioning the web server is because when I run the URL "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" from googles samples, the seeking work.

Could anyone help me figure out what is different because I host the file myself? I saw posts mentioning that if the stream doesn't have a duration, remoteMediaPlayer cannot seek in it. But it does. A call to remoteMediaPlayer.getStreamDuration() returns the actual media duration.

There seems to be something in missing in how I host the files...

All help is appreciated.


回答1:


I have now solved my problem. If anyone else has this or a similar problem, use a web server that supports http progressive download. In the android specific case, this was an app called Boa Web server.




回答2:


I solved similar problem with NanoHttpd, solution was to add this response header

Accept-Ranges: bytes


来源:https://stackoverflow.com/questions/26464463/seeking-start-media-at-desired-position-on-chromecast-from-android-from-my-own

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