我正在尝试将RTMPGW用作我的应用程序的一部分,这通常在Linux中运行良好。我正在尝试使用Vitamio捆绑来回放流。以下是主要代码,取自Vitamio Demo:
package io.vov.vitamio.demo;
import io.vov.vitamio.MediaPlayer;
import io.vov.vitamio.widget.MediaController;
import io.vov.vitamio.widget.VideoView;
import android.app.Activity;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
public class VideoViewDemo extends Activity {
private VideoView mVideoView;
/* (non-Javadoc)
* @see android.app.Activity#onCreate(android.os.Bundle)
*/
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
if (!io.vov.vitamio.LibsChecker.checkVitamioLibs(this))
return;
setContentView(R.layout.videoview);
mVideoView = (VideoView) findViewById(R.id.surface_view);
mVideoView.setVideoURI(Uri.parse("http://172.16.1.182:8902/?r=rtmp://live.dtv.cubecdn.net:80/kdmobil/KanalD1&W=http://www.kanald.com.tr/Content/swf/Canliplayer6.swf?config=/Content/swf/Config.xml%26debug=false&p=http://www.kanald.com.tr&c=80"));
mVideoView.setVideoQuality(MediaPlayer.VIDEOQUALITY_HIGH);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
if (mVideoView != null)
mVideoView.setVideoLayout(VideoView.VIDEO_LAYOUT_SCALE, 0);
super.onConfigurationChanged(newConfig);
}
}
当我运行它时,RTMPGW(我在Linux中从终端运行)显示此错误:
processTCPrequest, Range request not supported
..坐在那里,无所事事。
但是,当我使用常规Android VideoView和此代码时(在不同的项目中):
package com.sample.videoviewexample;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;
public class MainActivity extends Activity {
private VideoView mVideoView;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.activity_main);
mVideoView = (VideoView) findViewById(R.id.surface_view);
mVideoView.setVideoURI(Uri.parse("http://172.16.1.182:8902/?r=rtmp://live.dtv.cubecdn.net:80/kdmobil/KanalD1&W=http://www.kanald.com.tr/Content/swf/Canliplayer6.swf?config=/Content/swf/Config.xml%26debug=false&p=http://www.kanald.com.tr&c=80"));
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
}
}
它连接到RTMPGW服务器并像这样开始流式传输......
Streaming on http://0.0.0.0:8902
processTCPrequest, Range request not supported
Connecting ... port: 80, app: kdmobil/KanalD1
1094.914 KB / 16.90 sec
但是,当然,由于Android MediaPlayer本身不支持Flash,因此无法播放视频。
为什么VideoView与RTMPGW的服务器连接但Vitamio没有?
感谢您的帮助,
丹