在Android中直播电视流媒体

时间:2014-03-18 13:13:49

标签: android streaming television

嗨,我想在我的Android手机中打开直播电视,我使用此代码

package com.Slama.streamingtv;
import java.io.IOException;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    MediaPlayer m = new MediaPlayer(); 
    try {
        m.setDataSource("rtmp://ca-fss.tiscali.com/redirectsatchannel1/tvtunisi.stream");
          m.prepare(); 
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } 

    m.start(); 
}

}

或者我使用此代码

String LINK = "rtmp://ca-fss.tiscali.com/redirectsatchannel1/tvtunisi.stream";

        VideoView videoView = (VideoView) findViewById(R.id.video);
        MediaController mc = new MediaController(this);
        mc.setAnchorView(videoView);
        mc.setMediaPlayer(videoView);
        Uri video = Uri.parse(LINK);
        videoView.setMediaController(mc);
        videoView.setVideoURI(video);
        videoView.start();

但是没有显示视频,也没有发生任何事情,那么我应该怎么做才能修复我的代码?或者错误在哪里

0 个答案:

没有答案