|
|
@ -3,18 +3,24 @@ package com.frank.living.activity; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.support.v7.app.AppCompatActivity; |
|
|
|
import android.support.v7.app.AppCompatActivity; |
|
|
|
import android.util.Log; |
|
|
|
import android.util.Log; |
|
|
|
|
|
|
|
import android.view.View; |
|
|
|
|
|
|
|
import android.widget.ImageButton; |
|
|
|
import android.widget.TableLayout; |
|
|
|
import android.widget.TableLayout; |
|
|
|
import com.frank.living.R; |
|
|
|
import com.frank.living.R; |
|
|
|
import com.frank.living.listener.IjkPlayerListener; |
|
|
|
import com.frank.living.listener.IjkPlayerListener; |
|
|
|
import tv.danmaku.ijk.media.player.IjkMediaPlayer; |
|
|
|
import tv.danmaku.ijk.media.player.IjkMediaPlayer; |
|
|
|
import com.frank.living.widget.IjkVideoView; |
|
|
|
import com.frank.living.widget.IjkVideoView; |
|
|
|
|
|
|
|
|
|
|
|
public class RtspLiveActivity extends AppCompatActivity implements IjkPlayerListener{ |
|
|
|
public class RtspLiveActivity extends AppCompatActivity implements IjkPlayerListener, View.OnClickListener{ |
|
|
|
|
|
|
|
|
|
|
|
private final static String TAG = RtspLiveActivity.class.getSimpleName(); |
|
|
|
private final static String TAG = RtspLiveActivity.class.getSimpleName(); |
|
|
|
|
|
|
|
|
|
|
|
private IjkMediaPlayer ijkMediaPlayer; |
|
|
|
private IjkMediaPlayer ijkMediaPlayer; |
|
|
|
private IjkVideoView mVideoView; |
|
|
|
private IjkVideoView mVideoView; |
|
|
|
|
|
|
|
private ImageButton btnPlay; |
|
|
|
|
|
|
|
private ImageButton btnSound; |
|
|
|
|
|
|
|
private boolean isPause; |
|
|
|
|
|
|
|
private boolean isSilence; |
|
|
|
|
|
|
|
|
|
|
|
private final static String url = "rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov"; |
|
|
|
private final static String url = "rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov"; |
|
|
|
|
|
|
|
|
|
|
@ -37,6 +43,12 @@ public class RtspLiveActivity extends AppCompatActivity implements IjkPlayerList |
|
|
|
mVideoView.setIjkPlayerListener(this); |
|
|
|
mVideoView.setIjkPlayerListener(this); |
|
|
|
mVideoView.setVideoPath(url); |
|
|
|
mVideoView.setVideoPath(url); |
|
|
|
mVideoView.start(); |
|
|
|
mVideoView.start(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
btnPlay = (ImageButton) findViewById(R.id.btn_play); |
|
|
|
|
|
|
|
btnPlay.setOnClickListener(this); |
|
|
|
|
|
|
|
btnSound = (ImageButton) findViewById(R.id.btn_sound); |
|
|
|
|
|
|
|
btnSound.setOnClickListener(this); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initOptions(){ |
|
|
|
private void initOptions(){ |
|
|
@ -68,6 +80,36 @@ public class RtspLiveActivity extends AppCompatActivity implements IjkPlayerList |
|
|
|
initOptions(); |
|
|
|
initOptions(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onClick(View v) { |
|
|
|
|
|
|
|
switch (v.getId()){ |
|
|
|
|
|
|
|
case R.id.btn_play: |
|
|
|
|
|
|
|
isPause = !isPause; |
|
|
|
|
|
|
|
if (isPause){//直播暂停
|
|
|
|
|
|
|
|
mVideoView.pause(); |
|
|
|
|
|
|
|
btnPlay.setBackgroundResource(R.drawable.ic_play); |
|
|
|
|
|
|
|
}else {//直播继续
|
|
|
|
|
|
|
|
mVideoView.start(); |
|
|
|
|
|
|
|
btnPlay.setBackgroundResource(R.drawable.ic_pause); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case R.id.btn_sound: |
|
|
|
|
|
|
|
isSilence = !isSilence; |
|
|
|
|
|
|
|
if (ijkMediaPlayer == null) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
if (isSilence){ |
|
|
|
|
|
|
|
ijkMediaPlayer.setVolume(0, 0); |
|
|
|
|
|
|
|
btnSound.setBackgroundResource(R.drawable.ic_sound); |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
ijkMediaPlayer.setVolume(50, 50); |
|
|
|
|
|
|
|
btnSound.setBackgroundResource(R.drawable.ic_silence); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void onStop() { |
|
|
|
protected void onStop() { |
|
|
|
super.onStop(); |
|
|
|
super.onStop(); |
|
|
|