From 621d70e838aa1754ab23b646da7a63f1f057eb28 Mon Sep 17 00:00:00 2001 From: Leifzhang <454327998@qq.com> Date: Wed, 23 Nov 2016 15:03:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E5=8D=87=E7=BA=A7=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IjkLib/build.gradle | 2 +- IjkLib/src/main/AndroidManifest.xml | 2 +- .../media/services/MediaPlayerService.java | 1 + .../ijk/media/widget/media/IjkVideoView.java | 54 ++++++----- .../widget/media/PlayerMediaController.java | 12 +-- IjkLib/src/main/res/values/attrs.xml | 4 +- README.md | 2 +- build.gradle | 4 +- build/intermediates/dex-cache/cache.xml | 96 +------------------ gradle.properties | 19 ++-- gradle/wrapper/gradle-wrapper.properties | 4 +- .../zhangyang/ijktest/MainActivity.java | 5 +- 12 files changed, 55 insertions(+), 150 deletions(-) diff --git a/IjkLib/build.gradle b/IjkLib/build.gradle index dd7e71b..a7eaa2f 100644 --- a/IjkLib/build.gradle +++ b/IjkLib/build.gradle @@ -24,7 +24,7 @@ dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) 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' + provided 'com.android.support:appcompat-v7:23.2.1' compile 'com.android.support:preference-v7:23.2.1' } def siteUrl = 'https://github.com/Leifzhang/ijkplayer' // 项目的主页 diff --git a/IjkLib/src/main/AndroidManifest.xml b/IjkLib/src/main/AndroidManifest.xml index cc58024..f063ac2 100644 --- a/IjkLib/src/main/AndroidManifest.xml +++ b/IjkLib/src/main/AndroidManifest.xml @@ -4,7 +4,7 @@ - + diff --git a/IjkLib/src/main/java/tv/danmaku/ijk/media/services/MediaPlayerService.java b/IjkLib/src/main/java/tv/danmaku/ijk/media/services/MediaPlayerService.java index 8dad259..a1d0e67 100644 --- a/IjkLib/src/main/java/tv/danmaku/ijk/media/services/MediaPlayerService.java +++ b/IjkLib/src/main/java/tv/danmaku/ijk/media/services/MediaPlayerService.java @@ -59,4 +59,5 @@ public static void setMediaPlayer(IMediaPlayer mp) { public static IMediaPlayer getMediaPlayer() { return sMediaPlayer; } + } diff --git a/IjkLib/src/main/java/tv/danmaku/ijk/media/widget/media/IjkVideoView.java b/IjkLib/src/main/java/tv/danmaku/ijk/media/widget/media/IjkVideoView.java index 2ac1303..d6bf6c4 100644 --- a/IjkLib/src/main/java/tv/danmaku/ijk/media/widget/media/IjkVideoView.java +++ b/IjkLib/src/main/java/tv/danmaku/ijk/media/widget/media/IjkVideoView.java @@ -18,7 +18,9 @@ import android.annotation.TargetApi; import android.content.Context; +import android.content.DialogInterface; import android.content.res.Resources; +import android.content.res.TypedArray; import android.media.AudioManager; import android.media.MediaPlayer; import android.net.Uri; @@ -117,31 +119,32 @@ public class IjkVideoView extends FrameLayout implements MediaController.MediaPl public IjkVideoView(Context context) { super(context); - initVideoView(context); + initVideoView(context, null); } public IjkVideoView(Context context, AttributeSet attrs) { super(context, attrs); - initVideoView(context); + initVideoView(context, attrs); } public IjkVideoView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - initVideoView(context); + initVideoView(context, attrs); } @TargetApi(Build.VERSION_CODES.LOLLIPOP) public IjkVideoView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); - initVideoView(context); + initVideoView(context, attrs); } - // REMOVED: onMeasure - // REMOVED: onInitializeAccessibilityEvent - // REMOVED: onInitializeAccessibilityNodeInfo - // REMOVED: resolveAdjustedSize - - private void initVideoView(Context context) { + private void initVideoView(Context context, AttributeSet attrs) { + TypedArray arr = getContext().obtainStyledAttributes(attrs, + R.styleable.IjkVideoView, 0, 0); + if (arr != null) { + mEnableBackgroundPlay = arr.getBoolean(R.styleable.IjkVideoView_enableBackground, false); + arr.recycle(); + } mAppContext = context.getApplicationContext(); mSettings = new Settings(mAppContext); @@ -526,31 +529,35 @@ public boolean onError(IMediaPlayer mp, int framework_err, int impl_err) { } else { messageId = R.string.VideoView_error_text_unknown; } - - /* new AlertDialog.Builder(getContext()) + new AlertDialog.Builder(getContext()) .setMessage(messageId) .setPositiveButton(R.string.VideoView_error_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { - *//* If we get here, there is no onError listener, so - * at least inform them that the video is over. - *//* if (mOnCompletionListener != null) { mOnCompletionListener.onCompletion(mMediaPlayer); } } }) .setCancelable(false) - .show();*/ + .show(); } return true; } }; + private IMediaPlayer.OnBufferingUpdateListener bufferingUpdateListener; + + public void setBufferingUpdateListener(IMediaPlayer.OnBufferingUpdateListener bufferingUpdateListener) { + this.bufferingUpdateListener = bufferingUpdateListener; + } private IMediaPlayer.OnBufferingUpdateListener mBufferingUpdateListener = new IMediaPlayer.OnBufferingUpdateListener() { public void onBufferingUpdate(IMediaPlayer mp, int percent) { mCurrentBufferPercentage = percent; + if (bufferingUpdateListener != null) { + bufferingUpdateListener.onBufferingUpdate(mp, percent); + } } }; @@ -635,7 +642,6 @@ public void onSurfaceCreated(@NonNull IRenderView.ISurfaceHolder holder, int wid Log.e(TAG, "onSurfaceCreated: unmatched render callback\n"); return; } - mSurfaceHolder = holder; if (mMediaPlayer != null) bindSurfaceHolder(mMediaPlayer, holder); @@ -858,11 +864,11 @@ public int getAudioSessionId() { IRenderView.AR_ASPECT_FIT_PARENT, IRenderView.AR_ASPECT_FILL_PARENT, IRenderView.AR_ASPECT_WRAP_CONTENT, - // IRenderView.AR_MATCH_PARENT, + IRenderView.AR_MATCH_PARENT, IRenderView.AR_16_9_FIT_PARENT, IRenderView.AR_4_3_FIT_PARENT}; private int mCurrentAspectRatioIndex = 0; - private int mCurrentAspectRatio = s_allAspectRatio[1]; + private int mCurrentAspectRatio = s_allAspectRatio[0]; public int toggleAspectRatio() { mCurrentAspectRatioIndex++; @@ -875,7 +881,7 @@ public int toggleAspectRatio() { } public void changeAspectRaito() { - mRenderView.setAspectRatio(s_allAspectRatio[1]); + mRenderView.setAspectRatio(s_allAspectRatio[0]); } //------------------------- @@ -1037,15 +1043,19 @@ public IMediaPlayer createPlayer(int playerType) { private boolean mEnableBackgroundPlay = false; private void initBackground() { - mEnableBackgroundPlay = mSettings.getEnableBackgroundPlay(); if (mEnableBackgroundPlay) { MediaPlayerService.intentToStart(getContext()); mMediaPlayer = MediaPlayerService.getMediaPlayer(); - if (mHudViewHolder != null) + if (mHudViewHolder != null) { mHudViewHolder.setMediaPlayer(mMediaPlayer); + } } } + public void setEnableBackgroundPlay(boolean mEnableBackgroundPlay) { + this.mEnableBackgroundPlay = mEnableBackgroundPlay; + } + public boolean isBackgroundPlayEnabled() { return mEnableBackgroundPlay; } diff --git a/IjkLib/src/main/java/tv/danmaku/ijk/media/widget/media/PlayerMediaController.java b/IjkLib/src/main/java/tv/danmaku/ijk/media/widget/media/PlayerMediaController.java index 50677c3..464d297 100644 --- a/IjkLib/src/main/java/tv/danmaku/ijk/media/widget/media/PlayerMediaController.java +++ b/IjkLib/src/main/java/tv/danmaku/ijk/media/widget/media/PlayerMediaController.java @@ -110,17 +110,6 @@ public void onLayoutChange(View v, int left, int top, int right, } }; -/* private final OnTouchListener mTouchListener = new OnTouchListener() { - @Override - public boolean onTouch(View v, MotionEvent event) { - if (event.getAction() == MotionEvent.ACTION_DOWN) { - if (mShowing) { - hide(); - } - } - return false; - } - };*/ public void setMediaPlayer(MediaController.MediaPlayerControl player) { mPlayer = player; @@ -148,6 +137,7 @@ public void setAnchorView(ViewGroup view) { View v = makeControllerView(); addView(v, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); + mAnchor.removeView(this); mAnchor.addView(this, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); v.setVisibility(View.INVISIBLE); diff --git a/IjkLib/src/main/res/values/attrs.xml b/IjkLib/src/main/res/values/attrs.xml index dfd1e71..7172a76 100644 --- a/IjkLib/src/main/res/values/attrs.xml +++ b/IjkLib/src/main/res/values/attrs.xml @@ -1,7 +1,9 @@ - + + + diff --git a/README.md b/README.md index b7b1397..636829a 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Add this line to your `build.gradle` file under your module directory. ``` - compile 'com.github.leifzhang:IjkLib:0.2.1' + compile 'com.github.leifzhang:IjkLib:0.2.4' ``` # 简介 更新了一下ijk的版本号以及升级了一下so包. diff --git a/build.gradle b/build.gradle index a2201a9..44d13bd 100755 --- a/build.gradle +++ b/build.gradle @@ -5,12 +5,12 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.1.2' + classpath 'com.android.tools.build:gradle:2.2.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1' - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' } } diff --git a/build/intermediates/dex-cache/cache.xml b/build/intermediates/dex-cache/cache.xml index e5a5674..fba8db8 100644 --- a/build/intermediates/dex-cache/cache.xml +++ b/build/intermediates/dex-cache/cache.xml @@ -1,96 +1,2 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/gradle.properties b/gradle.properties index 8d30682..c94973b 100755 --- a/gradle.properties +++ b/gradle.properties @@ -1,22 +1,17 @@ -# Project-wide Gradle settings. - -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. - +## Project-wide Gradle settings. +# # For more details on how to configure your build environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html - +# # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -# Default value: -Xmx10248m -XX:MaxPermSize=256m +# Default value: -Xmx1024m -XX:MaxPermSize=256m # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 - +# # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true - -# 包信息 +#Wed Nov 23 14:04:37 CST 2016 PROJ_GROUP=com.github.leifzhang -PROJ_VERSION=0.2.1 \ No newline at end of file +PROJ_VERSION=0.2.4 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b792ac9..1c2b22b 100755 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Jun 07 18:06:37 CST 2016 +#Wed Nov 23 14:04:54 CST 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip diff --git a/sample/src/main/java/com/example/zhangyang/ijktest/MainActivity.java b/sample/src/main/java/com/example/zhangyang/ijktest/MainActivity.java index 6b9a865..75228c1 100644 --- a/sample/src/main/java/com/example/zhangyang/ijktest/MainActivity.java +++ b/sample/src/main/java/com/example/zhangyang/ijktest/MainActivity.java @@ -26,10 +26,11 @@ protected void onCreate(Bundle savedInstanceState) { // videoView.setOnErrorListener(new ErrorListener()); AndroidMediaController controller = new AndroidMediaController(this, false); videoView.setMediaController(controller); - //String url = "http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8"; - String url = "http://o6wf52jln.bkt.clouddn.com/演员.mp3"; + String url = "http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8"; + // String url = "http://o6wf52jln.bkt.clouddn.com/演员.mp3"; videoView.setVideoURI(Uri.parse(url)); videoView.start(); + videoView.setVideoURI(Uri.parse(url)); } @Override