wowza云直播打不开

wowza cloud live streaming is not working

我正在使用 Wowza 流媒体云,它在网络上使用 HLS link 时工作正常,但 android 设备无法在网络上工作 view.can 你知道它是如何工作的吗?

并且 rtsp live link 也无法在 android 设备上工作

public class AnotherOne 扩展了 AppCompatActivity 实现 SurfaceHolder.Callback, MediaPlayer.OnPreparedListener{

private String Downloadurl;
private int playminute;
private SurfaceView mSurfaceView;
private MediaPlayer mMediaPlayer;
private SurfaceHolder mSurfaceHolder;
ProgressBar p_bar;

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_another_one);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    View decorView = getWindow().getDecorView();

    int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_FULLSCREEN;
    decorView.setSystemUiVisibility(uiOptions);


    Downloadurl = "https://7c6ad8.entrypoint.cloud.wowza.com/app-04be/ngrp:f23a3900_all/playlist.m3u8";
    // Description =  getIntent().getStringExtra("Description");
    Log.e("kanish","Download Url inside player:"+Downloadurl);
    mSurfaceView = (SurfaceView) findViewById(R.id.surfaceView);
    mSurfaceHolder = mSurfaceView.getHolder();
    mSurfaceHolder.addCallback(this);
}

@Override
public void surfaceCreated(SurfaceHolder holder) {
   // p_bar.setVisibility(View.VISIBLE);
    mMediaPlayer = new MediaPlayer();
    mMediaPlayer.setDisplay(mSurfaceHolder);
    try {
        mMediaPlayer.setDataSource(Downloadurl);
        mMediaPlayer.prepare();
        mMediaPlayer.setOnPreparedListener(AnotherOne.this);
        //mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
}

@Override
public void surfaceDestroyed(SurfaceHolder holder) {
}

@Override
public void onBackPressed() {
    super.onBackPressed();

}

@Override
public void onPrepared(MediaPlayer mp) {
    //p_bar.setVisibility(View.GONE);
    mMediaPlayer.start();
}

@Override
protected void onPause() {
    super.onPause();
    releaseMediaPlayer();
}

@Override
protected void onDestroy() {
    super.onDestroy();
    releaseMediaPlayer();
}

private void releaseMediaPlayer() {
    if (mMediaPlayer != null) {
        mMediaPlayer.release();
        mMediaPlayer = null;
    }
}

}

您需要声明一个视图来呈现视频视图和 您需要使用 Android 提供的媒体播放器 Api 来流式传输 m3u8.it 播放直播内容非常简单,请遵循此代码。

   public class PlayerActivity extends AppCompatActivity implements 
   SurfaceHolder.Callback, MediaPlayer.OnPreparedListener {


   private String Downloadurl;
   private int playminute;
   private SurfaceView mSurfaceView;
   private MediaPlayer mMediaPlayer;
   private SurfaceHolder mSurfaceHolder;
   ProgressBar p_bar;

    @Override
   protected void onCreate(Bundle savedInstanceState) {

   super.onCreate(savedInstanceState);
    setContentView(R.layout.player);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
     View decorView = getWindow().getDecorView();

    int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_FULLSCREEN;
    decorView.setSystemUiVisibility(uiOptions);


    Downloadurl = "YOUR M3U8 URL";
    // Description =  getIntent().getStringExtra("Description");
       Log.e("kanish","Download Url inside player:"+Downloadurl);
    mSurfaceView = (SurfaceView) findViewById(R.id.surface_view);
    mSurfaceHolder = mSurfaceView.getHolder();
    mSurfaceHolder.addCallback(PlayerActivity.this);
    }

     @Override
     public void surfaceCreated(SurfaceHolder holder) {
    p_bar.setVisibility(View.VISIBLE);
    mMediaPlayer = new MediaPlayer();
    mMediaPlayer.setDisplay(mSurfaceHolder);
    try {
        mMediaPlayer.setDataSource(Downloadurl);
        mMediaPlayer.prepare();
        mMediaPlayer.setOnPreparedListener(PlayerActivity.this);
        //mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
      } catch (IOException e) {
        e.printStackTrace();
      }
   }

   @Override
   public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
   }

   @Override
   public void surfaceDestroyed(SurfaceHolder holder) {
   }

   @Override
   public void onBackPressed() {
    super.onBackPressed();

    }

   @Override
   public void onPrepared(MediaPlayer mp) {
    p_bar.setVisibility(View.GONE);
    mMediaPlayer.start();
    }

   @Override
   protected void onPause() {
      super.onPause();
       releaseMediaPlayer();
      }

    @Override
    protected void onDestroy() {
    super.onDestroy();
    releaseMediaPlayer();
     }

   private void releaseMediaPlayer() {
      if (mMediaPlayer != null) {
        mMediaPlayer.release();
        mMediaPlayer = null;
    }
  }

}

如果有帮助请告诉我。