SJS*_*oft 36 streaming android live rtsp wowza
我正在尝试开发一个基于Android的应用程序,它可以从实时流播放视频.此直播流使用Wowza Media Server生成.
URL是:
rtsp://tv.hindiworldtv.com:1935/live/getpun
Run Code Online (Sandbox Code Playgroud)
我试过在ecliplse中使用以下代码:
package com.kalloh.wpa;
import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.net.Uri;
import android.os.Bundle;
import android.view.Window;
import android.widget.MediaController;
import android.widget.VideoView;
public class a extends Activity {
VideoView videoView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
//Create a VideoView widget in the layout file
//use setContentView method to set content of the activity to the layout file which contains videoView
this.setContentView(R.layout.videoplayer);
videoView = (VideoView)this.findViewById(R.id.videoView);
//add controls to a MediaPlayer like play, pause.
MediaController mc = new MediaController(this);
videoView.setMediaController(mc);
//Set the path of Video or URI
videoView.setVideoURI(Uri.parse("rtsp://tv.hindiworldtv.com:1935/live/getpnj"));
//
//Set the focus
videoView.requestFocus();
}
}
Run Code Online (Sandbox Code Playgroud)
起初它没有用.
现在它开始工作,但它在20到30秒后停止.我该如何解决这个问题?
Jor*_*sys 14
使用VideoView是一个很好的解决方案,但我们也可以使用它native player
来播放RTSP.这是一个例子:
if (movieurl.startsWith("rtsp://")) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(movieurl));
startActivity(intent);
}
Run Code Online (Sandbox Code Playgroud)
请记住,您的媒体必须使用Android支持的媒体格式(编解码器)创建.
归档时间: |
|
查看次数: |
85133 次 |
最近记录: |