diff --git a/demo/src/androidTest/java/com/jarvanmo/demo/ExampleInstrumentedTest.java b/demo/src/androidTest/java/com/jarvanmo/demo/ExampleInstrumentedTest.java index 1999b5e..073d9c1 100644 --- a/demo/src/androidTest/java/com/jarvanmo/demo/ExampleInstrumentedTest.java +++ b/demo/src/androidTest/java/com/jarvanmo/demo/ExampleInstrumentedTest.java @@ -7,7 +7,7 @@ import org.junit.Test; import org.junit.runner.RunWith; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; /** * Instrumentation test, which will execute on an Android device. diff --git a/demo/src/main/AndroidManifest.xml b/demo/src/main/AndroidManifest.xml index a9b76ef..04dd3e8 100644 --- a/demo/src/main/AndroidManifest.xml +++ b/demo/src/main/AndroidManifest.xml @@ -15,9 +15,9 @@ android:theme="@style/FullscreenTheme"> - + diff --git a/demo/src/main/java/com/jarvanmo/demo/MainActivity.java b/demo/src/main/java/com/jarvanmo/demo/MainActivity.java index a80afb4..b647474 100644 --- a/demo/src/main/java/com/jarvanmo/demo/MainActivity.java +++ b/demo/src/main/java/com/jarvanmo/demo/MainActivity.java @@ -87,23 +87,23 @@ protected void onCreate(Bundle savedInstanceState) { List qualities = new ArrayList<>(); ExoMediaSource.Quality quality; - for (int i = 0; i <6 ; i++) { - SpannableString spannableString = new SpannableString("Quality"+i); - if(i % 2 ==0){ + for (int i = 0; i < 6; i++) { + SpannableString spannableString = new SpannableString("Quality" + i); + if (i % 2 == 0) { ForegroundColorSpan colorSpan = new ForegroundColorSpan(Color.YELLOW); spannableString.setSpan(colorSpan, 0, spannableString.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); - }else { + } else { ForegroundColorSpan colorSpan = new ForegroundColorSpan(Color.RED); spannableString.setSpan(colorSpan, 0, spannableString.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); } - quality = new SimpleQuality(spannableString,mediaSource.url()); + quality = new SimpleQuality(spannableString, mediaSource.url()); qualities.add(quality); } mediaSource.setQualities(qualities); - videoView.play(mediaSource,false); + videoView.play(mediaSource, false); play.setOnClickListener(view -> { videoView.play(mediaSource); play.setVisibility(View.INVISIBLE); @@ -180,8 +180,8 @@ protected void onDestroy() { @Override public boolean onKeyDown(int keyCode, KeyEvent event) { - if(keyCode == KeyEvent.KEYCODE_BACK){ - return videoView.onKeyDown(keyCode,event); + if (keyCode == KeyEvent.KEYCODE_BACK) { + return videoView.onKeyDown(keyCode, event); } return super.onKeyDown(keyCode, event); } diff --git a/demo/src/main/res/drawable/ic_arrow_back_white_24dp.xml b/demo/src/main/res/drawable/ic_arrow_back_white_24dp.xml index 4449d3b..48250d1 100644 --- a/demo/src/main/res/drawable/ic_arrow_back_white_24dp.xml +++ b/demo/src/main/res/drawable/ic_arrow_back_white_24dp.xml @@ -1,4 +1,10 @@ - - + + diff --git a/demo/src/main/res/drawable/ic_error_white_24dp.xml b/demo/src/main/res/drawable/ic_error_white_24dp.xml index 9449aa3..94002bd 100644 --- a/demo/src/main/res/drawable/ic_error_white_24dp.xml +++ b/demo/src/main/res/drawable/ic_error_white_24dp.xml @@ -1,4 +1,10 @@ - - + + diff --git a/demo/src/main/res/layout/activity_simple_video_view.xml b/demo/src/main/res/layout/activity_simple_video_view.xml index 8b31fde..0fb3d31 100644 --- a/demo/src/main/res/layout/activity_simple_video_view.xml +++ b/demo/src/main/res/layout/activity_simple_video_view.xml @@ -12,8 +12,7 @@ android:id="@+id/videoView" android:layout_width="match_parent" android:layout_height="0dp" - android:layout_weight="1.5" - /> + android:layout_weight="1.5" /> - diff --git a/demo/src/test/java/com/jarvanmo/demo/ExampleUnitTest.java b/demo/src/test/java/com/jarvanmo/demo/ExampleUnitTest.java index f8e5ab1..7642105 100644 --- a/demo/src/test/java/com/jarvanmo/demo/ExampleUnitTest.java +++ b/demo/src/test/java/com/jarvanmo/demo/ExampleUnitTest.java @@ -2,7 +2,7 @@ import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; /** * Example local unit test, which will execute on the development machine (host). diff --git a/exoplayerview/build.gradle b/exoplayerview/build.gradle index 95edec0..a347608 100644 --- a/exoplayerview/build.gradle +++ b/exoplayerview/build.gradle @@ -11,7 +11,7 @@ android { versionName "2.0.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - vectorDrawables.useSupportLibrary= true + vectorDrawables.useSupportLibrary = true } diff --git a/exoplayerview/src/main/AndroidManifest.xml b/exoplayerview/src/main/AndroidManifest.xml index 45ddd35..9273d83 100644 --- a/exoplayerview/src/main/AndroidManifest.xml +++ b/exoplayerview/src/main/AndroidManifest.xml @@ -1,11 +1,14 @@ - - - - - + + + + + diff --git a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/ads/ExoAdsLoader.java b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/ads/ExoAdsLoader.java index 417f602..b96a77b 100644 --- a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/ads/ExoAdsLoader.java +++ b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/ads/ExoAdsLoader.java @@ -11,7 +11,7 @@ * 剑气纵横三万里 一剑光寒十九洲 */ -public class ExoAdsLoader extends Player.DefaultEventListener implements AdsLoader{ +public class ExoAdsLoader extends Player.DefaultEventListener implements AdsLoader { @Override public void setSupportedContentTypes(int... contentTypes) { diff --git a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/extension/MultiQualitySelectorAdapter.java b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/extension/MultiQualitySelectorAdapter.java index 098ac34..d2672e5 100644 --- a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/extension/MultiQualitySelectorAdapter.java +++ b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/extension/MultiQualitySelectorAdapter.java @@ -38,7 +38,7 @@ public MultiQualitySelectorAdapter(List qualities, Multi @Override public MultiQualitySelectorViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { - View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_quality, parent,false); + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_quality, parent, false); return new MultiQualitySelectorViewHolder(view); } diff --git a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/gesture/OnVideoGestureChangeListener.java b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/gesture/OnVideoGestureChangeListener.java index aad4b66..e06ec8a 100644 --- a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/gesture/OnVideoGestureChangeListener.java +++ b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/gesture/OnVideoGestureChangeListener.java @@ -13,8 +13,8 @@ public interface OnVideoGestureChangeListener { int VOLUME_CHANGED_REDUCTION = -1; - int VOLUME_CHANGED_MUTE =VOLUME_CHANGED_REDUCTION+1; - int VOLUME_CHANGED_INCREMENT =VOLUME_CHANGED_MUTE+1; + int VOLUME_CHANGED_MUTE = VOLUME_CHANGED_REDUCTION + 1; + int VOLUME_CHANGED_INCREMENT = VOLUME_CHANGED_MUTE + 1; @IntDef({VOLUME_CHANGED_REDUCTION, VOLUME_CHANGED_MUTE, VOLUME_CHANGED_INCREMENT}) @@ -24,7 +24,7 @@ public interface OnVideoGestureChangeListener { } - void onVolumeChanged(int range,@VolumeChangeType int type); + void onVolumeChanged(int range, @VolumeChangeType int type); void onBrightnessChanged(int brightnessPercent); diff --git a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/gesture/VideoGesture.java b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/gesture/VideoGesture.java index c89ab79..e0dd8e8 100644 --- a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/gesture/VideoGesture.java +++ b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/gesture/VideoGesture.java @@ -58,7 +58,7 @@ public class VideoGesture implements View.OnTouchListener { private boolean enabled = true; - public VideoGesture(Context context, OnVideoGestureChangeListener onVideoGestureChangeListener,@NonNull ExoVideoPlaybackControlView.PlayerAccessor playerAccessor) { + public VideoGesture(Context context, OnVideoGestureChangeListener onVideoGestureChangeListener, @NonNull ExoVideoPlaybackControlView.PlayerAccessor playerAccessor) { this.context = context; this.onVideoGestureChangeListener = onVideoGestureChangeListener; mAudioManager = (AudioManager) context.getSystemService(AUDIO_SERVICE); @@ -76,6 +76,7 @@ private void initVol() { mAudioMax = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); } + @SuppressLint("ClickableViewAccessibility") @Override public boolean onTouch(View v, MotionEvent event) { @@ -299,11 +300,11 @@ private void doSeekTouch(int coef, float gesturesize, boolean seek) { if (length > 0) { //Show the jump's size - seekAndShowJump(seek,time + jump, jump > 0); + seekAndShowJump(seek, time + jump, jump > 0); } } - private void seekAndShowJump(boolean seek,long jumpSize, boolean isFastForward) { + private void seekAndShowJump(boolean seek, long jumpSize, boolean isFastForward) { if (onVideoGestureChangeListener != null) { onVideoGestureChangeListener.onShowSeekSize(jumpSize, isFastForward); } diff --git a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/media/EventLogger.java b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/media/EventLogger.java index 84bed5f..77a6965 100644 --- a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/media/EventLogger.java +++ b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/media/EventLogger.java @@ -42,184 +42,184 @@ * Logs player events using {@link Log}. */ /* package */ final class EventLogger implements Player.EventListener, MetadataOutput, - AudioRendererEventListener, VideoRendererEventListener, AdaptiveMediaSourceEventListener, - ExtractorMediaSource.EventListener, DefaultDrmSessionManager.EventListener { + AudioRendererEventListener, VideoRendererEventListener, AdaptiveMediaSourceEventListener, + ExtractorMediaSource.EventListener, DefaultDrmSessionManager.EventListener { - public EventLogger(MappingTrackSelector trackSelector) { - } + public EventLogger(MappingTrackSelector trackSelector) { + } - @Override - public void onTimelineChanged(Timeline timeline, Object manifest) { + @Override + public void onTimelineChanged(Timeline timeline, Object manifest) { - } + } - @Override - public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) { + @Override + public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) { - } + } - @Override - public void onLoadingChanged(boolean isLoading) { + @Override + public void onLoadingChanged(boolean isLoading) { - } + } - @Override - public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { + @Override + public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { - } + } - @Override - public void onRepeatModeChanged(int repeatMode) { + @Override + public void onRepeatModeChanged(int repeatMode) { - } + } - @Override - public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) { + @Override + public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) { - } + } - @Override - public void onPlayerError(ExoPlaybackException error) { + @Override + public void onPlayerError(ExoPlaybackException error) { - } + } - @Override - public void onPositionDiscontinuity(int reason) { + @Override + public void onPositionDiscontinuity(int reason) { - } + } - @Override - public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) { + @Override + public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) { - } + } - @Override - public void onSeekProcessed() { + @Override + public void onSeekProcessed() { - } + } - @Override - public void onAudioEnabled(DecoderCounters counters) { + @Override + public void onAudioEnabled(DecoderCounters counters) { - } + } - @Override - public void onAudioSessionId(int audioSessionId) { + @Override + public void onAudioSessionId(int audioSessionId) { - } + } - @Override - public void onAudioDecoderInitialized(String decoderName, long initializedTimestampMs, long initializationDurationMs) { + @Override + public void onAudioDecoderInitialized(String decoderName, long initializedTimestampMs, long initializationDurationMs) { - } + } - @Override - public void onAudioInputFormatChanged(Format format) { + @Override + public void onAudioInputFormatChanged(Format format) { - } + } - @Override - public void onAudioSinkUnderrun(int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs) { + @Override + public void onAudioSinkUnderrun(int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs) { - } + } - @Override - public void onAudioDisabled(DecoderCounters counters) { + @Override + public void onAudioDisabled(DecoderCounters counters) { - } + } - @Override - public void onDrmKeysLoaded() { + @Override + public void onDrmKeysLoaded() { - } + } - @Override - public void onDrmSessionManagerError(Exception e) { + @Override + public void onDrmSessionManagerError(Exception e) { - } + } - @Override - public void onDrmKeysRestored() { + @Override + public void onDrmKeysRestored() { - } + } - @Override - public void onDrmKeysRemoved() { + @Override + public void onDrmKeysRemoved() { - } + } - @Override - public void onMetadata(Metadata metadata) { + @Override + public void onMetadata(Metadata metadata) { - } + } - @Override - public void onLoadError(IOException error) { + @Override + public void onLoadError(IOException error) { - } + } - @Override - public void onLoadStarted(DataSpec dataSpec, int dataType, int trackType, Format trackFormat, int trackSelectionReason, Object trackSelectionData, long mediaStartTimeMs, long mediaEndTimeMs, long elapsedRealtimeMs) { + @Override + public void onLoadStarted(DataSpec dataSpec, int dataType, int trackType, Format trackFormat, int trackSelectionReason, Object trackSelectionData, long mediaStartTimeMs, long mediaEndTimeMs, long elapsedRealtimeMs) { - } + } - @Override - public void onLoadCompleted(DataSpec dataSpec, int dataType, int trackType, Format trackFormat, int trackSelectionReason, Object trackSelectionData, long mediaStartTimeMs, long mediaEndTimeMs, long elapsedRealtimeMs, long loadDurationMs, long bytesLoaded) { + @Override + public void onLoadCompleted(DataSpec dataSpec, int dataType, int trackType, Format trackFormat, int trackSelectionReason, Object trackSelectionData, long mediaStartTimeMs, long mediaEndTimeMs, long elapsedRealtimeMs, long loadDurationMs, long bytesLoaded) { - } + } - @Override - public void onLoadCanceled(DataSpec dataSpec, int dataType, int trackType, Format trackFormat, int trackSelectionReason, Object trackSelectionData, long mediaStartTimeMs, long mediaEndTimeMs, long elapsedRealtimeMs, long loadDurationMs, long bytesLoaded) { + @Override + public void onLoadCanceled(DataSpec dataSpec, int dataType, int trackType, Format trackFormat, int trackSelectionReason, Object trackSelectionData, long mediaStartTimeMs, long mediaEndTimeMs, long elapsedRealtimeMs, long loadDurationMs, long bytesLoaded) { - } + } - @Override - public void onLoadError(DataSpec dataSpec, int dataType, int trackType, Format trackFormat, int trackSelectionReason, Object trackSelectionData, long mediaStartTimeMs, long mediaEndTimeMs, long elapsedRealtimeMs, long loadDurationMs, long bytesLoaded, IOException error, boolean wasCanceled) { + @Override + public void onLoadError(DataSpec dataSpec, int dataType, int trackType, Format trackFormat, int trackSelectionReason, Object trackSelectionData, long mediaStartTimeMs, long mediaEndTimeMs, long elapsedRealtimeMs, long loadDurationMs, long bytesLoaded, IOException error, boolean wasCanceled) { - } + } - @Override - public void onUpstreamDiscarded(int trackType, long mediaStartTimeMs, long mediaEndTimeMs) { + @Override + public void onUpstreamDiscarded(int trackType, long mediaStartTimeMs, long mediaEndTimeMs) { - } + } - @Override - public void onDownstreamFormatChanged(int trackType, Format trackFormat, int trackSelectionReason, Object trackSelectionData, long mediaTimeMs) { + @Override + public void onDownstreamFormatChanged(int trackType, Format trackFormat, int trackSelectionReason, Object trackSelectionData, long mediaTimeMs) { - } + } - @Override - public void onVideoEnabled(DecoderCounters counters) { + @Override + public void onVideoEnabled(DecoderCounters counters) { - } + } - @Override - public void onVideoDecoderInitialized(String decoderName, long initializedTimestampMs, long initializationDurationMs) { + @Override + public void onVideoDecoderInitialized(String decoderName, long initializedTimestampMs, long initializationDurationMs) { - } + } - @Override - public void onVideoInputFormatChanged(Format format) { + @Override + public void onVideoInputFormatChanged(Format format) { - } + } - @Override - public void onDroppedFrames(int count, long elapsedMs) { + @Override + public void onDroppedFrames(int count, long elapsedMs) { - } + } - @Override - public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) { + @Override + public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) { - } + } - @Override - public void onRenderedFirstFrame(Surface surface) { + @Override + public void onRenderedFirstFrame(Surface surface) { - } + } - @Override - public void onVideoDisabled(DecoderCounters counters) { + @Override + public void onVideoDisabled(DecoderCounters counters) { - } + } } diff --git a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/media/ExoMediaSource.java b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/media/ExoMediaSource.java index eec1bd5..ad87b63 100644 --- a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/media/ExoMediaSource.java +++ b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/media/ExoMediaSource.java @@ -9,13 +9,17 @@ public interface ExoMediaSource { - interface Quality{ + interface Quality { CharSequence name(); + String url(); } String url(); + String name(); + List qualities(); + String extension(); } diff --git a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/media/SimpleQuality.java b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/media/SimpleQuality.java index cec2d5f..8c0cf03 100644 --- a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/media/SimpleQuality.java +++ b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/media/SimpleQuality.java @@ -1,8 +1,5 @@ package com.jarvanmo.exoplayerview.media; -import android.os.Parcel; -import android.os.Parcelable; - /** * Created by mo on 18-2-7. * diff --git a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/orientation/SensorOrientation.java b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/orientation/SensorOrientation.java index a2d7bcf..3a9c8f1 100644 --- a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/orientation/SensorOrientation.java +++ b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/orientation/SensorOrientation.java @@ -21,7 +21,7 @@ public class SensorOrientation { private final Context context; private final OrientationEventListener screenOrientationEventListener; - public SensorOrientation(Context context,OnOrientationChangedListener onOrientationChangedListener) { + public SensorOrientation(Context context, OnOrientationChangedListener onOrientationChangedListener) { this.context = context; screenOrientationEventListener = new OrientationEventListener(context) { @Override @@ -74,17 +74,17 @@ private boolean isScreenOpenRotate() { gravity = Settings.System.getInt(context.getContentResolver(), Settings.System.ACCELEROMETER_ROTATION); } catch (Settings.SettingNotFoundException e) { - Log.e(getClass().getSimpleName(),e.getMessage()+""); + Log.e(getClass().getSimpleName(), e.getMessage() + ""); } return 1 == gravity; } - public void enable(){ + public void enable() { screenOrientationEventListener.enable(); } - public void disable(){ + public void disable() { screenOrientationEventListener.disable(); } } diff --git a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/ui/ExoVideoPlaybackControlView.java b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/ui/ExoVideoPlaybackControlView.java index 78c89ab..97d84f2 100644 --- a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/ui/ExoVideoPlaybackControlView.java +++ b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/ui/ExoVideoPlaybackControlView.java @@ -18,7 +18,6 @@ import android.text.Spanned; import android.text.style.ForegroundColorSpan; import android.util.AttributeSet; -import android.util.Log; import android.util.TypedValue; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -62,13 +61,13 @@ * Created by mo on 16-11-7. * * @author mo - * - * *

Specifying a custom layout file

- * Defining your own {@code exo_video_playback_control_view.xml} is useful to customize the layout of - * ExoVideoPlaybackControlView throughout your application. It's also possible to customize the layout for a - * single instance in a layout file. This is achieved by setting the {@code controller_layout_id} - * attribute on a ExoVideoPlaybackControlView. This will cause the specified layout to be inflated instead - * of {@code exo_video_playback_control_view.xml} for only the instance on which the attribute is set. + *

+ * *

Specifying a custom layout file

+ * Defining your own {@code exo_video_playback_control_view.xml} is useful to customize the layout of + * ExoVideoPlaybackControlView throughout your application. It's also possible to customize the layout for a + * single instance in a layout file. This is achieved by setting the {@code controller_layout_id} + * attribute on a ExoVideoPlaybackControlView. This will cause the specified layout to be inflated instead + * of {@code exo_video_playback_control_view.xml} for only the instance on which the attribute is set. */ public class ExoVideoPlaybackControlView extends FrameLayout { @@ -527,7 +526,7 @@ public void onShowSeekSize(long seekSize, boolean fastForward) { return; } - if(centerError !=null && centerError.getVisibility() == VISIBLE){ + if (centerError != null && centerError.getVisibility() == VISIBLE) { centerError.setVisibility(GONE); } centerInfo.setVisibility(VISIBLE); @@ -592,7 +591,7 @@ private void setVolumeOrBrightnessInfo(String txt, @DrawableRes int drawableId) return; } - if(centerError !=null && centerError.getVisibility() == VISIBLE){ + if (centerError != null && centerError.getVisibility() == VISIBLE) { centerError.setVisibility(GONE); } @@ -1342,10 +1341,10 @@ private void showControllerByDisplayMode() { if (exoPlayerControllerTop != null) { boolean showByMode = (displayMode & CONTROLLER_MODE_TOP) == CONTROLLER_MODE_TOP; - if(portrait){ + if (portrait) { int visibility = showByMode ? VISIBLE : INVISIBLE; exoPlayerControllerTop.setVisibility(visibility); - }else { + } else { exoPlayerControllerTop.setVisibility(INVISIBLE); } @@ -1353,9 +1352,9 @@ private void showControllerByDisplayMode() { if (exoPlayerControllerTopLandscape != null) { boolean showByMode = (displayMode & CONTROLLER_MODE_TOP_LANDSCAPE) == CONTROLLER_MODE_TOP_LANDSCAPE; - if(portrait){ + if (portrait) { exoPlayerControllerTopLandscape.setVisibility(INVISIBLE); - }else { + } else { int visibility = showByMode ? VISIBLE : INVISIBLE; exoPlayerControllerTopLandscape.setVisibility(visibility); } @@ -1363,10 +1362,10 @@ private void showControllerByDisplayMode() { if (exoPlayerControllerBottom != null) { boolean showByMode = (displayMode & CONTROLLER_MODE_BOTTOM) == CONTROLLER_MODE_BOTTOM; - if(portrait){ + if (portrait) { int visibility = showByMode ? VISIBLE : INVISIBLE; exoPlayerControllerBottom.setVisibility(visibility); - }else { + } else { exoPlayerControllerBottom.setVisibility(INVISIBLE); } @@ -1374,9 +1373,9 @@ private void showControllerByDisplayMode() { if (exoPlayerControllerBottomLandscape != null) { boolean showByMode = (displayMode & CONTROLLER_MODE_BOTTOM_LANDSCAPE) == CONTROLLER_MODE_BOTTOM_LANDSCAPE; - if(portrait){ + if (portrait) { exoPlayerControllerBottomLandscape.setVisibility(INVISIBLE); - }else { + } else { int visibility = showByMode ? VISIBLE : INVISIBLE; exoPlayerControllerBottomLandscape.setVisibility(visibility); } @@ -1569,7 +1568,7 @@ public void onScrubStop(TimeBar timeBar, long position, boolean canceled) { public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { updatePlayPauseButton(); updateProgress(); - if(playbackState != Player.STATE_IDLE &¢erError !=null && centerError.getVisibility() == VISIBLE){ + if (playbackState != Player.STATE_IDLE && centerError != null && centerError.getVisibility() == VISIBLE) { centerError.setVisibility(GONE); } } @@ -1610,8 +1609,8 @@ public void onTimelineChanged(Timeline timeline, Object manifest) { @Override public void onPlayerError(ExoPlaybackException error) { super.onPlayerError(error); - if(centerError !=null ){ - String errorText = getResources().getString(R.string.player_error,error.type); + if (centerError != null) { + String errorText = getResources().getString(R.string.player_error, error.type); centerError.setText(errorText); centerError.setVisibility(VISIBLE); } diff --git a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/ui/ExoVideoView.java b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/ui/ExoVideoView.java index 9304c22..c074db4 100644 --- a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/ui/ExoVideoView.java +++ b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/ui/ExoVideoView.java @@ -667,9 +667,9 @@ public boolean onTouchEvent(MotionEvent ev) { if (!useController || player == null || ev.getActionMasked() != MotionEvent.ACTION_DOWN) { return false; } - if (enableMultiQuality ) { + if (enableMultiQuality) { View v = overlayFrameLayout.findViewById(R.id.exo_player_quality_container); - if(v != null && overlayFrameLayout.getVisibility() == VISIBLE){ + if (v != null && overlayFrameLayout.getVisibility() == VISIBLE) { return true; } @@ -1058,7 +1058,7 @@ public View attachVideoView() { **/ public void addCustomView(@ExoVideoPlaybackControlView.CustomViewType int customViewType, View customView, boolean removeViews) { if (useController && controller != null) { - controller.addCustomView(customViewType,customView,removeViews); + controller.addCustomView(customViewType, customView, removeViews); } } diff --git a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/util/AndroidUtil.java b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/util/AndroidUtil.java index 4a5e52f..98f11e0 100644 --- a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/util/AndroidUtil.java +++ b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/util/AndroidUtil.java @@ -28,7 +28,6 @@ public class AndroidUtil { - public static boolean isJellyBeanMR1OrLater() { return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1; } diff --git a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/util/Permissions.java b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/util/Permissions.java index f6cb742..22b4f8c 100644 --- a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/util/Permissions.java +++ b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/util/Permissions.java @@ -58,12 +58,12 @@ public static boolean canWriteSettings(Context context) { } public static boolean canReadStorage(Context context) { - return !AndroidUtil.isMarshMallowOrLater() ||ContextCompat.checkSelfPermission(context, + return !AndroidUtil.isMarshMallowOrLater() || ContextCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED; } - private static void requestStoragePermission(Activity activity){ + private static void requestStoragePermission(Activity activity) { ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, PERMISSION_STORAGE_TAG); diff --git a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/widget/BatteryLevelView.java b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/widget/BatteryLevelView.java index 04fb430..44b3735 100644 --- a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/widget/BatteryLevelView.java +++ b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/widget/BatteryLevelView.java @@ -32,7 +32,6 @@ public class BatteryLevelView extends View { private int measureWidth; private int measureHeight; /** - * * 电池参数 */ private float mBatteryHeight = 30f; // 电池的高度 @@ -40,7 +39,6 @@ public class BatteryLevelView extends View { private float mCapHeight = 15f; private float mCapWidth = 5f; /** - * * 电池电量 */ private float mPowerPadding = 1; @@ -50,7 +48,6 @@ public class BatteryLevelView extends View { * 2;// 电池身体的总宽度 private float mPower = 10f; /** - * * 矩形 */ private RectF mBatteryRect; @@ -61,11 +58,11 @@ public class BatteryLevelView extends View { private boolean mIsCharging = false; public BatteryLevelView(Context context) { - this(context,null); + this(context, null); } public BatteryLevelView(Context context, @Nullable AttributeSet attrs) { - this(context, attrs,0); + this(context, attrs, 0); } public BatteryLevelView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { @@ -135,17 +132,16 @@ public void setPower(float power) { } - - private int getPowerColor(){ - if(mIsCharging){ + private int getPowerColor() { + if (mIsCharging) { return Color.GREEN; } - if(mPower <= 15){ - return Color.RED; - }else if(mPower<= 30){ + if (mPower <= 15) { + return Color.RED; + } else if (mPower <= 30) { return Color.YELLOW; - }else { + } else { return Color.WHITE; } } @@ -160,7 +156,7 @@ public void onReceive(Context context, Intent intent) { int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1); - float percent = ((float)(level * 100)) / scale; + float percent = ((float) (level * 100)) / scale; setPower(percent); } }; @@ -168,7 +164,7 @@ public void onReceive(Context context, Intent intent) { @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); - getContext().registerReceiver(mPowerConnectionReceiver,new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); + getContext().registerReceiver(mPowerConnectionReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); } @Override diff --git a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/widget/BatteryStatusView.java b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/widget/BatteryStatusView.java index 0609296..29ca168 100644 --- a/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/widget/BatteryStatusView.java +++ b/exoplayerview/src/main/java/com/jarvanmo/exoplayerview/widget/BatteryStatusView.java @@ -4,15 +4,10 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.RectF; import android.os.BatteryManager; import android.support.annotation.Nullable; import android.support.v7.widget.AppCompatImageView; import android.util.AttributeSet; -import android.view.View; import com.jarvanmo.exoplayerview.R; @@ -24,14 +19,12 @@ public class BatteryStatusView extends AppCompatImageView { - - public BatteryStatusView(Context context) { - this(context,null); + this(context, null); } public BatteryStatusView(Context context, @Nullable AttributeSet attrs) { - this(context, attrs,0); + this(context, attrs, 0); } public BatteryStatusView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { @@ -39,26 +32,25 @@ public BatteryStatusView(Context context, @Nullable AttributeSet attrs, int defS init(); } - private void init(){ + private void init() { setImageResource(R.drawable.stat_sys_battery); setImageLevel(100); } - private BroadcastReceiver mPowerConnectionReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1); - boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING || + boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL; int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1); - if(isCharging){ + if (isCharging) { setImageResource(R.drawable.stat_sys_battery_charge); - }else { + } else { setImageResource(R.drawable.stat_sys_battery); } setImageLevel(level); @@ -69,7 +61,7 @@ public void onReceive(Context context, Intent intent) { @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); - getContext().registerReceiver(mPowerConnectionReceiver,new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); + getContext().registerReceiver(mPowerConnectionReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); } @Override diff --git a/exoplayerview/src/main/res/drawable/ic_error_outline_white_48dp.xml b/exoplayerview/src/main/res/drawable/ic_error_outline_white_48dp.xml index 060b8cf..c55d68d 100644 --- a/exoplayerview/src/main/res/drawable/ic_error_outline_white_48dp.xml +++ b/exoplayerview/src/main/res/drawable/ic_error_outline_white_48dp.xml @@ -1,4 +1,10 @@ - - + + diff --git a/exoplayerview/src/main/res/drawable/stat_sys_battery.xml b/exoplayerview/src/main/res/drawable/stat_sys_battery.xml index 6ed16f2..e9349a9 100644 --- a/exoplayerview/src/main/res/drawable/stat_sys_battery.xml +++ b/exoplayerview/src/main/res/drawable/stat_sys_battery.xml @@ -1,5 +1,4 @@ - - - - - - - - - - + + + + + + + + diff --git a/exoplayerview/src/main/res/drawable/stat_sys_battery_charge.xml b/exoplayerview/src/main/res/drawable/stat_sys_battery_charge.xml index caf0da2..2c98dba 100644 --- a/exoplayerview/src/main/res/drawable/stat_sys_battery_charge.xml +++ b/exoplayerview/src/main/res/drawable/stat_sys_battery_charge.xml @@ -1,5 +1,4 @@ - - - - - - - - - - + + + + + + + + diff --git a/exoplayerview/src/main/res/values/attrs.xml b/exoplayerview/src/main/res/values/attrs.xml index da07ca0..154a538 100644 --- a/exoplayerview/src/main/res/values/attrs.xml +++ b/exoplayerview/src/main/res/values/attrs.xml @@ -8,29 +8,29 @@ - - - - + + + + - - - + + + - - - - - + + + + + - - - + + + - + @@ -38,64 +38,63 @@ - - - - - - + + + + + + - + - - - - - - - - - - - - - + + + + + + + + + + + + + - + - + - - - - - - - + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - \ No newline at end of file diff --git a/exoplayerview/src/main/res/values/ids.xml b/exoplayerview/src/main/res/values/ids.xml index 28db280..926fafc 100644 --- a/exoplayerview/src/main/res/values/ids.xml +++ b/exoplayerview/src/main/res/values/ids.xml @@ -1,43 +1,43 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - + + + \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index aac7c9b..743d692 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,16 +1,12 @@ # Project-wide Gradle settings. - # IDE (e.g. Android Studio) users: # Gradle settings configured through the IDE *will override* # any settings specified in this file. - # 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. org.gradle.jvmargs=-Xmx1536m - # 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