diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index ab340b85..1d1e3740 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -6,6 +6,8 @@ about: Create a report to help us improve **什么jzvd版本 +**什么播放器内核 + **相关log是什么 **demo是否有这个问题 diff --git a/README.md b/README.md index d63d5da5..4a964dd2 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ --
@@ -23,7 +23,7 @@ ## 文档 -- [文档 - API](https://github.com/Jzvd/JiaoZiVideoPlayer/wiki/%E6%96%87%E6%A1%A3-%E2%80%94-API),下载安装demo[jiaozivideoplayer-7.2.4.apk](https://github.com/Jzvd/JiaoZiVideoPlayer/releases/download/v7.2.4/jiaozivideoplayer-7.2.4.apk),仔细过一遍demo +- [文档 - API](https://github.com/Jzvd/JiaoZiVideoPlayer/wiki/%E6%96%87%E6%A1%A3-%E2%80%94-API),下载安装demo[jiaozivideoplayer-7.3.0.apk](https://github.com/Jzvd/JiaoZiVideoPlayer/releases/download/v7.3.0/jiaozivideoplayer-7.3.0.apk),仔细过一遍demo - [文档 - 自定义Jzvd](https://github.com/Jzvd/JiaoZiVideoPlayer/wiki/%E6%96%87%E6%A1%A3-%E2%80%94-%E8%87%AA%E5%AE%9A%E4%B9%89Jzvd),继承JzvdStd实现自己的播放器 - [文档 - 自定义播放内核](https://github.com/Jzvd/JiaoZiVideoPlayer/wiki/%E6%96%87%E6%A1%A3-%E2%80%94-%E8%87%AA%E5%AE%9A%E4%B9%89%E6%92%AD%E6%94%BE%E5%86%85%E6%A0%B8),测试哪个播放内核适合自己的项目 @@ -37,7 +37,7 @@ 1.添加类库 ```gradle -implementation 'cn.jzvd:jiaozivideoplayer:7.2.4' +implementation 'cn.jzvd:jiaozivideoplayer:7.3.0' ``` 2.添加布局 diff --git a/demo/build.gradle b/demo/build.gradle index 42504bfc..2f228ed4 100755 --- a/demo/build.gradle +++ b/demo/build.gradle @@ -8,8 +8,8 @@ android { applicationId "cn.jzvd.demo" minSdkVersion 16 targetSdkVersion 29 - versionCode 99 - versionName "7.2.4" + versionCode 100 + versionName "7.3.0" ndk { // add support lib abiFilters 'armeabi-v7a' //, 'arm64-v8a'//, "mips" //,'armeabi''x86',, 'x86_64', diff --git a/demo/src/main/res/layout/activity_main.xml b/demo/src/main/res/layout/activity_main.xml index 977775b1..fc6b8f33 100644 --- a/demo/src/main/res/layout/activity_main.xml +++ b/demo/src/main/res/layout/activity_main.xml @@ -82,7 +82,7 @@ android:layout_marginTop="8dp" android:layout_marginBottom="8dp" android:onClick="clickCustomAgVideo" - android:text="Custom Ag Video !!" /> + android:text="## Custom Ag Video" /> diff --git a/gradle/build_upload.gradle b/gradle/build_upload.gradle index d92ba95b..9e3c8042 100644 --- a/gradle/build_upload.gradle +++ b/gradle/build_upload.gradle @@ -8,7 +8,7 @@ signing { group = "cn.jzvd" archivesBaseName = "jiaozivideoplayer" -version = "7.2.4" +version = "7.3.0" uploadArchives { repositories { diff --git a/library/build.gradle b/library/build.gradle index e3ac47d1..8f2841c2 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -7,8 +7,8 @@ android { defaultConfig { minSdkVersion 16 targetSdkVersion 29 - versionCode 99 - versionName "7.2.4" + versionCode 100 + versionName "7.3.0" } compileOptions { diff --git a/library/src/main/java/cn/jzvd/JZUtils.java b/library/src/main/java/cn/jzvd/JZUtils.java index d3feba7b..a14f2a8c 100755 --- a/library/src/main/java/cn/jzvd/JZUtils.java +++ b/library/src/main/java/cn/jzvd/JZUtils.java @@ -5,10 +5,13 @@ import android.content.Context; import android.content.ContextWrapper; import android.content.SharedPreferences; +import android.content.res.Resources; import android.net.ConnectivityManager; import android.net.NetworkInfo; +import android.util.DisplayMetrics; import android.util.Log; import android.view.View; +import android.view.ViewConfiguration; import android.view.Window; import android.view.WindowManager; @@ -166,4 +169,31 @@ public static void showSystemUI(Context context) { JZUtils.getWindow(context).getDecorView().setSystemUiVisibility(SYSTEM_UI); } + //获取状态栏的高度 + public static int getStatusBarHeight(Context context) { + Resources resources = context.getResources(); + int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android"); + int height = resources.getDimensionPixelSize(resourceId); + return height; + } + + //获取NavigationBar的高度 + public static int getNavigationBarHeight(Context context) { + boolean var1 = ViewConfiguration.get(context).hasPermanentMenuKey(); + int var2; + return (var2 = context.getResources().getIdentifier("navigation_bar_height", "dimen", "android")) > 0 && !var1 ? context.getResources().getDimensionPixelSize(var2) : 0; + } + + //获取屏幕的宽度 + public static int getScreenWidth(Context context) { + DisplayMetrics dm = context.getResources().getDisplayMetrics(); + return dm.widthPixels; + } + + //获取屏幕的高度 + public static int getScreenHeight(Context context) { + DisplayMetrics dm = context.getResources().getDisplayMetrics(); + return dm.heightPixels; + } + } diff --git a/library/src/main/java/cn/jzvd/Jzvd.java b/library/src/main/java/cn/jzvd/Jzvd.java index b36d439d..a0822f41 100644 --- a/library/src/main/java/cn/jzvd/Jzvd.java +++ b/library/src/main/java/cn/jzvd/Jzvd.java @@ -304,39 +304,47 @@ public void setMediaInterface(Class mediaInterfaceClass) { public void onClick(View v) { int i = v.getId(); if (i == R.id.start) { - Log.i(TAG, "onClick start [" + this.hashCode() + "] "); - if (jzDataSource == null || jzDataSource.urlsMap.isEmpty() || jzDataSource.getCurrentUrl() == null) { - Toast.makeText(getContext(), getResources().getString(R.string.no_url), Toast.LENGTH_SHORT).show(); - return; - } - if (state == STATE_NORMAL) { - if (!jzDataSource.getCurrentUrl().toString().startsWith("file") && ! - jzDataSource.getCurrentUrl().toString().startsWith("/") && - !JZUtils.isWifiConnected(getContext()) && !WIFI_TIP_DIALOG_SHOWED) {//这个可以放到std中 - showWifiDialog(); - return; - } - startVideo(); - } else if (state == STATE_PLAYING) { - Log.d(TAG, "pauseVideo [" + this.hashCode() + "] "); - mediaInterface.pause(); - onStatePause(); - } else if (state == STATE_PAUSE) { - mediaInterface.start(); - onStatePlaying(); - } else if (state == STATE_AUTO_COMPLETE) { - startVideo(); - } + clickStart(); } else if (i == R.id.fullscreen) { - Log.i(TAG, "onClick fullscreen [" + this.hashCode() + "] "); - if (state == STATE_AUTO_COMPLETE) return; - if (screen == SCREEN_FULLSCREEN) { - //quit fullscreen - backPress(); - } else { - Log.d(TAG, "toFullscreenActivity [" + this.hashCode() + "] "); - gotoScreenFullscreen(); + clickFullscreen(); + } + } + + private void clickFullscreen() { + Log.i(TAG, "onClick fullscreen [" + this.hashCode() + "] "); + if (state == STATE_AUTO_COMPLETE) return; + if (screen == SCREEN_FULLSCREEN) { + //quit fullscreen + backPress(); + } else { + Log.d(TAG, "toFullscreenActivity [" + this.hashCode() + "] "); + gotoScreenFullscreen(); + } + } + + private void clickStart() { + Log.i(TAG, "onClick start [" + this.hashCode() + "] "); + if (jzDataSource == null || jzDataSource.urlsMap.isEmpty() || jzDataSource.getCurrentUrl() == null) { + Toast.makeText(getContext(), getResources().getString(R.string.no_url), Toast.LENGTH_SHORT).show(); + return; + } + if (state == STATE_NORMAL) { + if (!jzDataSource.getCurrentUrl().toString().startsWith("file") && ! + jzDataSource.getCurrentUrl().toString().startsWith("/") && + !JZUtils.isWifiConnected(getContext()) && !WIFI_TIP_DIALOG_SHOWED) {//这个可以放到std中 + showWifiDialog(); + return; } + startVideo(); + } else if (state == STATE_PLAYING) { + Log.d(TAG, "pauseVideo [" + this.hashCode() + "] "); + mediaInterface.pause(); + onStatePause(); + } else if (state == STATE_PAUSE) { + mediaInterface.start(); + onStatePlaying(); + } else if (state == STATE_AUTO_COMPLETE) { + startVideo(); } } @@ -348,115 +356,130 @@ public boolean onTouch(View v, MotionEvent event) { if (id == R.id.surface_container) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: - Log.i(TAG, "onTouch surfaceContainer actionDown [" + this.hashCode() + "] "); - mTouchingProgressBar = true; - - mDownX = x; - mDownY = y; - mChangeVolume = false; - mChangePosition = false; - mChangeBrightness = false; - + touchActionDown(x,y); break; case MotionEvent.ACTION_MOVE: - Log.i(TAG, "onTouch surfaceContainer actionMove [" + this.hashCode() + "] "); - float deltaX = x - mDownX; - float deltaY = y - mDownY; - float absDeltaX = Math.abs(deltaX); - float absDeltaY = Math.abs(deltaY); - if (screen == SCREEN_FULLSCREEN) { - if (!mChangePosition && !mChangeVolume && !mChangeBrightness) { - if (absDeltaX > THRESHOLD || absDeltaY > THRESHOLD) { - cancelProgressTimer(); - if (absDeltaX >= THRESHOLD) { - // 全屏模式下的CURRENT_STATE_ERROR状态下,不响应进度拖动事件. - // 否则会因为mediaplayer的状态非法导致App Crash - if (state != STATE_ERROR) { - mChangePosition = true; - mGestureDownPosition = getCurrentPositionWhenPlaying(); - } - } else { - //如果y轴滑动距离超过设置的处理范围,那么进行滑动事件处理 - if (mDownX < mScreenWidth * 0.5f) {//左侧改变亮度 - mChangeBrightness = true; - WindowManager.LayoutParams lp = JZUtils.getWindow(getContext()).getAttributes(); - if (lp.screenBrightness < 0) { - try { - mGestureDownBrightness = Settings.System.getInt(getContext().getContentResolver(), Settings.System.SCREEN_BRIGHTNESS); - Log.i(TAG, "current system brightness: " + mGestureDownBrightness); - } catch (Settings.SettingNotFoundException e) { - e.printStackTrace(); - } - } else { - mGestureDownBrightness = lp.screenBrightness * 255; - Log.i(TAG, "current activity brightness: " + mGestureDownBrightness); - } - } else {//右侧改变声音 - mChangeVolume = true; - mGestureDownVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC); - } + touchActionMove(x,y); + break; + case MotionEvent.ACTION_UP: + touchActionUp(); + break; + } + } + return false; + } + + private void touchActionUp() { + Log.i(TAG, "onTouch surfaceContainer actionUp [" + this.hashCode() + "] "); + mTouchingProgressBar = false; + dismissProgressDialog(); + dismissVolumeDialog(); + dismissBrightnessDialog(); + if (mChangePosition) { + mediaInterface.seekTo(mSeekTimePosition); + long duration = getDuration(); + int progress = (int) (mSeekTimePosition * 100 / (duration == 0 ? 1 : duration)); + progressBar.setProgress(progress); + } + if (mChangeVolume) { + //change volume event + } + startProgressTimer(); + } + + private void touchActionMove(float x,float y) { + Log.i(TAG, "onTouch surfaceContainer actionMove [" + this.hashCode() + "] "); + float deltaX = x - mDownX; + float deltaY = y - mDownY; + float absDeltaX = Math.abs(deltaX); + float absDeltaY = Math.abs(deltaY); + if (screen == SCREEN_FULLSCREEN) { + //拖动的是NavigationBar和状态栏 + if (mDownX > JZUtils.getScreenWidth(getContext()) || mDownY < JZUtils.getStatusBarHeight(getContext())) { + return; + } + if (!mChangePosition && !mChangeVolume && !mChangeBrightness) { + if (absDeltaX > THRESHOLD || absDeltaY > THRESHOLD) { + cancelProgressTimer(); + if (absDeltaX >= THRESHOLD) { + // 全屏模式下的CURRENT_STATE_ERROR状态下,不响应进度拖动事件. + // 否则会因为mediaplayer的状态非法导致App Crash + if (state != STATE_ERROR) { + mChangePosition = true; + mGestureDownPosition = getCurrentPositionWhenPlaying(); + } + } else { + //如果y轴滑动距离超过设置的处理范围,那么进行滑动事件处理 + if (mDownX < mScreenWidth * 0.5f) {//左侧改变亮度 + mChangeBrightness = true; + WindowManager.LayoutParams lp = JZUtils.getWindow(getContext()).getAttributes(); + if (lp.screenBrightness < 0) { + try { + mGestureDownBrightness = Settings.System.getInt(getContext().getContentResolver(), Settings.System.SCREEN_BRIGHTNESS); + Log.i(TAG, "current system brightness: " + mGestureDownBrightness); + } catch (Settings.SettingNotFoundException e) { + e.printStackTrace(); } + } else { + mGestureDownBrightness = lp.screenBrightness * 255; + Log.i(TAG, "current activity brightness: " + mGestureDownBrightness); } + } else {//右侧改变声音 + mChangeVolume = true; + mGestureDownVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC); } } - if (mChangePosition) { - long totalTimeDuration = getDuration(); - mSeekTimePosition = (int) (mGestureDownPosition + deltaX * totalTimeDuration / mScreenWidth); - if (mSeekTimePosition > totalTimeDuration) - mSeekTimePosition = totalTimeDuration; - String seekTime = JZUtils.stringForTime(mSeekTimePosition); - String totalTime = JZUtils.stringForTime(totalTimeDuration); - - showProgressDialog(deltaX, seekTime, mSeekTimePosition, totalTime, totalTimeDuration); - } - if (mChangeVolume) { - deltaY = -deltaY; - int max = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); - int deltaV = (int) (max * deltaY * 3 / mScreenHeight); - mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, mGestureDownVolume + deltaV, 0); - //dialog中显示百分比 - int volumePercent = (int) (mGestureDownVolume * 100 / max + deltaY * 3 * 100 / mScreenHeight); - showVolumeDialog(-deltaY, volumePercent); - } + } + } + } + if (mChangePosition) { + long totalTimeDuration = getDuration(); + mSeekTimePosition = (int) (mGestureDownPosition + deltaX * totalTimeDuration / mScreenWidth); + if (mSeekTimePosition > totalTimeDuration) + mSeekTimePosition = totalTimeDuration; + String seekTime = JZUtils.stringForTime(mSeekTimePosition); + String totalTime = JZUtils.stringForTime(totalTimeDuration); + + showProgressDialog(deltaX, seekTime, mSeekTimePosition, totalTime, totalTimeDuration); + } + if (mChangeVolume) { + deltaY = -deltaY; + int max = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); + int deltaV = (int) (max * deltaY * 3 / mScreenHeight); + mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, mGestureDownVolume + deltaV, 0); + //dialog中显示百分比 + int volumePercent = (int) (mGestureDownVolume * 100 / max + deltaY * 3 * 100 / mScreenHeight); + showVolumeDialog(-deltaY, volumePercent); + } - if (mChangeBrightness) { - deltaY = -deltaY; - int deltaV = (int) (255 * deltaY * 3 / mScreenHeight); - WindowManager.LayoutParams params = JZUtils.getWindow(getContext()).getAttributes(); - if (((mGestureDownBrightness + deltaV) / 255) >= 1) {//这和声音有区别,必须自己过滤一下负值 - params.screenBrightness = 1; - } else if (((mGestureDownBrightness + deltaV) / 255) <= 0) { - params.screenBrightness = 0.01f; - } else { - params.screenBrightness = (mGestureDownBrightness + deltaV) / 255; - } - JZUtils.getWindow(getContext()).setAttributes(params); - //dialog中显示百分比 - int brightnessPercent = (int) (mGestureDownBrightness * 100 / 255 + deltaY * 3 * 100 / mScreenHeight); - showBrightnessDialog(brightnessPercent); -// mDownY = y; - } - break; - case MotionEvent.ACTION_UP: - Log.i(TAG, "onTouch surfaceContainer actionUp [" + this.hashCode() + "] "); - mTouchingProgressBar = false; - dismissProgressDialog(); - dismissVolumeDialog(); - dismissBrightnessDialog(); - if (mChangePosition) { - mediaInterface.seekTo(mSeekTimePosition); - long duration = getDuration(); - int progress = (int) (mSeekTimePosition * 100 / (duration == 0 ? 1 : duration)); - progressBar.setProgress(progress); - } - if (mChangeVolume) { - //change volume event - } - startProgressTimer(); - break; + if (mChangeBrightness) { + deltaY = -deltaY; + int deltaV = (int) (255 * deltaY * 3 / mScreenHeight); + WindowManager.LayoutParams params = JZUtils.getWindow(getContext()).getAttributes(); + if (((mGestureDownBrightness + deltaV) / 255) >= 1) {//这和声音有区别,必须自己过滤一下负值 + params.screenBrightness = 1; + } else if (((mGestureDownBrightness + deltaV) / 255) <= 0) { + params.screenBrightness = 0.01f; + } else { + params.screenBrightness = (mGestureDownBrightness + deltaV) / 255; } + JZUtils.getWindow(getContext()).setAttributes(params); + //dialog中显示百分比 + int brightnessPercent = (int) (mGestureDownBrightness * 100 / 255 + deltaY * 3 * 100 / mScreenHeight); + showBrightnessDialog(brightnessPercent); +// mDownY = y; } - return false; + } + + private void touchActionDown(float x,float y) { + Log.i(TAG, "onTouch surfaceContainer actionDown [" + this.hashCode() + "] "); + mTouchingProgressBar = true; + + mDownX = x; + mDownY = y; + mChangeVolume = false; + mChangePosition = false; + mChangeBrightness = false; } public void onStateNormal() { diff --git a/library/src/main/java/cn/jzvd/JzvdStd.java b/library/src/main/java/cn/jzvd/JzvdStd.java index fcdb63f9..19f3be85 100644 --- a/library/src/main/java/cn/jzvd/JzvdStd.java +++ b/library/src/main/java/cn/jzvd/JzvdStd.java @@ -233,7 +233,6 @@ public boolean onTouch(View v, MotionEvent event) { if (id == R.id.surface_container) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: - break; case MotionEvent.ACTION_MOVE: break; case MotionEvent.ACTION_UP: @@ -287,86 +286,114 @@ public void onClick(View v) { super.onClick(v); int i = v.getId(); if (i == R.id.poster) { - if (jzDataSource == null || jzDataSource.urlsMap.isEmpty() || jzDataSource.getCurrentUrl() == null) { - Toast.makeText(getContext(), getResources().getString(R.string.no_url), Toast.LENGTH_SHORT).show(); - return; - } - if (state == STATE_NORMAL) { - if (!jzDataSource.getCurrentUrl().toString().startsWith("file") && - !jzDataSource.getCurrentUrl().toString().startsWith("/") && - !JZUtils.isWifiConnected(getContext()) && !WIFI_TIP_DIALOG_SHOWED) { - showWifiDialog(); - return; - } - startVideo(); - } else if (state == STATE_AUTO_COMPLETE) { - onClickUiToggle(); - } + clickPoster(); } else if (i == R.id.surface_container) { - startDismissControlViewTimer(); + clickSurfaceContainer(); + if (clarityPopWindow != null) { + clarityPopWindow.dismiss(); + } } else if (i == R.id.back) { - backPress(); + clickBack(); } else if (i == R.id.back_tiny) { - clearFloatScreen(); + clickBackTiny(); } else if (i == R.id.clarity) { - LayoutInflater inflater = (LayoutInflater) getContext() - .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - final LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.jz_layout_clarity, null); + clickClarity(); + } else if (i == R.id.retry_btn) { + clickRetryBtn(); + } + } - OnClickListener mQualityListener = v1 -> { - int index = (int) v1.getTag(); + private void clickRetryBtn() { + if (jzDataSource.urlsMap.isEmpty() || jzDataSource.getCurrentUrl() == null) { + Toast.makeText(getContext(), getResources().getString(R.string.no_url), Toast.LENGTH_SHORT).show(); + return; + } + if (!jzDataSource.getCurrentUrl().toString().startsWith("file") && ! + jzDataSource.getCurrentUrl().toString().startsWith("/") && + !JZUtils.isWifiConnected(getContext()) && !WIFI_TIP_DIALOG_SHOWED) { + showWifiDialog(); + return; + } + startVideo(); + } + + private void clickClarity() { + onCLickUiToggleToClear(); + + LayoutInflater inflater = (LayoutInflater) getContext() + .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + final LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.jz_layout_clarity, null); + + OnClickListener mQualityListener = v1 -> { + int index = (int) v1.getTag(); // this.seekToInAdvance = getCurrentPositionWhenPlaying(); - jzDataSource.currentUrlIndex = index; + jzDataSource.currentUrlIndex = index; // onStatePreparingChangeUrl(); - changeUrl(jzDataSource, getCurrentPositionWhenPlaying()); + changeUrl(jzDataSource, getCurrentPositionWhenPlaying()); - clarity.setText(jzDataSource.getCurrentKey().toString()); - for (int j = 0; j < layout.getChildCount(); j++) {//设置点击之后的颜色 - if (j == jzDataSource.currentUrlIndex) { - ((TextView) layout.getChildAt(j)).setTextColor(Color.parseColor("#fff85959")); - } else { - ((TextView) layout.getChildAt(j)).setTextColor(Color.parseColor("#ffffff")); - } - } - if (clarityPopWindow != null) { - clarityPopWindow.dismiss(); - } - }; - - for (int j = 0; j < jzDataSource.urlsMap.size(); j++) { - String key = jzDataSource.getKeyFromDataSource(j); - TextView clarityItem = (TextView) View.inflate(getContext(), R.layout.jz_layout_clarity_item, null); - clarityItem.setText(key); - clarityItem.setTag(j); - layout.addView(clarityItem, j); - clarityItem.setOnClickListener(mQualityListener); + clarity.setText(jzDataSource.getCurrentKey().toString()); + for (int j = 0; j < layout.getChildCount(); j++) {//设置点击之后的颜色 if (j == jzDataSource.currentUrlIndex) { - clarityItem.setTextColor(Color.parseColor("#fff85959")); + ((TextView) layout.getChildAt(j)).setTextColor(Color.parseColor("#fff85959")); + } else { + ((TextView) layout.getChildAt(j)).setTextColor(Color.parseColor("#ffffff")); } } - - clarityPopWindow = new PopupWindow(layout, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, true); - clarityPopWindow.setContentView(layout); - clarityPopWindow.showAsDropDown(clarity); - layout.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); - int offsetX = clarity.getMeasuredWidth() / 3; - int offsetY = clarity.getMeasuredHeight() / 3; - clarityPopWindow.update(clarity, -offsetX, -offsetY, Math.round(layout.getMeasuredWidth() * 2), layout.getMeasuredHeight()); - } else if (i == R.id.retry_btn) { - if (jzDataSource.urlsMap.isEmpty() || jzDataSource.getCurrentUrl() == null) { - Toast.makeText(getContext(), getResources().getString(R.string.no_url), Toast.LENGTH_SHORT).show(); - return; + if (clarityPopWindow != null) { + clarityPopWindow.dismiss(); + } + }; + + for (int j = 0; j < jzDataSource.urlsMap.size(); j++) { + String key = jzDataSource.getKeyFromDataSource(j); + TextView clarityItem = (TextView) View.inflate(getContext(), R.layout.jz_layout_clarity_item, null); + clarityItem.setText(key); + clarityItem.setTag(j); + layout.addView(clarityItem, j); + clarityItem.setOnClickListener(mQualityListener); + if (j == jzDataSource.currentUrlIndex) { + clarityItem.setTextColor(Color.parseColor("#fff85959")); } - if (!jzDataSource.getCurrentUrl().toString().startsWith("file") && ! - jzDataSource.getCurrentUrl().toString().startsWith("/") && + } + + clarityPopWindow = new PopupWindow(layout, JZUtils.dip2px(getContext(), 240), LayoutParams.MATCH_PARENT, true); + clarityPopWindow.setContentView(layout); + clarityPopWindow.setAnimationStyle(R.style.pop_animation); + clarityPopWindow.showAtLocation(textureViewContainer, Gravity.END, 0, 0); +// int offsetX = clarity.getMeasuredWidth() / 3; +// int offsetY = clarity.getMeasuredHeight() / 3; +// clarityPopWindow.update(clarity, -offsetX, -offsetY, Math.round(layout.getMeasuredWidth() * 2), layout.getMeasuredHeight()); + } + + private void clickBackTiny() { + clearFloatScreen(); + } + + private void clickBack() { + backPress(); + } + + private void clickSurfaceContainer() { + startDismissControlViewTimer(); + } + + private void clickPoster() { + if (jzDataSource == null || jzDataSource.urlsMap.isEmpty() || jzDataSource.getCurrentUrl() == null) { + Toast.makeText(getContext(), getResources().getString(R.string.no_url), Toast.LENGTH_SHORT).show(); + return; + } + if (state == STATE_NORMAL) { + if (!jzDataSource.getCurrentUrl().toString().startsWith("file") && + !jzDataSource.getCurrentUrl().toString().startsWith("/") && !JZUtils.isWifiConnected(getContext()) && !WIFI_TIP_DIALOG_SHOWED) { showWifiDialog(); return; } - addTextureView(); - onStatePreparing(); + startVideo(); + } else if (state == STATE_AUTO_COMPLETE) { + onClickUiToggle(); } } @@ -511,6 +538,7 @@ public void setBatteryLevel() { } } + //** 和onClickUiToggle重复,要干掉 public void onCLickUiToggleToClear() { if (state == STATE_PREPARING) { if (bottomContainer.getVisibility() == View.VISIBLE) { @@ -861,9 +889,6 @@ public void onCompletion() { public void reset() { super.reset(); cancelDismissControlViewTimer(); - if (clarityPopWindow != null) { - clarityPopWindow.dismiss(); - } unregisterWifiListener(getApplicationContext()); } @@ -875,9 +900,7 @@ public void dissmissControlView() { bottomContainer.setVisibility(View.INVISIBLE); topContainer.setVisibility(View.INVISIBLE); startButton.setVisibility(View.INVISIBLE); - if (clarityPopWindow != null) { - clarityPopWindow.dismiss(); - } + if (screen != SCREEN_TINY) { bottomProgressBar.setVisibility(View.VISIBLE); } diff --git a/library/src/main/res/anim/pop_from_bottom_anim_in.xml b/library/src/main/res/anim/pop_from_bottom_anim_in.xml new file mode 100644 index 00000000..7536a523 --- /dev/null +++ b/library/src/main/res/anim/pop_from_bottom_anim_in.xml @@ -0,0 +1,6 @@ + + +