界面是先点击“启动本地RTSP服务器”,然后再点击“开始播放”
然后就出现“Cannot play video sorry this video cannot be played”
发送端我是用VLC播放器将MP4或3pg视频进行RTSP的串流,然后接收端是用VIDEOVIEW进行播放
下面是我的代码,求大神帮忙看下究竟是哪里的问题,小弟感激不尽package com.android.rtsp;import java.io.IOException;
import java.net.ServerSocket;import com.android.rtsp.RtspEnumType.RtspType;import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.VideoView;public class rtspAcitivity extends Activity implements StartRtspListener{
Button btn;
Button start;
VideoView videoView;
ServerSocket server = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btn = (Button)this.findViewById(R.id.play);
btn.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v) {
try {
server = new ServerSocket (5540);
} catch (IOException e) {
e.printStackTrace();
}
rtspThread rtsp = new rtspThread(rtspAcitivity.this,0,server);
}
});
videoView = (VideoView)this.findViewById(R.id.videoview);
start = (Button)this.findViewById(R.id.start);
start.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v) {
videoView.setVideoURI(Uri.parse("RTSP地址"));
videoView.requestFocus();
videoView.start();
}
});
} public void StartVideoViewRtsp(int whichOne, RtspType eventCode,rtspThread server){
rtspAcitivity.this.runOnUiThread(new Runnable(){
public void run() {
videoView.setVideoURI(Uri.parse("RTSP地址"));
videoView.requestFocus();
videoView.start();
}
});
} @Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK)
{
try {
server.close();
server = null;
} catch (IOException e) {
e.printStackTrace();
}
}
return super.onKeyDown(keyCode, event);
}
}
然后就出现“Cannot play video sorry this video cannot be played”
发送端我是用VLC播放器将MP4或3pg视频进行RTSP的串流,然后接收端是用VIDEOVIEW进行播放
下面是我的代码,求大神帮忙看下究竟是哪里的问题,小弟感激不尽package com.android.rtsp;import java.io.IOException;
import java.net.ServerSocket;import com.android.rtsp.RtspEnumType.RtspType;import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.VideoView;public class rtspAcitivity extends Activity implements StartRtspListener{
Button btn;
Button start;
VideoView videoView;
ServerSocket server = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btn = (Button)this.findViewById(R.id.play);
btn.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v) {
try {
server = new ServerSocket (5540);
} catch (IOException e) {
e.printStackTrace();
}
rtspThread rtsp = new rtspThread(rtspAcitivity.this,0,server);
}
});
videoView = (VideoView)this.findViewById(R.id.videoview);
start = (Button)this.findViewById(R.id.start);
start.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v) {
videoView.setVideoURI(Uri.parse("RTSP地址"));
videoView.requestFocus();
videoView.start();
}
});
} public void StartVideoViewRtsp(int whichOne, RtspType eventCode,rtspThread server){
rtspAcitivity.this.runOnUiThread(new Runnable(){
public void run() {
videoView.setVideoURI(Uri.parse("RTSP地址"));
videoView.requestFocus();
videoView.start();
}
});
} @Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK)
{
try {
server.close();
server = null;
} catch (IOException e) {
e.printStackTrace();
}
}
return super.onKeyDown(keyCode, event);
}
}
解决方案 »
- 求一个可以发布微博的闹钟程序代码
- 下拉列表问题
- android 原生music播放器源码
- Android 驱动中如何发送触摸屏multi-touch的抬起事件
- 在Java中如何声明对应C#的数据类型int?,DateTime?
- 系统中的哪个路径,程序是可以随便使用的 ??
- jarsigner签名报错Invalid keystore format
- 上传图片压缩
- 求助关于android的Get请求
- android内存管理,垃圾回收策略的疑惑
- expandablelistView 展开的View设置一个大背景
- developer.android.com 上不去了 我们的系统检测到您的计算机网络中存在异常流量
可以将你的视频放到板子上,先确保用Gallery能正常播放。2.我记得android4.0里的Nuplayer还没实现好,是不能直接播放rtsp码流的