diff --git a/README-ZH.md b/README-ZH.md index 4763862e1..46abc022e 100644 --- a/README-ZH.md +++ b/README-ZH.md @@ -2,7 +2,7 @@ --

- +

@@ -28,7 +28,7 @@ ## 效果 -**[jiecaovideoplayer-5.5.4.apk](https://github.com/lipangit/JieCaoVideoPlayer/releases/download/v5.5.4/jiecaovideoplayer-5.5.4.apk)** +**[jiecaovideoplayer-5.6.apk](https://github.com/lipangit/JieCaoVideoPlayer/releases/download/v5.6/jiecaovideoplayer-5.6.apk)** ![Demo Screenshot][1] @@ -38,10 +38,10 @@ 1.添加类库 ```gradle -compile 'fm.jiecao:jiecaovideoplayer:5.5.4' +compile 'fm.jiecao:jiecaovideoplayer:5.6' ``` -[或直接下载jar包](https://github.com/lipangit/JieCaoVideoPlayer/releases/tag/v5.5.4) +[或直接下载jar包](https://github.com/lipangit/JieCaoVideoPlayer/releases/tag/v5.6) 2.添加布局 ```xml diff --git a/README.md b/README.md index a8c61da17..4732a5303 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ --

- +

@@ -30,7 +30,7 @@ I think the final solution for play video in android is android.media.MediaPlaye ## Effect -**[jiecaovideoplayer-5.5.4.apk](https://github.com/lipangit/JieCaoVideoPlayer/releases/download/v5.5.4/jiecaovideoplayer-5.5.4.apk)** +**[jiecaovideoplayer-5.6.apk](https://github.com/lipangit/JieCaoVideoPlayer/releases/download/v5.6/jiecaovideoplayer-5.6.apk)** ![Demo Screenshot][1] @@ -40,10 +40,10 @@ Even the custom UI, or has changed to the Library, is also the five steps to use 1.Import library ```gradle -compile 'fm.jiecao:jiecaovideoplayer:5.5.4' +compile 'fm.jiecao:jiecaovideoplayer:5.6' ``` -[Or download lib](https://github.com/lipangit/JieCaoVideoPlayer/releases/tag/v5.5.4) +[Or download lib](https://github.com/lipangit/JieCaoVideoPlayer/releases/tag/v5.6) 2.Add JCVideoPlayer in your layout ```xml diff --git a/app/build.gradle b/app/build.gradle index 25d5aceea..285736e89 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,14 +2,14 @@ apply plugin: 'com.android.application' android { compileSdkVersion 25 - buildToolsVersion '25.0.3' + buildToolsVersion '26.0.0' defaultConfig { applicationId "fm.jiecao.jiecaovideoplayer" minSdkVersion 16 targetSdkVersion 25 - versionCode 59 - versionName "5.5.4" + versionCode 60 + versionName "5.6" } buildTypes { release { diff --git a/app/src/main/java/fm/jiecao/jiecaovideoplayer/ApiActivity.java b/app/src/main/java/fm/jiecao/jiecaovideoplayer/ApiActivity.java index 4d98faeba..3f30ec6cb 100644 --- a/app/src/main/java/fm/jiecao/jiecaovideoplayer/ApiActivity.java +++ b/app/src/main/java/fm/jiecao/jiecaovideoplayer/ApiActivity.java @@ -70,7 +70,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { // cpAssertVideoToLocalPath(); // mJcVideoPlayerStandard.setUp(Environment.getExternalStorageDirectory().getAbsolutePath() + "/DCIM/Camera/local_video.mp4" // , JCVideoPlayerStandard.SCREEN_LAYOUT_NORMAL, "嫂子不信"); - /** Play video in assert **/ + /** Play video in assert, but not work now **/ // mJcVideoPlayerStandard.setUp("file:///android_asset/local_video.mp4" // , JCVideoPlayerStandard.SCREEN_LAYOUT_NORMAL, "嫂子不信"); diff --git a/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardAutoCompleteAfterFullscreen.java b/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardAutoCompleteAfterFullscreen.java index 561ff88f8..ea76495e3 100644 --- a/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardAutoCompleteAfterFullscreen.java +++ b/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardAutoCompleteAfterFullscreen.java @@ -21,7 +21,7 @@ public JCVideoPlayerStandardAutoCompleteAfterFullscreen(Context context, Attribu @Override public void onAutoCompletion() { if (currentScreen == SCREEN_WINDOW_FULLSCREEN) { - setUiWitStateAndScreen(CURRENT_STATE_AUTO_COMPLETE); + onStateAutoComplete(); } else { super.onAutoCompletion(); } diff --git a/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardFresco.java b/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardFresco.java index 5873b3d7b..f4a567fb0 100755 --- a/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardFresco.java +++ b/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardFresco.java @@ -22,9 +22,11 @@ import java.util.Timer; import java.util.TimerTask; +import fm.jiecao.jcvideoplayer_lib.JCUserAction; import fm.jiecao.jcvideoplayer_lib.JCUserActionStandard; import fm.jiecao.jcvideoplayer_lib.JCUtils; import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer; +import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard; import fm.jiecao.jiecaovideoplayer.R; //import com.facebook.drawee.view.SimpleDraweeView; @@ -34,18 +36,8 @@ * Created by Nathen * On 2016/05/01 22:59 */ -public class JCVideoPlayerStandardFresco extends JCVideoPlayer { - - public ImageView backButton; - public ProgressBar bottomProgressBar, loadingProgressBar; - public TextView titleTextView; +public class JCVideoPlayerStandardFresco extends JCVideoPlayerStandard { // public SimpleDraweeView thumbImageView; - public ImageView tinyBackImageView; - - protected static Timer DISSMISS_CONTROL_VIEW_TIMER; - protected DismissControlViewTimerTask mDismissControlViewTimerTask; - - protected static JCUserActionStandard JC_USER_EVENT_STANDARD; public JCVideoPlayerStandardFresco(Context context) { super(context); @@ -96,541 +88,5 @@ public int getLayoutId() { return R.layout.layout_standard_fresco; } - @Override - public void setUiWitStateAndScreen(int state) { - super.setUiWitStateAndScreen(state); - switch (currentState) { - case CURRENT_STATE_NORMAL: - changeUiToNormal(); - break; - case CURRENT_STATE_PREPARING: - changeUiToPreparingShow(); - startDismissControlViewTimer(); - break; - case CURRENT_STATE_PLAYING: - changeUiToPlayingShow(); - startDismissControlViewTimer(); - break; - case CURRENT_STATE_PAUSE: - changeUiToPauseShow(); - cancelDismissControlViewTimer(); - break; - case CURRENT_STATE_ERROR: - changeUiToError(); - break; - case CURRENT_STATE_AUTO_COMPLETE: - changeUiToCompleteShow(); - cancelDismissControlViewTimer(); - bottomProgressBar.setProgress(100); - break; - case CURRENT_STATE_PLAYING_BUFFERING_START: - changeUiToPlayingBufferingShow(); - break; - } - } - - @Override - public boolean onTouch(View v, MotionEvent event) { - int id = v.getId(); - if (id == R.id.surface_container) { - switch (event.getAction()) { - case MotionEvent.ACTION_DOWN: - break; - case MotionEvent.ACTION_MOVE: - break; - case MotionEvent.ACTION_UP: - startDismissControlViewTimer(); - if (mChangePosition) { - int duration = getDuration(); - int progress = mSeekTimePosition * 100 / (duration == 0 ? 1 : duration); - bottomProgressBar.setProgress(progress); - } - if (!mChangePosition && !mChangeVolume) { - onClickUiToggle(); - } - break; - } - } else if (id == R.id.bottom_seek_progress) { - switch (event.getAction()) { - case MotionEvent.ACTION_DOWN: - cancelDismissControlViewTimer(); - break; - case MotionEvent.ACTION_UP: - startDismissControlViewTimer(); - break; - } - } - return super.onTouch(v, event); - } - - @Override - public void onClick(View v) { - super.onClick(v); - int i = v.getId(); - if (i == R.id.thumb) { - if (TextUtils.isEmpty(url)) { - Toast.makeText(getContext(), getResources().getString(R.string.no_url), Toast.LENGTH_SHORT).show(); - return; - } - if (currentState == CURRENT_STATE_NORMAL) { - if (!url.startsWith("file") && !JCUtils.isWifiConnected(getContext()) && !WIFI_TIP_DIALOG_SHOWED) { - showWifiDialog(); - return; - } - startPlayLogic(); - } else if (currentState == CURRENT_STATE_AUTO_COMPLETE) { - onClickUiToggle(); - } - } else if (i == R.id.surface_container) { - if (JC_USER_EVENT_STANDARD != null && isCurrentJcvd()) { -// if (mIfCurrentIsFullscreen) { -// JC_USER_EVENT_STANDARD.onClickBlankFullscreen(url, objects); -// } else { -// JC_USER_EVENT_STANDARD.onClickBlank(url, objects); -// } - } - startDismissControlViewTimer(); - } else if (i == R.id.back) { - backPress(); - } else if (i == R.id.back_tiny) { - backPress(); - } - } - - @Override - public void showWifiDialog() { - super.showWifiDialog(); - AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); - builder.setMessage(getResources().getString(R.string.tips_not_wifi)); - builder.setPositiveButton(getResources().getString(R.string.tips_not_wifi_confirm), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - startPlayLogic(); - WIFI_TIP_DIALOG_SHOWED = true; - } - }); - builder.setNegativeButton(getResources().getString(R.string.tips_not_wifi_cancel), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - } - }); - builder.create().show(); - } - - @Override - public void onStartTrackingTouch(SeekBar seekBar) { - super.onStartTrackingTouch(seekBar); - cancelDismissControlViewTimer(); - } - - @Override - public void onStopTrackingTouch(SeekBar seekBar) { - super.onStopTrackingTouch(seekBar); - startDismissControlViewTimer(); - } - - private void startPlayLogic() { - onEvent(JCUserActionStandard.ON_CLICK_START_THUMB); - prepareMediaPlayer(); - startDismissControlViewTimer(); - } - - private void onClickUiToggle() { - if (currentState == CURRENT_STATE_PREPARING) { - if (bottomContainer.getVisibility() == View.VISIBLE) { - changeUiToPreparingClear(); - } else { - changeUiToPreparingShow(); - } - } else if (currentState == CURRENT_STATE_PLAYING) { - if (bottomContainer.getVisibility() == View.VISIBLE) { - changeUiToPlayingClear(); - } else { - changeUiToPlayingShow(); - } - } else if (currentState == CURRENT_STATE_PAUSE) { - if (bottomContainer.getVisibility() == View.VISIBLE) { - changeUiToPauseClear(); - } else { - changeUiToPauseShow(); - } - } else if (currentState == CURRENT_STATE_AUTO_COMPLETE) { - if (bottomContainer.getVisibility() == View.VISIBLE) { - changeUiToCompleteClear(); - } else { - changeUiToCompleteShow(); - } - } else if (currentState == CURRENT_STATE_PLAYING_BUFFERING_START) { - if (bottomContainer.getVisibility() == View.VISIBLE) { - changeUiToPlayingBufferingClear(); - } else { - changeUiToPlayingBufferingShow(); - } - } - } - -// @Override -// public void setProgressAndTime(int progress, int secProgress, int currentTime, int totalTime) { -// super.setProgressAndTime(progress, secProgress, currentTime, totalTime); -// if (progress != 0) bottomProgressBar.setProgress(progress); -// if (secProgress != 0) bottomProgressBar.setSecondaryProgress(secProgress); -// } - - @Override - public void resetProgressAndTime() { - super.resetProgressAndTime(); - bottomProgressBar.setProgress(0); - bottomProgressBar.setSecondaryProgress(0); - } - - //Unified management Ui - public void changeUiToNormal() { - switch (currentScreen) { - case SCREEN_LAYOUT_LIST: - setAllControlsVisible(View.VISIBLE, View.INVISIBLE, View.VISIBLE, - View.INVISIBLE, View.VISIBLE, View.VISIBLE, View.INVISIBLE); - updateStartImage(); - break; - case SCREEN_WINDOW_FULLSCREEN: - setAllControlsVisible(View.VISIBLE, View.INVISIBLE, View.VISIBLE, - View.INVISIBLE, View.VISIBLE, View.VISIBLE, View.INVISIBLE); - updateStartImage(); - break; - case SCREEN_WINDOW_TINY: - break; - } - } - - public void changeUiToPreparingShow() { - switch (currentScreen) { - case SCREEN_LAYOUT_LIST: - setAllControlsVisible(View.VISIBLE, View.VISIBLE, View.INVISIBLE, - View.VISIBLE, View.INVISIBLE, View.VISIBLE, View.INVISIBLE); - break; - case SCREEN_WINDOW_FULLSCREEN: - setAllControlsVisible(View.VISIBLE, View.VISIBLE, View.INVISIBLE, - View.VISIBLE, View.INVISIBLE, View.VISIBLE, View.INVISIBLE); - break; - case SCREEN_WINDOW_TINY: - break; - } - - } - - private void changeUiToPreparingClear() { - switch (currentScreen) { - case SCREEN_LAYOUT_LIST: - setAllControlsVisible(View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, - View.VISIBLE, View.INVISIBLE, View.VISIBLE, View.INVISIBLE); - break; - case SCREEN_WINDOW_FULLSCREEN: - setAllControlsVisible(View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, - View.VISIBLE, View.INVISIBLE, View.VISIBLE, View.INVISIBLE); - break; - case SCREEN_WINDOW_TINY: - break; - } - - } - - private void changeUiToPlayingShow() { - switch (currentScreen) { - case SCREEN_LAYOUT_LIST: - setAllControlsVisible(View.VISIBLE, View.VISIBLE, View.VISIBLE, - View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, View.INVISIBLE); - updateStartImage(); - break; - case SCREEN_WINDOW_FULLSCREEN: - setAllControlsVisible(View.VISIBLE, View.VISIBLE, View.VISIBLE, - View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, View.INVISIBLE); - updateStartImage(); - break; - case SCREEN_WINDOW_TINY: - break; - } - - } - - private void changeUiToPlayingClear() { - switch (currentScreen) { - case SCREEN_LAYOUT_LIST: - setAllControlsVisible(View.INVISIBLE, View.INVISIBLE, View.VISIBLE, - View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, View.INVISIBLE); - break; - case SCREEN_WINDOW_FULLSCREEN: - setAllControlsVisible(View.INVISIBLE, View.INVISIBLE, View.VISIBLE, - View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, View.INVISIBLE); - break; - case SCREEN_WINDOW_TINY: - break; - } - - } - - private void changeUiToPauseShow() { - switch (currentScreen) { - case SCREEN_LAYOUT_LIST: - setAllControlsVisible(View.VISIBLE, View.VISIBLE, View.VISIBLE, - View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, View.INVISIBLE); - updateStartImage(); - break; - case SCREEN_WINDOW_FULLSCREEN: - setAllControlsVisible(View.VISIBLE, View.VISIBLE, View.VISIBLE, - View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, View.INVISIBLE); - updateStartImage(); - break; - case SCREEN_WINDOW_TINY: - break; - } - - } - - private void changeUiToPauseClear() { - switch (currentScreen) { - case SCREEN_LAYOUT_LIST: - setAllControlsVisible(View.INVISIBLE, View.VISIBLE, View.INVISIBLE, - View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, View.INVISIBLE); - break; - case SCREEN_WINDOW_FULLSCREEN: - setAllControlsVisible(View.INVISIBLE, View.VISIBLE, View.INVISIBLE, - View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, View.INVISIBLE); - break; - case SCREEN_WINDOW_TINY: - break; - } - - } - - private void changeUiToPlayingBufferingShow() { - switch (currentScreen) { - case SCREEN_LAYOUT_LIST: - setAllControlsVisible(View.VISIBLE, View.VISIBLE, View.INVISIBLE, - View.VISIBLE, View.INVISIBLE, View.INVISIBLE, View.INVISIBLE); - break; - case SCREEN_WINDOW_FULLSCREEN: - setAllControlsVisible(View.VISIBLE, View.VISIBLE, View.INVISIBLE, - View.VISIBLE, View.INVISIBLE, View.INVISIBLE, View.INVISIBLE); - break; - case SCREEN_WINDOW_TINY: - break; - } - - } - - private void changeUiToPlayingBufferingClear() { - switch (currentScreen) { - case SCREEN_LAYOUT_LIST: - setAllControlsVisible(View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, - View.VISIBLE, View.INVISIBLE, View.INVISIBLE, View.VISIBLE); - updateStartImage(); - break; - case SCREEN_WINDOW_FULLSCREEN: - setAllControlsVisible(View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, - View.VISIBLE, View.INVISIBLE, View.INVISIBLE, View.VISIBLE); - updateStartImage(); - break; - case SCREEN_WINDOW_TINY: - break; - } - - } - - private void changeUiToCompleteShow() { - switch (currentScreen) { - case SCREEN_LAYOUT_LIST: - setAllControlsVisible(View.VISIBLE, View.VISIBLE, View.VISIBLE, - View.INVISIBLE, View.VISIBLE, View.INVISIBLE, View.INVISIBLE); - updateStartImage(); - break; - case SCREEN_WINDOW_FULLSCREEN: - setAllControlsVisible(View.VISIBLE, View.VISIBLE, View.VISIBLE, - View.INVISIBLE, View.VISIBLE, View.INVISIBLE, View.INVISIBLE); - updateStartImage(); - break; - case SCREEN_WINDOW_TINY: - break; - } - - } - - private void changeUiToCompleteClear() { - switch (currentScreen) { - case SCREEN_LAYOUT_LIST: - setAllControlsVisible(View.INVISIBLE, View.INVISIBLE, View.VISIBLE, - View.INVISIBLE, View.VISIBLE, View.INVISIBLE, View.VISIBLE); - updateStartImage(); - break; - case SCREEN_WINDOW_FULLSCREEN: - setAllControlsVisible(View.INVISIBLE, View.INVISIBLE, View.VISIBLE, - View.INVISIBLE, View.VISIBLE, View.INVISIBLE, View.VISIBLE); - updateStartImage(); - break; - case SCREEN_WINDOW_TINY: - break; - } - - } - - private void changeUiToError() { - switch (currentScreen) { - case SCREEN_LAYOUT_LIST: - setAllControlsVisible(View.INVISIBLE, View.INVISIBLE, View.VISIBLE, - View.INVISIBLE, View.INVISIBLE, View.VISIBLE, View.INVISIBLE); - updateStartImage(); - break; - case SCREEN_WINDOW_FULLSCREEN: - setAllControlsVisible(View.INVISIBLE, View.INVISIBLE, View.VISIBLE, - View.INVISIBLE, View.INVISIBLE, View.VISIBLE, View.INVISIBLE); - updateStartImage(); - break; - case SCREEN_WINDOW_TINY: - break; - } - - } - - private void setAllControlsVisible(int topCon, int bottomCon, int startBtn, int loadingPro, - int thumbImg, int coverImg, int bottomPro) { - topContainer.setVisibility(topCon); - bottomContainer.setVisibility(bottomCon); - startButton.setVisibility(startBtn); - loadingProgressBar.setVisibility(loadingPro); -// thumbImageView.setVisibility(thumbImg); - bottomProgressBar.setVisibility(bottomPro); - } - - private void updateStartImage() { - if (currentState == CURRENT_STATE_PLAYING) { - startButton.setImageResource(R.drawable.jc_click_pause_selector); - } else if (currentState == CURRENT_STATE_ERROR) { - startButton.setImageResource(R.drawable.jc_click_error_selector); - } else { - startButton.setImageResource(R.drawable.jc_click_play_selector); - } - } - - protected Dialog mProgressDialog; - protected ProgressBar mDialogProgressBar; - protected TextView mDialogSeekTime; - protected TextView mDialogTotalTime; - protected ImageView mDialogIcon; - - @Override - public void showProgressDialog(float deltaX, String seekTime, int seekTimePosition, String totalTime, int totalTimeDuration) { - super.showProgressDialog(deltaX, seekTime, seekTimePosition, totalTime, totalTimeDuration); - if (mProgressDialog == null) { - View localView = LayoutInflater.from(getContext()).inflate(R.layout.jc_dialog_progress, null); - mDialogProgressBar = ((ProgressBar) localView.findViewById(R.id.duration_progressbar)); - mDialogSeekTime = ((TextView) localView.findViewById(R.id.tv_current)); - mDialogTotalTime = ((TextView) localView.findViewById(R.id.tv_duration)); - mDialogIcon = ((ImageView) localView.findViewById(R.id.duration_image_tip)); - mProgressDialog = new Dialog(getContext(), R.style.jc_style_dialog_progress); - mProgressDialog.setContentView(localView); - mProgressDialog.getWindow().addFlags(Window.FEATURE_ACTION_BAR); - mProgressDialog.getWindow().addFlags(32); - mProgressDialog.getWindow().addFlags(16); - mProgressDialog.getWindow().setLayout(-2, -2); - WindowManager.LayoutParams localLayoutParams = mProgressDialog.getWindow().getAttributes(); - localLayoutParams.gravity = Gravity.CENTER; - mProgressDialog.getWindow().setAttributes(localLayoutParams); - } - if (!mProgressDialog.isShowing()) { - mProgressDialog.show(); - } - - mDialogSeekTime.setText(seekTime); - mDialogTotalTime.setText(" / " + totalTime); - mDialogProgressBar.setProgress(seekTimePosition * 100 / totalTimeDuration); - if (deltaX > 0) { - mDialogIcon.setBackgroundResource(R.drawable.jc_forward_icon); - } else { - mDialogIcon.setBackgroundResource(R.drawable.jc_backward_icon); - } - - } - - @Override - public void dismissProgressDialog() { - super.dismissProgressDialog(); - if (mProgressDialog != null) { - mProgressDialog.dismiss(); - } - } - - - protected Dialog mVolumeDialog; - protected ProgressBar mDialogVolumeProgressBar; - - @Override - public void showVolumeDialog(float deltaY, int volumePercent) { - super.showVolumeDialog(deltaY, volumePercent); - if (mVolumeDialog == null) { - View localView = LayoutInflater.from(getContext()).inflate(R.layout.jc_dialog_volume, null); - mDialogVolumeProgressBar = ((ProgressBar) localView.findViewById(R.id.volume_progressbar)); - mVolumeDialog = new Dialog(getContext(), R.style.jc_style_dialog_progress); - mVolumeDialog.setContentView(localView); - mVolumeDialog.getWindow().addFlags(8); - mVolumeDialog.getWindow().addFlags(32); - mVolumeDialog.getWindow().addFlags(16); - mVolumeDialog.getWindow().setLayout(-2, -2); - WindowManager.LayoutParams localLayoutParams = mVolumeDialog.getWindow().getAttributes(); - localLayoutParams.gravity = Gravity.CENTER; - mVolumeDialog.getWindow().setAttributes(localLayoutParams); - } - if (!mVolumeDialog.isShowing()) { - mVolumeDialog.show(); - } - - mDialogVolumeProgressBar.setProgress(volumePercent); - } - - @Override - public void dismissVolumeDialog() { - super.dismissVolumeDialog(); - if (mVolumeDialog != null) { - mVolumeDialog.dismiss(); - } - } - - private void startDismissControlViewTimer() { - cancelDismissControlViewTimer(); - DISSMISS_CONTROL_VIEW_TIMER = new Timer(); - mDismissControlViewTimerTask = new DismissControlViewTimerTask(); - DISSMISS_CONTROL_VIEW_TIMER.schedule(mDismissControlViewTimerTask, 2500); - } - - private void cancelDismissControlViewTimer() { - if (DISSMISS_CONTROL_VIEW_TIMER != null) { - DISSMISS_CONTROL_VIEW_TIMER.cancel(); - } - if (mDismissControlViewTimerTask != null) { - mDismissControlViewTimerTask.cancel(); - } - - } - - protected class DismissControlViewTimerTask extends TimerTask { - - @Override - public void run() { - if (currentState != CURRENT_STATE_NORMAL - && currentState != CURRENT_STATE_ERROR - && currentState != CURRENT_STATE_AUTO_COMPLETE) { - if (getContext() != null && getContext() instanceof Activity) { - ((Activity) getContext()).runOnUiThread(new Runnable() { - @Override - public void run() { - bottomContainer.setVisibility(View.INVISIBLE); - topContainer.setVisibility(View.INVISIBLE); - bottomProgressBar.setVisibility(View.VISIBLE); - startButton.setVisibility(View.INVISIBLE); - } - }); - } - } - } - } } diff --git a/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardShowState.java b/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardShowState.java new file mode 100644 index 000000000..df20cd929 --- /dev/null +++ b/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardShowState.java @@ -0,0 +1,110 @@ +package fm.jiecao.jiecaovideoplayer.CustomView; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.MotionEvent; +import android.view.View; + +import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard; + +/** + * Created by Nathen on 2017/7/2. + */ +public class JCVideoPlayerStandardShowState extends JCVideoPlayerStandard { + public JCVideoPlayerStandardShowState(Context context) { + super(context); + } + + public JCVideoPlayerStandardShowState(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + public void init(Context context) { + super.init(context); + } + + @Override + public void onClick(View v) { + super.onClick(v); + int i = v.getId(); + if (i == fm.jiecao.jcvideoplayer_lib.R.id.fullscreen) { + if (currentScreen == SCREEN_WINDOW_FULLSCREEN) { + //click quit fullscreen + } else { + //click goto fullscreen + } + } + } + + @Override + public boolean onTouch(View v, MotionEvent event) { + return super.onTouch(v, event); + } + + @Override + public void startVideo() { + super.startVideo(); + } + + @Override + public void onPrepared() { + super.onPrepared(); + } + + @Override + public void onStateNormal() { + super.onStateNormal(); + } + + @Override + public void onStatePreparing() { + super.onStatePreparing(); + } + + @Override + public void onStatePlaying() { + super.onStatePlaying(); + } + + @Override + public void onStatePause() { + super.onStatePause(); + } + + @Override + public void onStatePlaybackBufferingStart() { + super.onStatePlaybackBufferingStart(); + } + + @Override + public void onStateError() { + super.onStateError(); + } + + @Override + public void onStateAutoComplete() { + super.onStateAutoComplete(); + } + + @Override + public void onInfo(int what, int extra) { + super.onInfo(what, extra); + } + + @Override + public void onError(int what, int extra) { + super.onError(what, extra); + } + + @Override + public void startWindowFullscreen() { + super.startWindowFullscreen(); + } + + @Override + public void startWindowTiny() { + super.startWindowTiny(); + } + +} diff --git a/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardShowTextureViewAfterAutoComplete.java b/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardShowTextureViewAfterAutoComplete.java index 959dc348b..3deca692e 100644 --- a/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardShowTextureViewAfterAutoComplete.java +++ b/app/src/main/java/fm/jiecao/jiecaovideoplayer/CustomView/JCVideoPlayerStandardShowTextureViewAfterAutoComplete.java @@ -20,11 +20,9 @@ public JCVideoPlayerStandardShowTextureViewAfterAutoComplete(Context context, At } @Override - public void setUiWitStateAndScreen(int state) { - super.setUiWitStateAndScreen(state); - if (state == CURRENT_STATE_AUTO_COMPLETE) { - thumbImageView.setVisibility(View.GONE); - } + public void onAutoCompletion() { + super.onAutoCompletion(); + thumbImageView.setVisibility(View.GONE); } @Override diff --git a/app/src/main/java/fm/jiecao/jiecaovideoplayer/DemoFragment.java b/app/src/main/java/fm/jiecao/jiecaovideoplayer/DemoFragment.java new file mode 100644 index 000000000..852cb359d --- /dev/null +++ b/app/src/main/java/fm/jiecao/jiecaovideoplayer/DemoFragment.java @@ -0,0 +1,36 @@ +package fm.jiecao.jiecaovideoplayer; + + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ListView; + +/** + * Created by Nathen on 2017/6/9. + */ +public class DemoFragment extends Fragment { + + ListView listView; + int index; + + public DemoFragment setIndex(int index) { + this.index = index; + return this; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInastanceState) { + listView = (ListView) inflater.inflate(R.layout.layout_list, container, false); + listView.setAdapter(new VideoListAdapter(getActivity(), index)); + return listView; + } +} diff --git a/app/src/main/java/fm/jiecao/jiecaovideoplayer/ListViewViewpagerActivity.java b/app/src/main/java/fm/jiecao/jiecaovideoplayer/ListViewViewpagerActivity.java index ad8ab5735..c2d2da3b7 100755 --- a/app/src/main/java/fm/jiecao/jiecaovideoplayer/ListViewViewpagerActivity.java +++ b/app/src/main/java/fm/jiecao/jiecaovideoplayer/ListViewViewpagerActivity.java @@ -1,6 +1,9 @@ package fm.jiecao.jiecaovideoplayer; import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; @@ -18,6 +21,8 @@ * On 2016/02/07 01:01 */ public class ListViewViewpagerActivity extends AppCompatActivity implements ViewPager.OnPageChangeListener { + List fragmentList = new ArrayList<>(); + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -28,20 +33,11 @@ protected void onCreate(Bundle savedInstanceState) { getSupportActionBar().setDisplayUseLogoEnabled(false); getSupportActionBar().setTitle("ViewPagerAndListView"); - List listViews = new ArrayList<>(); - ListView listView1 = (ListView) getLayoutInflater().inflate(R.layout.layout_list, null); - ListView listView2 = (ListView) getLayoutInflater().inflate(R.layout.layout_list, null); - ListView listView3 = (ListView) getLayoutInflater().inflate(R.layout.layout_list, null); - - listView1.setAdapter(new VideoListAdapter(this, 0)); - listView2.setAdapter(new VideoListAdapter(this, 1)); - listView3.setAdapter(new VideoListAdapter(this, 2)); - - listViews.add(listView1); - listViews.add(listView2); - listViews.add(listView3); + fragmentList.add(new DemoFragment().setIndex(0)); + fragmentList.add(new DemoFragment().setIndex(1)); + fragmentList.add(new DemoFragment().setIndex(2)); - MyAdapter myAdapter = new MyAdapter(listViews); + MyAdapter myAdapter = new MyAdapter(getSupportFragmentManager()); ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager); viewPager.setAdapter(myAdapter); viewPager.setOnPageChangeListener(this); @@ -68,36 +64,22 @@ public void onPageScrollStateChanged(int state) { } - public class MyAdapter extends PagerAdapter { + public class MyAdapter extends FragmentPagerAdapter { - List viewLists; - - public MyAdapter(List lists) { - viewLists = lists; + public MyAdapter(FragmentManager fm) { + super(fm); } @Override - public int getCount() { - // TODO Auto-generated method stub - return viewLists.size(); + public Fragment getItem(int i) { + return fragmentList.get(i); } @Override - public boolean isViewFromObject(View arg0, Object arg1) { - // TODO Auto-generated method stub - return arg0 == arg1; - } - - @Override - public void destroyItem(View view, int position, Object object) { - ((ViewPager) view).removeView(viewLists.get(position)); + public int getCount() { + return fragmentList.size(); } - @Override - public Object instantiateItem(View view, int position) { - ((ViewPager) view).addView(viewLists.get(position), 0); - return viewLists.get(position); - } } @Override diff --git a/app/src/main/res/drawable/skin_seek_progress.xml b/app/src/main/res/drawable/skin_seek_progress.xml index ab9ba80e1..75d77cb71 100644 --- a/app/src/main/res/drawable/skin_seek_progress.xml +++ b/app/src/main/res/drawable/skin_seek_progress.xml @@ -3,7 +3,7 @@ - + @@ -11,7 +11,7 @@ - + @@ -20,7 +20,7 @@ - + diff --git a/app/src/main/res/layout/activity_api.xml b/app/src/main/res/layout/activity_api.xml index ffcc2c45e..c3a352285 100644 --- a/app/src/main/res/layout/activity_api.xml +++ b/app/src/main/res/layout/activity_api.xml @@ -29,7 +29,7 @@