Stream video while downloading iOS

后端 未结 3 1199
故里飘歌
故里飘歌 2021-01-30 05:44

I am using iOS 7 and I have a .mp4 video that I need to download in my app. The video is large (~ 1 GB) which is why it is not included as part of the app. I want the user to be

3条回答
  •  梦谈多话
    2021-01-30 06:32

    You gotta create an internal webserver that acts like a proxy! Then set your player to play the movie from the localhost.

    When using HTTP protocol to play a video with MPMoviePlayerViewController, the first thing the player does is to ask for the byte-range 0-1 (first 2 bytes) just to obtain the file length. Then, the player asks for "chunks" of the video using the "byte-range" HTTP command (the purpose is to save some battery).

    What you have to do is to implement this internal server that delivers the video to the player, but your "proxy" must consider the length of your video as the full length of the file, even if the actual file hasn't been completely downloaded from the internet.

    Then you you set your player to play a movie from " http:// localhost : someport "

    I've done this before... it works perfectly!

    Good luck!

提交回复
热议问题