Skip to content

Commit

Permalink
同步升级ijkplayer
Browse files Browse the repository at this point in the history
  • Loading branch information
Leifzhang committed Oct 31, 2016
1 parent 67d97bc commit 12b2a93
Show file tree
Hide file tree
Showing 26 changed files with 67 additions and 168 deletions.
4 changes: 2 additions & 2 deletions IjkLib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ android {
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'tv.danmaku.ijk.media:ijkplayer-java:0.4.5.1'
compile 'tv.danmaku.ijk.media:ijkplayer-exo:0.4.5.1'
compile 'tv.danmaku.ijk.media:ijkplayer-java:0.6.3'
compile 'tv.danmaku.ijk.media:ijkplayer-exo:0.6.3'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:preference-v7:23.2.1'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.support.v7.app.ActionBar;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;

Expand Down Expand Up @@ -72,6 +73,8 @@ public void hide() {
mShowOnceArray.clear();
}



//----------
// Extends
//----------
Expand All @@ -84,7 +87,7 @@ public void showOnce(@NonNull View view) {
}

@Override
public void setAnchorView(View view) {
public void setAnchorView(ViewGroup view) {
super.setAnchorView(view);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
package tv.danmaku.ijk.media.widget.media;

import android.view.View;
import android.view.ViewGroup;
import android.widget.MediaController;

public interface IMediaController {
void hide();

boolean isShowing();

void setAnchorView(View view);
void setAnchorView(ViewGroup view);

void setEnabled(boolean enabled);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.MediaController;
import android.widget.TableLayout;
Expand Down Expand Up @@ -351,8 +352,7 @@ public void setMediaController(IMediaController controller) {

private void attachMediaController() {
if (mMediaPlayer != null && mMediaController != null) {
View anchorView = this.getParent() instanceof View ?
(View) this.getParent() : this;
ViewGroup anchorView = this;
mMediaController.setAnchorView(anchorView);
mMediaController.setMediaPlayer(this);
mMediaController.setEnabled(isInPlaybackState());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
package tv.danmaku.ijk.media.widget.media;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.PixelFormat;
import android.media.AudioManager;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.MediaController;
Expand All @@ -37,12 +31,8 @@ public class PlayerMediaController extends FrameLayout {

private MediaController.MediaPlayerControl mPlayer;
private final Context mContext;
private View mAnchor;
private ViewGroup mAnchor;
private View mRoot;
private WindowManager mWindowManager;
private Window mWindow;
private View mDecor;
private WindowManager.LayoutParams mDecorLayoutParams;
protected ProgressBar mProgress;
protected TextView mEndTime, mCurrentTime;
private boolean mShowing;
Expand Down Expand Up @@ -79,7 +69,6 @@ public PlayerMediaController(Context context, boolean useFastForward) {
super(context);
mContext = context;
mUseFastForward = useFastForward;
initFloatingWindowLayout();
initFloatingWindow();
}

Expand All @@ -88,43 +77,14 @@ public PlayerMediaController(Context context) {
}

private void initFloatingWindow() {
mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
Dialog dialog = new Dialog(mContext);
mWindow = dialog.getWindow();
mWindow.setWindowManager(mWindowManager, null, null);
mWindow.requestFeature(Window.FEATURE_NO_TITLE);
mDecor = mWindow.getDecorView();
mDecor.setOnTouchListener(mTouchListener);
mWindow.setContentView(this);
mWindow.setBackgroundDrawableResource(android.R.color.transparent);

// While the media controller is up, the volume control keys should
// affect the media stream type
mWindow.setVolumeControlStream(AudioManager.STREAM_MUSIC);

//setOnTouchListener(mTouchListener);
setFocusable(true);
setFocusableInTouchMode(true);
setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
requestFocus();
}

// Allocate and initialize the static parts of mDecorLayoutParams. Must
// also call updateFloatingWindowLayout() to fill in the dynamic parts
// (y and width) before mDecorLayoutParams can be used.
private void initFloatingWindowLayout() {
mDecorLayoutParams = new WindowManager.LayoutParams();
WindowManager.LayoutParams p = mDecorLayoutParams;
p.gravity = Gravity.TOP | Gravity.LEFT;
p.height = LayoutParams.WRAP_CONTENT;
p.x = 0;
p.format = PixelFormat.TRANSLUCENT;
p.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
p.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM
| WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
| WindowManager.LayoutParams.FLAG_SPLIT_TOUCH;
p.token = null;
p.windowAnimations = 0; // android.R.style.DropDownAnimationDown;
}


// Update the dynamic parts of mDecorLayoutParams
// Must be called with mAnchor != NULL.
Expand All @@ -134,13 +94,6 @@ private void updateFloatingWindowLayout() {

// we need to know the size of the controller so we can properly position it
// within its space
mDecor.measure(MeasureSpec.makeMeasureSpec(mAnchor.getWidth(), MeasureSpec.AT_MOST),
MeasureSpec.makeMeasureSpec(mAnchor.getHeight(), MeasureSpec.AT_MOST));

WindowManager.LayoutParams p = mDecorLayoutParams;
p.width = mAnchor.getWidth();
p.x = anchorPos[0] + (mAnchor.getWidth() - p.width) / 2;
p.y = anchorPos[1] + mAnchor.getHeight() - mDecor.getMeasuredHeight();
}

// This is called whenever mAnchor's layout bound changes
Expand All @@ -152,12 +105,12 @@ public void onLayoutChange(View v, int left, int top, int right,
int oldBottom) {
updateFloatingWindowLayout();
if (mShowing) {
mWindowManager.updateViewLayout(mDecor, mDecorLayoutParams);
//mWindowManager.updateViewLayout(mDecor, mDecorLayoutParams);
}
}
};

private final OnTouchListener mTouchListener = new OnTouchListener() {
/* private final OnTouchListener mTouchListener = new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
Expand All @@ -167,7 +120,7 @@ public boolean onTouch(View v, MotionEvent event) {
}
return false;
}
};
};*/

public void setMediaPlayer(MediaController.MediaPlayerControl player) {
mPlayer = player;
Expand All @@ -183,23 +136,20 @@ public void setMediaPlayer(MediaController.MediaPlayerControl player) {
*
* @param view The view to which to anchor the controller when it is visible.
*/
public void setAnchorView(View view) {
public void setAnchorView(ViewGroup view) {
if (mAnchor != null) {
mAnchor.removeOnLayoutChangeListener(mLayoutChangeListener);
}
mAnchor = view;
if (mAnchor != null) {
mAnchor.addOnLayoutChangeListener(mLayoutChangeListener);
}

LayoutParams frameParams = new LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
);

removeAllViews();
View v = makeControllerView();
addView(v, frameParams);
addView(v, ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
mAnchor.addView(this, ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
}


Expand Down Expand Up @@ -280,7 +230,7 @@ public void show(int timeout) {
}
disableUnsupportedButtons();
updateFloatingWindowLayout();
mWindowManager.addView(mDecor, mDecorLayoutParams);
mRoot.setVisibility(View.VISIBLE);
mShowing = true;
}
updatePausePlay();
Expand Down Expand Up @@ -311,7 +261,7 @@ public void hide() {
if (mShowing) {
try {
mHandler.removeMessages(SHOW_PROGRESS);
mWindowManager.removeView(mDecor);
mRoot.setVisibility(View.GONE);
} catch (IllegalArgumentException ex) {
Log.w("MediaController", "already removed");
}
Expand Down Expand Up @@ -399,13 +349,13 @@ private int setProgress() {
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
show(0); // show until hide is called
break;
case MotionEvent.ACTION_UP:
show(sDefaultTimeout); // start timeout
break;
case MotionEvent.ACTION_CANCEL:
hide();
if (!isShowing()) {
show(sDefaultTimeout); // show until hide is called
} else {
hide();
}
break;
default:
break;
Expand Down
Binary file added IjkLib/src/main/jniLibs/arm64-v8a/libijkffmpeg.so
Binary file not shown.
Binary file not shown.
Binary file added IjkLib/src/main/jniLibs/arm64-v8a/libijksdl.so
Binary file not shown.
Binary file modified IjkLib/src/main/jniLibs/armeabi-v7a/libijkffmpeg.so
Binary file not shown.
Binary file modified IjkLib/src/main/jniLibs/armeabi-v7a/libijkplayer.so
Binary file not shown.
Binary file modified IjkLib/src/main/jniLibs/armeabi-v7a/libijksdl.so
Binary file not shown.
Binary file modified IjkLib/src/main/jniLibs/armeabi/libijkffmpeg.so
Binary file not shown.
Binary file modified IjkLib/src/main/jniLibs/armeabi/libijkplayer.so
Binary file not shown.
Binary file modified IjkLib/src/main/jniLibs/armeabi/libijksdl.so
Binary file not shown.
Binary file modified IjkLib/src/main/jniLibs/x86/libijkffmpeg.so
Binary file not shown.
Binary file modified IjkLib/src/main/jniLibs/x86/libijkplayer.so
Binary file not shown.
Binary file modified IjkLib/src/main/jniLibs/x86/libijksdl.so
Binary file not shown.
Binary file modified IjkLib/src/main/jniLibs/x86_64/libijkffmpeg.so
Binary file not shown.
Binary file modified IjkLib/src/main/jniLibs/x86_64/libijkplayer.so
Binary file not shown.
Binary file modified IjkLib/src/main/jniLibs/x86_64/libijksdl.so
Binary file not shown.
13 changes: 9 additions & 4 deletions IjkLib/src/main/res/layout/ijk_media_control.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="match_parent">


<ImageView
android:id="@+id/iv_background"
android:layout_width="match_parent"
android:layout_height="70dp"
android:scaleType="centerCrop"/>
android:scaleType="centerCrop"
android:layout_alignParentBottom="true" />

<RelativeLayout
android:id="@+id/rll_options"
android:layout_width="match_parent"
android:layout_height="48dp"
android:paddingTop="4dip">
android:paddingTop="4dip"
android:layout_above="@+id/ijkLib__relativeLayout"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">

<ImageView
android:id="@+id/mediacontroller_play_pause"
Expand All @@ -29,7 +33,8 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/rll_options">
android:layout_alignParentBottom="true"
android:id="@+id/ijkLib__relativeLayout">

<TextView
android:id="@+id/mediacontroller_time_current"
Expand Down
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
# ijkplayer
基于bilibili开源播放器编译好的so包项目,可直接通过lib的方式进行引用。

优化了下control的实现方式,从dialog替换成view的显示隐藏.

## Usage
Add this line to your `build.gradle` file under your module directory.

```
compile 'com.github.leifzhang:IjkLib:0.1.0'
compile 'com.github.leifzhang:IjkLib:0.1.3'
```
# How to use
# 简介
更新了一下ijk的版本号以及升级了一下so包.

正常情况下可以考虑参考以下代码,可以简单的过滤项目的so包.

```
defaultConfig {
ndk {
abiFilters 'armeabi', ' 'x86'
}
}
```

升级了ijkplayer的so包以及java代码,同时更好的对lib代码迁移,方便直接关联项目的方式引入。
同时感谢bilibili大神们开源。
Loading

0 comments on commit 12b2a93

Please sign in to comment.