我在服务器中上传了一个.mp4视频。公开了Java API以流式传输视频。小尺寸的视频可以正常播放,但是大尺寸的视频无法播放。 在android应用上,它显示“无法播放视频。”
以下是用于在android中显示视频的代码:
((FeedHomeViewHolder)holder).dareVideo.setVideoURI(vidUri, headers);
((FeedHomeViewHolder)holder).dareVideo.setZOrderOnTop(false);
((FeedHomeViewHolder)holder).buffering_textview.setVisibility(View.VISIBLE);
((FeedHomeViewHolder)holder).dareVideo.setOnErrorListener(new MediaPlayer.OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
Log.d(VolleyLog.TAG, "==========WHAT:"+what+" EXTRA:"+extra);
return true;
}
});
((FeedHomeViewHolder)holder).dareVideo.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
((FeedHomeViewHolder)holder).buffering_textview.setVisibility(View.GONE);
((FeedHomeViewHolder)holder).ic_media_play.setVisibility(View.VISIBLE);
((FeedHomeViewHolder)holder).dareVideo.seekTo(100);
//((FeedHomeViewHolder)holder).dareVideo.start();
}
});