以编程方式将视频从php服务器流到android服务器

时间:2023-01-27 23:49:14

I have a url to a video. I want to stream the video to my application. I can download the video file completely and then play it but i want that while downloading the video the video should also be played, like in youtube. I have a php server running which has the video on it. I have seen this question being asked but there were no answers for any of the questions.

我有一个视频的url。我想把视频传输到我的应用程序。我可以下载完整的视频文件,然后播放它,但是我想在下载视频的同时也播放视频,就像在youtube上一样。我有一个php服务器运行它上面有视频。我曾看到有人问过这个问题,但没有任何问题的答案。

3 个解决方案

#1


9  

You can go through code

你可以通过代码。

void playvideo(String url) 
{
     String  link=url;
     Log.e("url",link);
     view1 = (VideoView) findViewById(R.id.myVideoView); 
      getWindow().setFormat(PixelFormat.TRANSLUCENT);

      MediaController mc = new MediaController(this); 
      mc.setMediaPlayer(view1); 

      view1.setMediaController(mc); 
      view1.setVideoURI(Uri.parse(link)); 
      view1.requestFocus(); 
      view1.start();

 }

#2


0  

Assuming you are using an .mp4 container or similar, you need to use a program such as qt-faststart (under linux) to move the moov atom (containing data on keyframes etc., I believe) to the begining of the video. That way the video can play prior to the whole video being downloaded.

假设您正在使用一个.mp4容器或类似的容器,您需要使用一个程序,如qt-faststart(在linux下)将moov原子(我相信包含关键帧上的数据等)移动到视频的开始。这样,视频可以在整个视频被下载之前播放。

#3


0  

your video file may not be set up for progressive download, which is required for HTTP streaming

您的视频文件可能没有设置为渐进式下载,这是HTTP流媒体所需要的

#1


9  

You can go through code

你可以通过代码。

void playvideo(String url) 
{
     String  link=url;
     Log.e("url",link);
     view1 = (VideoView) findViewById(R.id.myVideoView); 
      getWindow().setFormat(PixelFormat.TRANSLUCENT);

      MediaController mc = new MediaController(this); 
      mc.setMediaPlayer(view1); 

      view1.setMediaController(mc); 
      view1.setVideoURI(Uri.parse(link)); 
      view1.requestFocus(); 
      view1.start();

 }

#2


0  

Assuming you are using an .mp4 container or similar, you need to use a program such as qt-faststart (under linux) to move the moov atom (containing data on keyframes etc., I believe) to the begining of the video. That way the video can play prior to the whole video being downloaded.

假设您正在使用一个.mp4容器或类似的容器,您需要使用一个程序,如qt-faststart(在linux下)将moov原子(我相信包含关键帧上的数据等)移动到视频的开始。这样,视频可以在整个视频被下载之前播放。

#3


0  

your video file may not be set up for progressive download, which is required for HTTP streaming

您的视频文件可能没有设置为渐进式下载,这是HTTP流媒体所需要的