diff --git a/PLDroidPlayerDemo/app/build.gradle b/PLDroidPlayerDemo/app/build.gradle index c976b3f..befb44b 100644 --- a/PLDroidPlayerDemo/app/build.gradle +++ b/PLDroidPlayerDemo/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId "com.pili.pldroid.playerdemo" minSdkVersion 9 targetSdkVersion 22 - versionCode 3 - versionName "1.3.2" + versionCode 4 + versionName "1.4.0" } buildTypes { release { @@ -20,8 +20,8 @@ android { } dependencies { + compile files('libs/pldroid-player-1.4.0.jar') compile 'com.android.support:appcompat-v7:22+' - compile files('libs/pldroid-player-1.3.2.jar') compile 'com.qiniu:happy-dns:0.2.+' compile 'com.qiniu.pili:pili-android-qos:0.8.+' } diff --git a/PLDroidPlayerDemo/app/libs/pldroid-player-1.3.2.jar b/PLDroidPlayerDemo/app/libs/pldroid-player-1.3.2.jar deleted file mode 100644 index c696ac3..0000000 Binary files a/PLDroidPlayerDemo/app/libs/pldroid-player-1.3.2.jar and /dev/null differ diff --git a/PLDroidPlayerDemo/app/libs/pldroid-player-1.4.0.jar b/PLDroidPlayerDemo/app/libs/pldroid-player-1.4.0.jar new file mode 100644 index 0000000..e913f1c Binary files /dev/null and b/PLDroidPlayerDemo/app/libs/pldroid-player-1.4.0.jar differ diff --git a/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/MainActivity.java b/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/MainActivity.java index 692e735..124c52e 100644 --- a/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/MainActivity.java +++ b/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/MainActivity.java @@ -2,6 +2,7 @@ import android.app.Activity; import android.content.Intent; +import android.os.Build; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; @@ -47,6 +48,9 @@ protected void onCreate(Bundle savedInstanceState) { e.printStackTrace(); } + TextView mVersionInfoTextView = (TextView) findViewById(R.id.version_info); + mVersionInfoTextView.setText("Version: " + BuildConfig.VERSION_NAME); + mEditText = (EditText)findViewById(R.id.VideoPathEdit); mEditText.setText(DEFAULT_TEST_URL); diff --git a/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLAudioPlayerActivity.java b/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLAudioPlayerActivity.java index 5f213c6..4ad5f80 100644 --- a/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLAudioPlayerActivity.java +++ b/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLAudioPlayerActivity.java @@ -119,9 +119,11 @@ public void onClickStop(View v) { } public void release() { - mMediaPlayer.stop(); - mMediaPlayer.release(); - mMediaPlayer = null; + if (mMediaPlayer != null) { + mMediaPlayer.stop(); + mMediaPlayer.release(); + mMediaPlayer = null; + } } private void prepare() { diff --git a/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLMediaPlayerActivity.java b/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLMediaPlayerActivity.java index 88a2352..9062e5b 100644 --- a/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLMediaPlayerActivity.java +++ b/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLMediaPlayerActivity.java @@ -26,7 +26,7 @@ /** * This demo shows how to use PLMediaPlayer API playing video stream */ -public class PLMediaPlayerActivity extends AppCompatActivity { +public class PLMediaPlayerActivity extends VideoPlayerBaseActivity { private static final String TAG = PLMediaPlayerActivity.class.getSimpleName(); @@ -48,7 +48,6 @@ public class PLMediaPlayerActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { - getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); super.onCreate(savedInstanceState); setContentView(R.layout.activity_media_player); mLoadingView = findViewById(R.id.LoadingView); diff --git a/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLVideoTextureActivity.java b/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLVideoTextureActivity.java index 1e4b8ea..c2d24ed 100644 --- a/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLVideoTextureActivity.java +++ b/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLVideoTextureActivity.java @@ -4,9 +4,8 @@ import android.os.Handler; import android.os.Looper; import android.os.Message; -import android.support.v7.app.AppCompatActivity; import android.view.View; -import android.view.WindowManager; +import android.widget.ImageView; import android.widget.Toast; import com.pili.pldroid.player.AVOptions; @@ -18,7 +17,7 @@ /** * This is a demo activity of PLVideoTextureView */ -public class PLVideoTextureActivity extends AppCompatActivity { +public class PLVideoTextureActivity extends VideoPlayerBaseActivity { private static final int MESSAGE_ID_RECONNECTING = 0x01; @@ -29,18 +28,19 @@ public class PLVideoTextureActivity extends AppCompatActivity { private int mRotation = 0; private int mDisplayAspectRatio = PLVideoTextureView.ASPECT_RATIO_FIT_PARENT; //default private View mLoadingView; + private View mCoverView = null; private boolean mIsActivityPaused = true; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_pl_video_texture); mVideoView = (PLVideoTextureView) findViewById(R.id.VideoView); - mLoadingView = findViewById(R.id.LoadingView); mVideoView.setBufferingIndicator(mLoadingView); mLoadingView.setVisibility(View.VISIBLE); + mCoverView = (ImageView) findViewById(R.id.CoverView); + mVideoView.setCoverView(mCoverView); mVideoPath = getIntent().getStringExtra("videoPath"); diff --git a/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLVideoViewActivity.java b/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLVideoViewActivity.java index e544507..89c7ec0 100644 --- a/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLVideoViewActivity.java +++ b/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLVideoViewActivity.java @@ -4,10 +4,9 @@ import android.os.Handler; import android.os.Looper; import android.os.Message; -import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.View; -import android.view.WindowManager; +import android.widget.ImageView; import android.widget.Toast; import com.pili.pldroid.player.AVOptions; @@ -17,9 +16,9 @@ import com.pili.pldroid.playerdemo.widget.MediaController; /** - * This is a demo activity of PLVideoView + * This is a demo activity of PLVideoView */ -public class PLVideoViewActivity extends AppCompatActivity { +public class PLVideoViewActivity extends VideoPlayerBaseActivity { private static final String TAG = PLVideoViewActivity.class.getSimpleName(); @@ -32,14 +31,16 @@ public class PLVideoViewActivity extends AppCompatActivity { private int mDisplayAspectRatio = PLVideoView.ASPECT_RATIO_FIT_PARENT; private boolean mIsActivityPaused = true; private View mLoadingView; + private View mCoverView = null; @Override protected void onCreate(Bundle savedInstanceState) { - getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); super.onCreate(savedInstanceState); setContentView(R.layout.activity_pl_video_view); mVideoView = (PLVideoView) findViewById(R.id.VideoView); + mCoverView = (ImageView) findViewById(R.id.CoverView); + mVideoView.setCoverView(mCoverView); mLoadingView = findViewById(R.id.LoadingView); mVideoView.setBufferingIndicator(mLoadingView); mLoadingView.setVisibility(View.VISIBLE); @@ -78,7 +79,7 @@ protected void onCreate(Bundle savedInstanceState) { mVideoView.setVideoPath(mVideoPath); // You can also use a custom `MediaController` widget - mMediaController = new MediaController(this, false, isLiveStreaming==1); + mMediaController = new MediaController(this, false, isLiveStreaming == 1); mVideoView.setMediaController(mMediaController); } @@ -214,7 +215,7 @@ public void onBufferingUpdate(PLMediaPlayer plMediaPlayer, int precent) { @Override public void onSeekComplete(PLMediaPlayer plMediaPlayer) { Log.d(TAG, "onSeekComplete !"); - }; + } }; private PLMediaPlayer.OnVideoSizeChangedListener mOnVideoSizeChangedListener = new PLMediaPlayer.OnVideoSizeChangedListener() { diff --git a/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/VideoPlayerBaseActivity.java b/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/VideoPlayerBaseActivity.java new file mode 100644 index 0000000..c68afc2 --- /dev/null +++ b/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/VideoPlayerBaseActivity.java @@ -0,0 +1,29 @@ +package com.pili.pldroid.playerdemo; + +import android.os.Build; +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v7.app.AppCompatActivity; +import android.view.View; +import android.view.WindowManager; + +/** + * Created by kongweile on 29/10/2016. + * Auto hide and show navigation bar and status bar for API >= 19. + * Keep screen on. + */ + +public class VideoPlayerBaseActivity extends AppCompatActivity { + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + View decorView = getWindow().getDecorView(); + decorView.setSystemUiVisibility( + View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_FULLSCREEN + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); + } + getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + } +} diff --git a/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/VideoViewActivity.java b/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/VideoViewActivity.java index 13bcbfd..72cf7bf 100644 --- a/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/VideoViewActivity.java +++ b/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/VideoViewActivity.java @@ -3,7 +3,6 @@ import android.content.Intent; import android.content.pm.ActivityInfo; import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; import android.text.TextUtils; import android.util.Log; import android.util.Pair; @@ -28,7 +27,7 @@ * This is a demo activity of com.pili.pldroid.player.widget.VideoView * @deprecated Use {@link PLVideoView} instead. */ -public class VideoViewActivity extends AppCompatActivity implements +public class VideoViewActivity extends VideoPlayerBaseActivity implements IjkMediaPlayer.OnCompletionListener, IjkMediaPlayer.OnInfoListener, IjkMediaPlayer.OnErrorListener, @@ -58,7 +57,6 @@ public class VideoViewActivity extends AppCompatActivity implements @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_video_view); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); diff --git a/PLDroidPlayerDemo/app/src/main/jniLibs/arm64-v8a/libpldroidplayer.so b/PLDroidPlayerDemo/app/src/main/jniLibs/arm64-v8a/libpldroidplayer.so index ac4e6ad..dce04b6 100755 Binary files a/PLDroidPlayerDemo/app/src/main/jniLibs/arm64-v8a/libpldroidplayer.so and b/PLDroidPlayerDemo/app/src/main/jniLibs/arm64-v8a/libpldroidplayer.so differ diff --git a/PLDroidPlayerDemo/app/src/main/jniLibs/armeabi-v7a/libpldroidplayer.so b/PLDroidPlayerDemo/app/src/main/jniLibs/armeabi-v7a/libpldroidplayer.so index 229c8b9..dc581e3 100755 Binary files a/PLDroidPlayerDemo/app/src/main/jniLibs/armeabi-v7a/libpldroidplayer.so and b/PLDroidPlayerDemo/app/src/main/jniLibs/armeabi-v7a/libpldroidplayer.so differ diff --git a/PLDroidPlayerDemo/app/src/main/jniLibs/armeabi/libpldroidplayer.so b/PLDroidPlayerDemo/app/src/main/jniLibs/armeabi/libpldroidplayer.so index 58026b1..4834e6c 100755 Binary files a/PLDroidPlayerDemo/app/src/main/jniLibs/armeabi/libpldroidplayer.so and b/PLDroidPlayerDemo/app/src/main/jniLibs/armeabi/libpldroidplayer.so differ diff --git a/PLDroidPlayerDemo/app/src/main/jniLibs/x86/libpldroidplayer.so b/PLDroidPlayerDemo/app/src/main/jniLibs/x86/libpldroidplayer.so index 7a817f1..79f494d 100755 Binary files a/PLDroidPlayerDemo/app/src/main/jniLibs/x86/libpldroidplayer.so and b/PLDroidPlayerDemo/app/src/main/jniLibs/x86/libpldroidplayer.so differ diff --git a/PLDroidPlayerDemo/app/src/main/res/drawable-hdpi/thumbnail.png b/PLDroidPlayerDemo/app/src/main/res/drawable-hdpi/thumbnail.png new file mode 100644 index 0000000..31f093b Binary files /dev/null and b/PLDroidPlayerDemo/app/src/main/res/drawable-hdpi/thumbnail.png differ diff --git a/PLDroidPlayerDemo/app/src/main/res/layout/activity_main.xml b/PLDroidPlayerDemo/app/src/main/res/layout/activity_main.xml index 40ab824..dd6b595 100644 --- a/PLDroidPlayerDemo/app/src/main/res/layout/activity_main.xml +++ b/PLDroidPlayerDemo/app/src/main/res/layout/activity_main.xml @@ -2,13 +2,21 @@ + android:orientation="vertical"> + + @@ -16,13 +24,13 @@ android:id="@+id/TestSpinner" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginLeft="10dp"/> + android:layout_marginLeft="10dp" /> @@ -30,23 +38,23 @@ android:id="@+id/StreamingTypeRadioGroup" android:layout_width="match_parent" android:layout_height="wrap_content" - android:orientation="horizontal" android:layout_marginLeft="15dp" - android:layout_marginTop="5dp" > + android:layout_marginTop="5dp" + android:orientation="horizontal"> + android:checked="true" + android:text="@string/live_streaming" /> + android:layout_marginLeft="10dp" + android:text="@string/playback" /> @@ -54,33 +62,33 @@ android:id="@+id/DecodeTypeRadioGroup" android:layout_width="match_parent" android:layout_height="wrap_content" - android:orientation="horizontal" android:layout_marginLeft="15dp" - android:layout_marginTop="5dp" > + android:layout_marginTop="5dp" + android:orientation="horizontal"> + android:checked="true" + android:text="@string/sw_decode" /> + android:layout_marginLeft="10dp" + android:text="@string/hw_decode" /> @@ -88,32 +96,32 @@ android:id="@+id/VideoPathEdit" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_margin="10dp" android:hint="@string/input_video_path" - android:singleLine="true" - android:textSize="18sp" android:padding="10sp" - android:layout_margin="10dp" /> + android:singleLine="true" + android:textSize="18sp" /> + android:layout_margin="10dp" + android:orientation="horizontal">