四分屏:同时播放四路画面

四分屏:同时播放四路画面
pull/107/head
xufulong 6 years ago
parent 657780986e
commit df8570f873
  1. 12
      OnLive/src/main/AndroidManifest.xml
  2. 103
      OnLive/src/main/java/com/frank/living/activity/MultiScreenActivity.java
  3. 48
      OnLive/src/main/res/layout/activity_multi_screen.xml

@ -19,6 +19,18 @@
android:label="@string/app_name" android:label="@string/app_name"
android:screenOrientation="landscape" android:screenOrientation="landscape"
android:theme="@style/FullscreenTheme"> android:theme="@style/FullscreenTheme">
<!--<intent-filter>-->
<!--<action android:name="android.intent.action.MAIN" />-->
<!--<category android:name="android.intent.category.LAUNCHER" />-->
<!--</intent-filter>-->
</activity>
<activity
android:name="com.frank.living.activity.MultiScreenActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="landscape"
android:theme="@style/FullscreenTheme">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />

@ -0,0 +1,103 @@
package com.frank.living.activity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import com.frank.living.R;
import com.frank.living.listener.IjkPlayerListener;
import com.frank.living.widget.IjkVideoView;
import tv.danmaku.ijk.media.player.IjkMediaPlayer;
public class MultiScreenActivity extends AppCompatActivity implements IjkPlayerListener{
private final static String TAG = MultiScreenActivity.class.getSimpleName();
private IjkMediaPlayer ijkMediaPlayer;
private IjkVideoView mVideoView1;
private IjkVideoView mVideoView2;
private IjkVideoView mVideoView3;
private IjkVideoView mVideoView4;
private final static String url1 = "rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov";
private final static String url2 = "http://ivi.bupt.edu.cn/hls/cctv5phd.m3u8";
private final static String url3 = "rtmp://58.200.131.2:1935/livetv/hunantv";
private final static String url4 = "http://ivi.bupt.edu.cn/hls/cctv1hd.m3u8";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_multi_screen);
init();
}
private void init(){
IjkMediaPlayer.loadLibrariesOnce(null);
IjkMediaPlayer.native_profileBegin("libijkplayer.so");
mVideoView1 = (IjkVideoView) findViewById(R.id.video_view1);
mVideoView1.setIjkPlayerListener(this);
mVideoView1.setVideoPath(url1);
mVideoView1.start();
mVideoView2 = (IjkVideoView) findViewById(R.id.video_view2);
mVideoView2.setVideoPath(url2);
mVideoView2.start();
mVideoView3 = (IjkVideoView) findViewById(R.id.video_view3);
mVideoView3.setVideoPath(url3);
mVideoView3.start();
mVideoView4 = (IjkVideoView) findViewById(R.id.video_view4);
mVideoView4.setVideoPath(url4);
mVideoView4.start();
}
private void initOptions(){
if (ijkMediaPlayer == null)
return;
Log.e(TAG, "initOptions");
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "fast", 1);
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "probesize", 200);
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "flush_packets", 1);
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "packet-buffering", 0);
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "start-on-prepared", 1);
//0:代表关闭 1:代表开启
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec", 0);
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec-auto-rotate", 0);
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec-handle-resolution-change", 0);
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "max-buffer-size", 0);
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "min-frames", 2);
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "max_cached_duration", 30);
//input buffer:don't limit the input buffer size (useful with realtime streams)
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "infbuf", 1);
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "fflags", "nobuffer");
//ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "rtsp_transport", "tcp");
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "analyzedmaxduration", 100);
}
@Override
public void onIjkPlayer(IjkMediaPlayer ijkMediaPlayer) {
this.ijkMediaPlayer = ijkMediaPlayer;
initOptions();
}
@Override
protected void onStop() {
super.onStop();
mVideoView1.stopPlayback();
mVideoView1.release(true);
mVideoView2.stopPlayback();
mVideoView2.release(true);
mVideoView3.stopPlayback();
mVideoView3.release(true);
mVideoView4.stopPlayback();
mVideoView4.release(true);
IjkMediaPlayer.native_profileEnd();
}
}

@ -0,0 +1,48 @@
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/divider1"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/ijk_color_blue_800"
android:layout_centerVertical="true"/>
<View
android:id="@+id/divider2"
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/ijk_color_blue_800"
android:layout_centerHorizontal="true"/>
<com.frank.living.widget.IjkVideoView
android:id="@+id/video_view1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/divider1"
android:layout_toStartOf="@id/divider2"/>
<com.frank.living.widget.IjkVideoView
android:id="@+id/video_view2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/divider1"
android:layout_toEndOf="@id/divider2"/>
<com.frank.living.widget.IjkVideoView
android:id="@+id/video_view3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/divider1"
android:layout_toStartOf="@id/divider2"/>
<com.frank.living.widget.IjkVideoView
android:id="@+id/video_view4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/divider1"
android:layout_toEndOf="@id/divider2"/>
</RelativeLayout>
Loading…
Cancel
Save