增加直播暂停、静音

增加直播暂停、静音
pull/107/head
xufulong 6 years ago
parent 5abd5cc1a9
commit 41048642d8
  1. 1
      OnLive/.gitignore
  2. 44
      OnLive/src/main/java/com/frank/living/activity/RtspLiveActivity.java
  3. BIN
      OnLive/src/main/res/drawable-xhdpi/ic_action_dark_aspect_ratio.png
  4. BIN
      OnLive/src/main/res/drawable-xhdpi/ic_action_dark_filter.png
  5. BIN
      OnLive/src/main/res/drawable-xhdpi/ic_action_dark_settings.png
  6. BIN
      OnLive/src/main/res/drawable-xhdpi/ic_pause.png
  7. BIN
      OnLive/src/main/res/drawable-xhdpi/ic_play.png
  8. BIN
      OnLive/src/main/res/drawable-xhdpi/ic_silence.png
  9. BIN
      OnLive/src/main/res/drawable-xhdpi/ic_sound.png
  10. BIN
      OnLive/src/main/res/drawable-xhdpi/ic_theme_description.png
  11. BIN
      OnLive/src/main/res/drawable-xhdpi/ic_theme_folder.png
  12. BIN
      OnLive/src/main/res/drawable-xhdpi/ic_theme_play_arrow.png
  13. BIN
      OnLive/src/main/res/drawable-xxhdpi/ic_action_dark_aspect_ratio.png
  14. BIN
      OnLive/src/main/res/drawable-xxhdpi/ic_action_dark_filter.png
  15. BIN
      OnLive/src/main/res/drawable-xxhdpi/ic_action_dark_settings.png
  16. BIN
      OnLive/src/main/res/drawable-xxhdpi/ic_pause.png
  17. BIN
      OnLive/src/main/res/drawable-xxhdpi/ic_play.png
  18. BIN
      OnLive/src/main/res/drawable-xxhdpi/ic_silence.png
  19. BIN
      OnLive/src/main/res/drawable-xxhdpi/ic_sound.png
  20. BIN
      OnLive/src/main/res/drawable-xxhdpi/ic_theme_description.png
  21. BIN
      OnLive/src/main/res/drawable-xxhdpi/ic_theme_folder.png
  22. BIN
      OnLive/src/main/res/drawable-xxhdpi/ic_theme_play_arrow.png
  23. 19
      OnLive/src/main/res/layout/activity_live.xml
  24. 2
      README.md

1
OnLive/.gitignore vendored

@ -0,0 +1 @@
/build

@ -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();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 525 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 929 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 942 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

@ -13,6 +13,25 @@
android:layout_gravity="center"> android:layout_gravity="center">
</com.frank.living.widget.IjkVideoView> </com.frank.living.widget.IjkVideoView>
<ImageButton
android:id="@+id/btn_play"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="@drawable/ic_pause"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"/>
<ImageButton
android:id="@+id/btn_sound"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="@drawable/ic_silence"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginEnd="20dp"
android:layout_marginBottom="10dp"/>
<TableLayout <TableLayout
android:id="@+id/hud_view" android:id="@+id/hud_view"
android:layout_width="wrap_content" android:layout_width="wrap_content"

@ -66,7 +66,5 @@ android端基于FFmpeg库的使用。<br>
![动态图片](https://github.com/xufuji456/FFmpegAndroid/blob/master/gif/reverse.gif) ![动态图片](https://github.com/xufuji456/FFmpegAndroid/blob/master/gif/reverse.gif)
*** ***
后续会完善音视频播放、推流直播。
<br><br> <br><br>

Loading…
Cancel
Save