diff --git a/README.md b/README.md
index 62aa9af6..a2f8d1ec 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# YinYangPlayer
+# DCPlayer
A video player based on [IjkPlayer](https://github.com/Bilibili/ijkplayer).
[![](https://www.jitpack.io/v/DevlinChiu/YinYangPlayer.svg)](https://www.jitpack.io/#DevlinChiu/YinYangPlayer)
@@ -39,14 +39,14 @@ Step 1.Add it in your root build.gradle at the end of repositories:
Step 2. Add the dependency
dependencies {
- compile 'com.github.DevlinChiu:YinYangPlayer:1.2'
+ compile 'com.github.DevlinChiu:dcplayer:1.3'
}
```
或者将library下载并导入项目中使用
2.添加布局
```xml
-
@@ -54,9 +54,9 @@ Step 2. Add the dependency
3.设置视频地址、标题、Controller等
```java
-yinYangPlayer = (YinYangPlayer) findViewById(R.id.player);
+ijkVideoView = (IjkVideoView) findViewById(R.id.player);
StandardVideoController controller = new StandardVideoController(this);
-yinYangPlayer
+ijkVideoView
.autoRotate() //启用重力感应自动进入/推出全屏功能
.enableCache() //启用边播边缓存功能
.useSurfaceView() //启用SurfaceView显示视频,不调用默认使用TextureView
@@ -72,25 +72,25 @@ yinYangPlayer
@Override
protected void onPause() {
super.onPause();
- yinYangPlayer.pause();
+ ijkVideoView.pause();
}
@Override
protected void onResume() {
super.onResume();
- yinYangPlayer.resume();
+ ijkVideoView.resume();
}
@Override
protected void onDestroy() {
super.onDestroy();
- yinYangPlayer.release();
+ ijkVideoView.release();
}
@Override
public void onBackPressed() {
- if (!yinYangPlayer.onBackPressed()) {
+ if (!ijkVideoView.onBackPressed()) {
super.onBackPressed();
}
}
@@ -123,5 +123,5 @@ yinYangPlayer
## 混淆
-keep class tv.danmaku.ijk.** { *; }
-dontwarn tv.danmaku.ijk.**
- -keep class com.devlin_n.yinyangplayer.** { *; }
- -dontwarn com.devlin_n.yinyangplayer.**
+ -keep class com.devlin_n.videoplayer.** { *; }
+ -dontwarn com.devlin_n.videoplayer.**
diff --git a/app/build.gradle b/app/build.gradle
index 10115eb1..a6194eb5 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -5,7 +5,7 @@ android {
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
- applicationId "com.devlin_n.yyplayer"
+ applicationId "com.devlin_n.dcplayer"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 6
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index bc96ba2a..3a64ef23 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,19 +1,19 @@
+ package="com.devlin_n.dcplayer">
@@ -24,31 +24,31 @@
diff --git a/app/src/main/java/com/devlin_n/yyplayer/MainActivity.java b/app/src/main/java/com/devlin_n/dcplayer/MainActivity.java
similarity index 86%
rename from app/src/main/java/com/devlin_n/yyplayer/MainActivity.java
rename to app/src/main/java/com/devlin_n/dcplayer/MainActivity.java
index 0c1031fc..8096d5d4 100644
--- a/app/src/main/java/com/devlin_n/yyplayer/MainActivity.java
+++ b/app/src/main/java/com/devlin_n/dcplayer/MainActivity.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yyplayer;
+package com.devlin_n.dcplayer;
import android.Manifest;
import android.content.Intent;
@@ -16,15 +16,15 @@
import android.widget.RadioGroup;
import android.widget.Toast;
-import com.devlin_n.yinyangplayer.player.BackgroundPlayService;
-import com.devlin_n.yinyangplayer.player.VideoCacheManager;
-import com.devlin_n.yyplayer.activity.DanmakuActivity;
-import com.devlin_n.yyplayer.activity.FullScreenActivity;
-import com.devlin_n.yyplayer.activity.ListViewActivity;
-import com.devlin_n.yyplayer.activity.LivePlayerActivity;
-import com.devlin_n.yyplayer.activity.PlayerActivity;
-import com.devlin_n.yyplayer.activity.RecyclerViewActivity;
-import com.devlin_n.yyplayer.activity.VodPlayerActivity;
+import com.devlin_n.videoplayer.player.BackgroundPlayService;
+import com.devlin_n.videoplayer.player.VideoCacheManager;
+import com.devlin_n.dcplayer.activity.DanmakuActivity;
+import com.devlin_n.dcplayer.activity.FullScreenActivity;
+import com.devlin_n.dcplayer.activity.ListViewActivity;
+import com.devlin_n.dcplayer.activity.LivePlayerActivity;
+import com.devlin_n.dcplayer.activity.PlayerActivity;
+import com.devlin_n.dcplayer.activity.RecyclerViewActivity;
+import com.devlin_n.dcplayer.activity.VodPlayerActivity;
public class MainActivity extends AppCompatActivity {
diff --git a/app/src/main/java/com/devlin_n/yyplayer/activity/DanmakuActivity.java b/app/src/main/java/com/devlin_n/dcplayer/activity/DanmakuActivity.java
similarity index 93%
rename from app/src/main/java/com/devlin_n/yyplayer/activity/DanmakuActivity.java
rename to app/src/main/java/com/devlin_n/dcplayer/activity/DanmakuActivity.java
index becf41b0..f99277fb 100644
--- a/app/src/main/java/com/devlin_n/yyplayer/activity/DanmakuActivity.java
+++ b/app/src/main/java/com/devlin_n/dcplayer/activity/DanmakuActivity.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yyplayer.activity;
+package com.devlin_n.dcplayer.activity;
import android.content.Intent;
import android.graphics.Canvas;
@@ -20,11 +20,11 @@
import android.widget.Toast;
import com.devlin_n.floatWindowPermission.FloatWindowManager;
-import com.devlin_n.yinyangplayer.controller.StandardVideoController;
-import com.devlin_n.yinyangplayer.player.YinYangPlayer;
-import com.devlin_n.yinyangplayer.util.WindowUtil;
-import com.devlin_n.yyplayer.R;
-import com.devlin_n.yyplayer.widget.CenteredImageSpan;
+import com.devlin_n.videoplayer.controller.StandardVideoController;
+import com.devlin_n.videoplayer.player.IjkVideoView;
+import com.devlin_n.videoplayer.util.WindowUtil;
+import com.devlin_n.dcplayer.R;
+import com.devlin_n.dcplayer.widget.CenteredImageSpan;
import java.util.HashMap;
@@ -49,7 +49,7 @@ public class DanmakuActivity extends AppCompatActivity {
private DanmakuView mDanmakuView;
private DanmakuContext mContext;
private BaseDanmakuParser mParser;
- private YinYangPlayer yinYangPlayer;
+ private IjkVideoView ijkVideoView;
private static final String URL_VOD = "http://mov.bn.netease.com/open-movie/nos/flv/2017/01/03/SC8U8K7BC_hd.flv";
// private static final String URL_VOD = "http://uploads.cutv.com:8088/video/data/201703/10/encode_file/515b6a95601ba6b39620358f2677a17358c2472411d53.mp4";
@@ -62,10 +62,10 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
actionBar.setTitle("弹幕");
actionBar.setDisplayHomeAsUpEnabled(true);
}
- yinYangPlayer = (YinYangPlayer) findViewById(R.id.player);
+ ijkVideoView = (IjkVideoView) findViewById(R.id.player);
initDanMuView();
- yinYangPlayer
+ ijkVideoView
.autoRotate()
// .enableCache()
// .useSurfaceView()
@@ -88,26 +88,25 @@ public boolean onOptionsItemSelected(MenuItem item) {
@Override
protected void onPause() {
super.onPause();
- yinYangPlayer.pause();
+ ijkVideoView.pause();
}
@Override
protected void onResume() {
super.onResume();
-// yinYangPlayer.resume();
- yinYangPlayer.stopFloatWindow();
+ ijkVideoView.stopFloatWindow();
}
@Override
protected void onDestroy() {
super.onDestroy();
- yinYangPlayer.release();
+ ijkVideoView.release();
}
@Override
public void onBackPressed() {
- if (!yinYangPlayer.onBackPressed()) {
+ if (!ijkVideoView.onBackPressed()) {
super.onBackPressed();
}
}
@@ -116,7 +115,7 @@ public void onBackPressed() {
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == FloatWindowManager.PERMISSION_REQUEST_CODE) {
if (FloatWindowManager.getInstance().checkPermission(this)) {
- yinYangPlayer.startFloatWindow();
+ ijkVideoView.startFloatWindow();
} else {
Toast.makeText(DanmakuActivity.this, "权限授予失败,无法开启悬浮窗", Toast.LENGTH_SHORT).show();
}
diff --git a/app/src/main/java/com/devlin_n/yyplayer/activity/FullScreenActivity.java b/app/src/main/java/com/devlin_n/dcplayer/activity/FullScreenActivity.java
similarity index 69%
rename from app/src/main/java/com/devlin_n/yyplayer/activity/FullScreenActivity.java
rename to app/src/main/java/com/devlin_n/dcplayer/activity/FullScreenActivity.java
index 9387dfe4..8a440027 100644
--- a/app/src/main/java/com/devlin_n/yyplayer/activity/FullScreenActivity.java
+++ b/app/src/main/java/com/devlin_n/dcplayer/activity/FullScreenActivity.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yyplayer.activity;
+package com.devlin_n.dcplayer.activity;
import android.content.Intent;
import android.os.Bundle;
@@ -7,8 +7,8 @@
import android.widget.Toast;
import com.devlin_n.floatWindowPermission.FloatWindowManager;
-import com.devlin_n.yinyangplayer.controller.StandardVideoController;
-import com.devlin_n.yinyangplayer.player.YinYangPlayer;
+import com.devlin_n.videoplayer.controller.FullScreenController;
+import com.devlin_n.videoplayer.player.IjkVideoView;
/**
* 全屏播放
@@ -17,46 +17,46 @@
public class FullScreenActivity extends AppCompatActivity{
- private YinYangPlayer yinYangPlayer;
+ private IjkVideoView ijkVideoView;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- yinYangPlayer = new YinYangPlayer(this);
- setContentView(yinYangPlayer);
- yinYangPlayer
+ ijkVideoView = new IjkVideoView(this);
+ setContentView(ijkVideoView);
+ ijkVideoView
.autoRotate()
.alwaysFullScreen()
// .useAndroidMediaPlayer()
.setTitle("这是一个标题")
.setUrl("http://flv2.bn.netease.com/videolib3/1611/28/GbgsL3639/HD/movie_index.m3u8")
- .setVideoController(new StandardVideoController(this))
- .setScreenScale(YinYangPlayer.SCREEN_SCALE_16_9)
+ .setVideoController(new FullScreenController(this))
+ .setScreenScale(IjkVideoView.SCREEN_SCALE_16_9)
.start();
}
@Override
protected void onPause() {
super.onPause();
- yinYangPlayer.pause();
+ ijkVideoView.pause();
}
@Override
protected void onResume() {
super.onResume();
- yinYangPlayer.resume();
- yinYangPlayer.stopFloatWindow();
+ ijkVideoView.resume();
+ ijkVideoView.stopFloatWindow();
}
@Override
protected void onDestroy() {
super.onDestroy();
- yinYangPlayer.release();
+ ijkVideoView.release();
}
@Override
public void onBackPressed() {
- if (!yinYangPlayer.onBackPressed()){
+ if (!ijkVideoView.onBackPressed()){
super.onBackPressed();
}
}
@@ -65,7 +65,7 @@ public void onBackPressed() {
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == FloatWindowManager.PERMISSION_REQUEST_CODE) {
if (FloatWindowManager.getInstance().checkPermission(this)) {
- yinYangPlayer.startFloatWindow();
+ ijkVideoView.startFloatWindow();
} else {
Toast.makeText(FullScreenActivity.this, "权限授予失败,无法开启悬浮窗", Toast.LENGTH_SHORT).show();
}
diff --git a/app/src/main/java/com/devlin_n/yyplayer/activity/ListViewActivity.java b/app/src/main/java/com/devlin_n/dcplayer/activity/ListViewActivity.java
similarity index 91%
rename from app/src/main/java/com/devlin_n/yyplayer/activity/ListViewActivity.java
rename to app/src/main/java/com/devlin_n/dcplayer/activity/ListViewActivity.java
index 3bd3b3e5..f82fbd9b 100644
--- a/app/src/main/java/com/devlin_n/yyplayer/activity/ListViewActivity.java
+++ b/app/src/main/java/com/devlin_n/dcplayer/activity/ListViewActivity.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yyplayer.activity;
+package com.devlin_n.dcplayer.activity;
import android.content.Intent;
import android.os.Bundle;
@@ -12,11 +12,11 @@
import android.widget.Toast;
import com.devlin_n.floatWindowPermission.FloatWindowManager;
-import com.devlin_n.yinyangplayer.player.YinYangPlayer;
-import com.devlin_n.yinyangplayer.player.YinYangPlayerManager;
-import com.devlin_n.yyplayer.R;
-import com.devlin_n.yyplayer.adapter.VideoListViewAdapter;
-import com.devlin_n.yyplayer.bean.VideoBean;
+import com.devlin_n.videoplayer.player.IjkVideoView;
+import com.devlin_n.videoplayer.player.VideoViewManager;
+import com.devlin_n.dcplayer.R;
+import com.devlin_n.dcplayer.adapter.VideoListViewAdapter;
+import com.devlin_n.dcplayer.bean.VideoBean;
import java.util.ArrayList;
import java.util.List;
@@ -86,9 +86,9 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun
private void gcView(View gcView) {
if (gcView != null) {
- YinYangPlayer yinYangPlayer = (YinYangPlayer) gcView.findViewById(R.id.video_player);
- if (yinYangPlayer != null && !yinYangPlayer.isFullScreen()) {
- yinYangPlayer.release();
+ IjkVideoView ijkVideoView = (IjkVideoView) gcView.findViewById(R.id.video_player);
+ if (ijkVideoView != null && !ijkVideoView.isFullScreen()) {
+ ijkVideoView.release();
}
}
}
@@ -106,7 +106,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
@Override
protected void onPause() {
super.onPause();
- YinYangPlayer currentVideoPlayer = YinYangPlayerManager.instance().getCurrentVideoPlayer();
+ IjkVideoView currentVideoPlayer = VideoViewManager.instance().getCurrentVideoPlayer();
if (currentVideoPlayer != null) {
currentVideoPlayer.release();
}
@@ -114,7 +114,7 @@ protected void onPause() {
@Override
public void onBackPressed() {
- if (!YinYangPlayerManager.instance().onBackPressed()) {
+ if (!VideoViewManager.instance().onBackPressed()) {
super.onBackPressed();
}
}
@@ -123,7 +123,7 @@ public void onBackPressed() {
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == FloatWindowManager.PERMISSION_REQUEST_CODE) {
if (FloatWindowManager.getInstance().checkPermission(this)) {
- YinYangPlayerManager.instance().getCurrentVideoPlayer().startFloatWindow();
+ VideoViewManager.instance().getCurrentVideoPlayer().startFloatWindow();
} else {
Toast.makeText(this, "权限授予失败,无法开启悬浮窗", Toast.LENGTH_SHORT).show();
}
diff --git a/app/src/main/java/com/devlin_n/yyplayer/activity/LivePlayerActivity.java b/app/src/main/java/com/devlin_n/dcplayer/activity/LivePlayerActivity.java
similarity index 80%
rename from app/src/main/java/com/devlin_n/yyplayer/activity/LivePlayerActivity.java
rename to app/src/main/java/com/devlin_n/dcplayer/activity/LivePlayerActivity.java
index 343f8653..6b098692 100644
--- a/app/src/main/java/com/devlin_n/yyplayer/activity/LivePlayerActivity.java
+++ b/app/src/main/java/com/devlin_n/dcplayer/activity/LivePlayerActivity.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yyplayer.activity;
+package com.devlin_n.dcplayer.activity;
import android.content.Intent;
import android.os.Bundle;
@@ -10,9 +10,9 @@
import com.bumptech.glide.Glide;
import com.devlin_n.floatWindowPermission.FloatWindowManager;
-import com.devlin_n.yinyangplayer.controller.StandardVideoController;
-import com.devlin_n.yinyangplayer.player.YinYangPlayer;
-import com.devlin_n.yyplayer.R;
+import com.devlin_n.videoplayer.controller.StandardVideoController;
+import com.devlin_n.videoplayer.player.IjkVideoView;
+import com.devlin_n.dcplayer.R;
/**
* 直播播放
@@ -21,7 +21,7 @@
public class LivePlayerActivity extends AppCompatActivity {
- private YinYangPlayer yinYangPlayer;
+ private IjkVideoView ijkVideoView;
private static final String URL = "http://ivi.bupt.edu.cn/hls/hunanhd.m3u8";
@Override
@@ -33,9 +33,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
actionBar.setTitle("LIVE");
actionBar.setDisplayHomeAsUpEnabled(true);
}
- yinYangPlayer = (YinYangPlayer) findViewById(R.id.player);
+ ijkVideoView = (IjkVideoView) findViewById(R.id.player);
// int widthPixels = getResources().getDisplayMetrics().widthPixels;
-// yinYangPlayer.setLayoutParams(new LinearLayout.LayoutParams(widthPixels, widthPixels / 4 * 3));
+// ijkVideoView.setLayoutParams(new LinearLayout.LayoutParams(widthPixels, widthPixels / 4 * 3));
StandardVideoController controller = new StandardVideoController(this);
controller.setLive(true);
@@ -47,7 +47,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
.animate(R.anim.anim_alpha_in)
.placeholder(android.R.color.darker_gray)
.into(controller.getThumb());
- yinYangPlayer
+ ijkVideoView
.autoRotate()
// .useAndroidMediaPlayer()
.setUrl(URL)
@@ -67,26 +67,26 @@ public boolean onOptionsItemSelected(MenuItem item) {
@Override
protected void onPause() {
super.onPause();
- yinYangPlayer.pause();
+ ijkVideoView.pause();
}
@Override
protected void onResume() {
super.onResume();
- yinYangPlayer.resume();
- yinYangPlayer.stopFloatWindow();
+ ijkVideoView.resume();
+ ijkVideoView.stopFloatWindow();
}
@Override
protected void onDestroy() {
super.onDestroy();
- yinYangPlayer.release();
+ ijkVideoView.release();
}
@Override
public void onBackPressed() {
- if (!yinYangPlayer.onBackPressed()) {
+ if (!ijkVideoView.onBackPressed()) {
super.onBackPressed();
}
}
@@ -95,7 +95,7 @@ public void onBackPressed() {
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == FloatWindowManager.PERMISSION_REQUEST_CODE) {
if (FloatWindowManager.getInstance().checkPermission(this)) {
- yinYangPlayer.startFloatWindow();
+ ijkVideoView.startFloatWindow();
} else {
Toast.makeText(LivePlayerActivity.this, "权限授予失败,无法开启悬浮窗", Toast.LENGTH_SHORT).show();
}
diff --git a/app/src/main/java/com/devlin_n/yyplayer/activity/PlayerActivity.java b/app/src/main/java/com/devlin_n/dcplayer/activity/PlayerActivity.java
similarity index 80%
rename from app/src/main/java/com/devlin_n/yyplayer/activity/PlayerActivity.java
rename to app/src/main/java/com/devlin_n/dcplayer/activity/PlayerActivity.java
index 18f630a6..97f7a4e7 100644
--- a/app/src/main/java/com/devlin_n/yyplayer/activity/PlayerActivity.java
+++ b/app/src/main/java/com/devlin_n/dcplayer/activity/PlayerActivity.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yyplayer.activity;
+package com.devlin_n.dcplayer.activity;
import android.content.Intent;
import android.os.Bundle;
@@ -9,9 +9,9 @@
import android.widget.Toast;
import com.devlin_n.floatWindowPermission.FloatWindowManager;
-import com.devlin_n.yinyangplayer.controller.StandardVideoController;
-import com.devlin_n.yinyangplayer.player.YinYangPlayer;
-import com.devlin_n.yyplayer.R;
+import com.devlin_n.videoplayer.controller.StandardVideoController;
+import com.devlin_n.videoplayer.player.IjkVideoView;
+import com.devlin_n.dcplayer.R;
/**
* 播放其他链接
@@ -20,7 +20,7 @@
public class PlayerActivity extends AppCompatActivity {
- private YinYangPlayer yinYangPlayer;
+ private IjkVideoView ijkVideoView;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -31,7 +31,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
actionBar.setTitle("Player");
actionBar.setDisplayHomeAsUpEnabled(true);
}
- yinYangPlayer = (YinYangPlayer) findViewById(R.id.player);
+ ijkVideoView = (IjkVideoView) findViewById(R.id.player);
Intent intent = getIntent();
if (intent != null) {
@@ -40,7 +40,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
if (isLive) {
controller.setLive(true);
}
- yinYangPlayer
+ ijkVideoView
.autoRotate()
// .useAndroidMediaPlayer()
.setUrl(intent.getStringExtra("url"))
@@ -60,26 +60,25 @@ public boolean onOptionsItemSelected(MenuItem item) {
@Override
protected void onPause() {
super.onPause();
- yinYangPlayer.pause();
+ ijkVideoView.pause();
}
@Override
protected void onResume() {
super.onResume();
-// yinYangPlayer.resume();
- yinYangPlayer.stopFloatWindow();
+ ijkVideoView.stopFloatWindow();
}
@Override
protected void onDestroy() {
super.onDestroy();
- yinYangPlayer.release();
+ ijkVideoView.release();
}
@Override
public void onBackPressed() {
- if (!yinYangPlayer.onBackPressed()) {
+ if (!ijkVideoView.onBackPressed()) {
super.onBackPressed();
}
}
@@ -88,7 +87,7 @@ public void onBackPressed() {
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == FloatWindowManager.PERMISSION_REQUEST_CODE) {
if (FloatWindowManager.getInstance().checkPermission(this)) {
- yinYangPlayer.startFloatWindow();
+ ijkVideoView.startFloatWindow();
} else {
Toast.makeText(PlayerActivity.this, "权限授予失败,无法开启悬浮窗", Toast.LENGTH_SHORT).show();
}
diff --git a/app/src/main/java/com/devlin_n/yyplayer/activity/RecyclerViewActivity.java b/app/src/main/java/com/devlin_n/dcplayer/activity/RecyclerViewActivity.java
similarity index 88%
rename from app/src/main/java/com/devlin_n/yyplayer/activity/RecyclerViewActivity.java
rename to app/src/main/java/com/devlin_n/dcplayer/activity/RecyclerViewActivity.java
index 2d587cb3..7766f4cd 100644
--- a/app/src/main/java/com/devlin_n/yyplayer/activity/RecyclerViewActivity.java
+++ b/app/src/main/java/com/devlin_n/dcplayer/activity/RecyclerViewActivity.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yyplayer.activity;
+package com.devlin_n.dcplayer.activity;
import android.content.Intent;
import android.os.Bundle;
@@ -13,11 +13,11 @@
import android.widget.Toast;
import com.devlin_n.floatWindowPermission.FloatWindowManager;
-import com.devlin_n.yinyangplayer.player.YinYangPlayer;
-import com.devlin_n.yinyangplayer.player.YinYangPlayerManager;
-import com.devlin_n.yyplayer.R;
-import com.devlin_n.yyplayer.bean.VideoBean;
-import com.devlin_n.yyplayer.adapter.VideoRecyclerViewAdapter;
+import com.devlin_n.videoplayer.player.IjkVideoView;
+import com.devlin_n.videoplayer.player.VideoViewManager;
+import com.devlin_n.dcplayer.R;
+import com.devlin_n.dcplayer.bean.VideoBean;
+import com.devlin_n.dcplayer.adapter.VideoRecyclerViewAdapter;
import java.util.ArrayList;
import java.util.List;
@@ -60,12 +60,12 @@ public void onChildViewAttachedToWindow(View view) {
@Override
public void onChildViewDetachedFromWindow(View view) {
- YinYangPlayer yinYangPlayer = (YinYangPlayer) view.findViewById(R.id.video_player);
- if (yinYangPlayer != null && !yinYangPlayer.isFullScreen()) {
+ IjkVideoView ijkVideoView = (IjkVideoView) view.findViewById(R.id.video_player);
+ if (ijkVideoView != null && !ijkVideoView.isFullScreen()) {
Log.d("@@@@@@", "onChildViewDetachedFromWindow: called");
- int tag = (int) yinYangPlayer.getTag();
+ int tag = (int) ijkVideoView.getTag();
Log.d("@@@@@@", "onChildViewDetachedFromWindow: position: " + tag);
- yinYangPlayer.release();
+ ijkVideoView.release();
}
}
});
@@ -127,7 +127,7 @@ public List getVideoList() {
@Override
protected void onPause() {
super.onPause();
- YinYangPlayer currentVideoPlayer = YinYangPlayerManager.instance().getCurrentVideoPlayer();
+ IjkVideoView currentVideoPlayer = VideoViewManager.instance().getCurrentVideoPlayer();
if (currentVideoPlayer != null){
currentVideoPlayer.release();
}
@@ -135,7 +135,7 @@ protected void onPause() {
@Override
public void onBackPressed() {
- if (!YinYangPlayerManager.instance().onBackPressed()){
+ if (!VideoViewManager.instance().onBackPressed()){
super.onBackPressed();
}
}
@@ -144,7 +144,7 @@ public void onBackPressed() {
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == FloatWindowManager.PERMISSION_REQUEST_CODE) {
if (FloatWindowManager.getInstance().checkPermission(this)) {
- YinYangPlayerManager.instance().getCurrentVideoPlayer().startFloatWindow();
+ VideoViewManager.instance().getCurrentVideoPlayer().startFloatWindow();
} else {
Toast.makeText(this, "权限授予失败,无法开启悬浮窗", Toast.LENGTH_SHORT).show();
}
diff --git a/app/src/main/java/com/devlin_n/yyplayer/activity/VodPlayerActivity.java b/app/src/main/java/com/devlin_n/dcplayer/activity/VodPlayerActivity.java
similarity index 79%
rename from app/src/main/java/com/devlin_n/yyplayer/activity/VodPlayerActivity.java
rename to app/src/main/java/com/devlin_n/dcplayer/activity/VodPlayerActivity.java
index 0428b5b6..70ca70e4 100644
--- a/app/src/main/java/com/devlin_n/yyplayer/activity/VodPlayerActivity.java
+++ b/app/src/main/java/com/devlin_n/dcplayer/activity/VodPlayerActivity.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yyplayer.activity;
+package com.devlin_n.dcplayer.activity;
import android.content.Intent;
import android.os.Bundle;
@@ -9,11 +9,11 @@
import android.widget.Toast;
import com.devlin_n.floatWindowPermission.FloatWindowManager;
-import com.devlin_n.yinyangplayer.controller.AdController;
-import com.devlin_n.yinyangplayer.controller.StandardVideoController;
-import com.devlin_n.yinyangplayer.player.VideoModel;
-import com.devlin_n.yinyangplayer.player.YinYangPlayer;
-import com.devlin_n.yyplayer.R;
+import com.devlin_n.videoplayer.controller.AdController;
+import com.devlin_n.videoplayer.controller.StandardVideoController;
+import com.devlin_n.videoplayer.player.VideoModel;
+import com.devlin_n.videoplayer.player.IjkVideoView;
+import com.devlin_n.dcplayer.R;
import java.util.ArrayList;
import java.util.List;
@@ -25,7 +25,7 @@
public class VodPlayerActivity extends AppCompatActivity {
- private YinYangPlayer yinYangPlayer;
+ private IjkVideoView ijkVideoView;
// private static final String URL_VOD = "http://mov.bn.netease.com/open-movie/nos/flv/2017/01/03/SC8U8K7BC_hd.flv";
private static final String URL_VOD = "http://baobab.wdjcdn.com/14564977406580.mp4";
// private static final String URL_VOD = "http://uploads.cutv.com:8088/video/data/201703/10/encode_file/515b6a95601ba6b39620358f2677a17358c2472411d53.mp4";
@@ -40,15 +40,15 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
actionBar.setTitle("VOD");
actionBar.setDisplayHomeAsUpEnabled(true);
}
- yinYangPlayer = (YinYangPlayer) findViewById(R.id.player);
+ ijkVideoView = (IjkVideoView) findViewById(R.id.player);
// int widthPixels = getResources().getDisplayMetrics().widthPixels;
-// yinYangPlayer.setLayoutParams(new LinearLayout.LayoutParams(widthPixels, widthPixels / 16 * 9));
+// ijkVideoView.setLayoutParams(new LinearLayout.LayoutParams(widthPixels, widthPixels / 16 * 9));
List videos = new ArrayList<>();
videos.add(new VideoModel(URL_AD, "广告", new AdController(this)));
videos.add(new VideoModel(URL_VOD, "奥斯卡", new StandardVideoController(this)));
- yinYangPlayer
+ ijkVideoView
.autoRotate()
// .enableCache()
// .useSurfaceView()
@@ -70,26 +70,25 @@ public boolean onOptionsItemSelected(MenuItem item) {
@Override
protected void onPause() {
super.onPause();
- yinYangPlayer.pause();
+ ijkVideoView.pause();
}
@Override
protected void onResume() {
super.onResume();
-// yinYangPlayer.resume();
- yinYangPlayer.stopFloatWindow();
+ ijkVideoView.stopFloatWindow();
}
@Override
protected void onDestroy() {
super.onDestroy();
- yinYangPlayer.release();
+ ijkVideoView.release();
}
@Override
public void onBackPressed() {
- if (!yinYangPlayer.onBackPressed()) {
+ if (!ijkVideoView.onBackPressed()) {
super.onBackPressed();
}
}
@@ -98,7 +97,7 @@ public void onBackPressed() {
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == FloatWindowManager.PERMISSION_REQUEST_CODE) {
if (FloatWindowManager.getInstance().checkPermission(this)) {
- yinYangPlayer.startFloatWindow();
+ ijkVideoView.startFloatWindow();
} else {
Toast.makeText(VodPlayerActivity.this, "权限授予失败,无法开启悬浮窗", Toast.LENGTH_SHORT).show();
}
diff --git a/app/src/main/java/com/devlin_n/yyplayer/adapter/VideoListViewAdapter.java b/app/src/main/java/com/devlin_n/dcplayer/adapter/VideoListViewAdapter.java
similarity index 83%
rename from app/src/main/java/com/devlin_n/yyplayer/adapter/VideoListViewAdapter.java
rename to app/src/main/java/com/devlin_n/dcplayer/adapter/VideoListViewAdapter.java
index 4164e7f9..d862d8e4 100644
--- a/app/src/main/java/com/devlin_n/yyplayer/adapter/VideoListViewAdapter.java
+++ b/app/src/main/java/com/devlin_n/dcplayer/adapter/VideoListViewAdapter.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yyplayer.adapter;
+package com.devlin_n.dcplayer.adapter;
import android.content.Context;
import android.view.LayoutInflater;
@@ -7,10 +7,10 @@
import android.widget.BaseAdapter;
import com.bumptech.glide.Glide;
-import com.devlin_n.yinyangplayer.controller.StandardVideoController;
-import com.devlin_n.yinyangplayer.player.YinYangPlayer;
-import com.devlin_n.yyplayer.R;
-import com.devlin_n.yyplayer.bean.VideoBean;
+import com.devlin_n.videoplayer.controller.StandardVideoController;
+import com.devlin_n.videoplayer.player.IjkVideoView;
+import com.devlin_n.dcplayer.R;
+import com.devlin_n.dcplayer.bean.VideoBean;
import java.util.ArrayList;
import java.util.List;
@@ -52,7 +52,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
viewHolder = (ViewHolder) convertView.getTag();
}
- viewHolder.yinYangPlayer
+ viewHolder.ijkVideoView
.enableCache()
.autoRotate()
// .useAndroidMediaPlayer()
@@ -71,11 +71,11 @@ public View getView(int position, View convertView, ViewGroup parent) {
private class ViewHolder {
- private YinYangPlayer yinYangPlayer;
+ private IjkVideoView ijkVideoView;
private StandardVideoController controller;
ViewHolder(View itemView) {
- this.yinYangPlayer = (YinYangPlayer) itemView.findViewById(R.id.video_player);
+ this.ijkVideoView = (IjkVideoView) itemView.findViewById(R.id.video_player);
controller = new StandardVideoController(context);
}
}
diff --git a/app/src/main/java/com/devlin_n/yyplayer/adapter/VideoRecyclerViewAdapter.java b/app/src/main/java/com/devlin_n/dcplayer/adapter/VideoRecyclerViewAdapter.java
similarity index 76%
rename from app/src/main/java/com/devlin_n/yyplayer/adapter/VideoRecyclerViewAdapter.java
rename to app/src/main/java/com/devlin_n/dcplayer/adapter/VideoRecyclerViewAdapter.java
index ffecdaa7..966b27f2 100644
--- a/app/src/main/java/com/devlin_n/yyplayer/adapter/VideoRecyclerViewAdapter.java
+++ b/app/src/main/java/com/devlin_n/dcplayer/adapter/VideoRecyclerViewAdapter.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yyplayer.adapter;
+package com.devlin_n.dcplayer.adapter;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
@@ -8,10 +8,10 @@
import android.widget.LinearLayout;
import com.bumptech.glide.Glide;
-import com.devlin_n.yinyangplayer.controller.StandardVideoController;
-import com.devlin_n.yinyangplayer.player.YinYangPlayer;
-import com.devlin_n.yyplayer.R;
-import com.devlin_n.yyplayer.bean.VideoBean;
+import com.devlin_n.videoplayer.controller.StandardVideoController;
+import com.devlin_n.videoplayer.player.IjkVideoView;
+import com.devlin_n.dcplayer.R;
+import com.devlin_n.dcplayer.bean.VideoBean;
import java.util.List;
@@ -42,7 +42,7 @@ public void onBindViewHolder(final VideoHolder holder, int position) {
.crossFade()
.placeholder(android.R.color.darker_gray)
.into(holder.controller.getThumb());
- holder.yinYangPlayer
+ holder.ijkVideoView
.enableCache()
.autoRotate()
// .useAndroidMediaPlayer()
@@ -50,7 +50,7 @@ public void onBindViewHolder(final VideoHolder holder, int position) {
.setUrl(videoBean.getUrl())
.setTitle(videoBean.getTitle())
.setVideoController(holder.controller);
- holder.yinYangPlayer.setTag(position);
+ holder.ijkVideoView.setTag(position);
}
@@ -61,16 +61,16 @@ public int getItemCount() {
class VideoHolder extends RecyclerView.ViewHolder {
- private YinYangPlayer yinYangPlayer;
+ private IjkVideoView ijkVideoView;
private StandardVideoController controller;
VideoHolder(View itemView) {
super(itemView);
- yinYangPlayer = (YinYangPlayer) itemView.findViewById(R.id.video_player);
+ ijkVideoView = (IjkVideoView) itemView.findViewById(R.id.video_player);
int widthPixels = context.getResources().getDisplayMetrics().widthPixels;
- yinYangPlayer.setLayoutParams(new LinearLayout.LayoutParams(widthPixels, widthPixels / 16 * 9));
+ ijkVideoView.setLayoutParams(new LinearLayout.LayoutParams(widthPixels, widthPixels / 16 * 9));
controller = new StandardVideoController(context);
- yinYangPlayer.setVideoController(controller);
+ ijkVideoView.setVideoController(controller);
}
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/devlin_n/yyplayer/app/MyApplication.java b/app/src/main/java/com/devlin_n/dcplayer/app/MyApplication.java
similarity index 91%
rename from app/src/main/java/com/devlin_n/yyplayer/app/MyApplication.java
rename to app/src/main/java/com/devlin_n/dcplayer/app/MyApplication.java
index 0e4ab3ea..cdbb7441 100644
--- a/app/src/main/java/com/devlin_n/yyplayer/app/MyApplication.java
+++ b/app/src/main/java/com/devlin_n/dcplayer/app/MyApplication.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yyplayer.app;
+package com.devlin_n.dcplayer.app;
import android.app.Application;
diff --git a/app/src/main/java/com/devlin_n/yyplayer/bean/VideoBean.java b/app/src/main/java/com/devlin_n/dcplayer/bean/VideoBean.java
similarity index 95%
rename from app/src/main/java/com/devlin_n/yyplayer/bean/VideoBean.java
rename to app/src/main/java/com/devlin_n/dcplayer/bean/VideoBean.java
index 0e2581cc..3921a9b2 100644
--- a/app/src/main/java/com/devlin_n/yyplayer/bean/VideoBean.java
+++ b/app/src/main/java/com/devlin_n/dcplayer/bean/VideoBean.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yyplayer.bean;
+package com.devlin_n.dcplayer.bean;
/**
* Created by Devlin_n on 2017/6/1.
diff --git a/app/src/main/java/com/devlin_n/yyplayer/widget/CenteredImageSpan.java b/app/src/main/java/com/devlin_n/dcplayer/widget/CenteredImageSpan.java
similarity index 97%
rename from app/src/main/java/com/devlin_n/yyplayer/widget/CenteredImageSpan.java
rename to app/src/main/java/com/devlin_n/dcplayer/widget/CenteredImageSpan.java
index 3ded795d..74b70251 100644
--- a/app/src/main/java/com/devlin_n/yyplayer/widget/CenteredImageSpan.java
+++ b/app/src/main/java/com/devlin_n/dcplayer/widget/CenteredImageSpan.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yyplayer.widget;
+package com.devlin_n.dcplayer.widget;
import android.graphics.Canvas;
import android.graphics.Paint;
diff --git a/app/src/main/res/layout/activity_danmaku_player.xml b/app/src/main/res/layout/activity_danmaku_player.xml
index 64617ada..ffc0dbd3 100644
--- a/app/src/main/res/layout/activity_danmaku_player.xml
+++ b/app/src/main/res/layout/activity_danmaku_player.xml
@@ -4,7 +4,7 @@
android:layout_height="match_parent"
android:orientation="vertical">
-
diff --git a/app/src/main/res/layout/activity_live_player.xml b/app/src/main/res/layout/activity_live_player.xml
index e3cccd1e..02134ec0 100644
--- a/app/src/main/res/layout/activity_live_player.xml
+++ b/app/src/main/res/layout/activity_live_player.xml
@@ -4,7 +4,7 @@
android:layout_height="match_parent"
android:orientation="vertical">
-
diff --git a/app/src/main/res/layout/activity_vod_player.xml b/app/src/main/res/layout/activity_vod_player.xml
index 8d0538d9..3b5573c0 100644
--- a/app/src/main/res/layout/activity_vod_player.xml
+++ b/app/src/main/res/layout/activity_vod_player.xml
@@ -4,7 +4,7 @@
android:layout_height="match_parent"
android:orientation="vertical">
-
diff --git a/app/src/main/res/layout/item_video.xml b/app/src/main/res/layout/item_video.xml
index d2333fbe..a38924b4 100644
--- a/app/src/main/res/layout/item_video.xml
+++ b/app/src/main/res/layout/item_video.xml
@@ -4,7 +4,7 @@
android:layout_height="wrap_content"
android:orientation="vertical">
-
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
index fb0a979c..2da77eb8 100644
Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
new file mode 100644
index 00000000..2f0371e7
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
index 82bb25ee..20b76419 100644
Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
new file mode 100644
index 00000000..dfcc69d0
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
index e7c3fd6a..6278da2e 100644
Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
new file mode 100644
index 00000000..bd7d18ba
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
index 41b3cf76..6af20ec8 100644
Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
new file mode 100644
index 00000000..049cc951
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
index ea40d32f..a27e46e1 100644
Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
new file mode 100644
index 00000000..439f2f76
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 9fe91a44..65feee2f 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1,3 +1,3 @@
- 阴阳播放器
+ DC播放器
diff --git a/library/build.gradle b/library/build.gradle
index de83b421..510140b3 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -9,8 +9,8 @@ android {
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
- versionCode 6
- versionName "1.1"
+ versionCode 7
+ versionName "1.3"
}
sourceSets {
diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml
index a165abf6..3c40ece7 100644
--- a/library/src/main/AndroidManifest.xml
+++ b/library/src/main/AndroidManifest.xml
@@ -1,6 +1,6 @@
+ package="com.devlin_n.videoplayer">
@@ -9,7 +9,7 @@
-
+
diff --git a/library/src/main/java/com/devlin_n/yinyangplayer/controller/AdController.java b/library/src/main/java/com/devlin_n/videoplayer/controller/AdController.java
similarity index 87%
rename from library/src/main/java/com/devlin_n/yinyangplayer/controller/AdController.java
rename to library/src/main/java/com/devlin_n/videoplayer/controller/AdController.java
index 8f38d72c..07e3210a 100644
--- a/library/src/main/java/com/devlin_n/yinyangplayer/controller/AdController.java
+++ b/library/src/main/java/com/devlin_n/videoplayer/controller/AdController.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yinyangplayer.controller;
+package com.devlin_n.videoplayer.controller;
import android.content.Context;
import android.support.annotation.NonNull;
@@ -8,10 +8,9 @@
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
-import android.widget.Toast;
-import com.devlin_n.yinyangplayer.R;
-import com.devlin_n.yinyangplayer.player.YinYangPlayer;
+import com.devlin_n.videoplayer.R;
+import com.devlin_n.videoplayer.player.IjkVideoView;
/**
* 广告控制器
@@ -63,7 +62,7 @@ public void onClick(View v) {
} else if (id == R.id.iv_volume) {
doMute();
} else if (id == R.id.ad_detail) {
- Toast.makeText(getContext(), "施工中~", Toast.LENGTH_SHORT).show();
+ if (listener != null) listener.onAdClick();
} else if (id == R.id.ad_time) {
mediaPlayer.skipToNext();
} else if (id == R.id.iv_play) {
@@ -84,11 +83,11 @@ private void doMute() {
public void setPlayState(int playState) {
super.setPlayState(playState);
switch (playState) {
- case YinYangPlayer.STATE_PLAYING:
+ case IjkVideoView.STATE_PLAYING:
post(mShowProgress);
playButton.setSelected(true);
break;
- case YinYangPlayer.STATE_PAUSED:
+ case IjkVideoView.STATE_PAUSED:
playButton.setSelected(false);
break;
}
@@ -98,10 +97,10 @@ public void setPlayState(int playState) {
public void setPlayerState(int playerState) {
super.setPlayerState(playerState);
switch (playerState) {
- case YinYangPlayer.PLAYER_NORMAL:
+ case IjkVideoView.PLAYER_NORMAL:
back.setVisibility(GONE);
break;
- case YinYangPlayer.PLAYER_FULL_SCREEN:
+ case IjkVideoView.PLAYER_FULL_SCREEN:
back.setVisibility(VISIBLE);
break;
}
@@ -125,7 +124,7 @@ protected int setProgress() {
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
- Toast.makeText(getContext(), "施工中~", Toast.LENGTH_SHORT).show();
+ if (listener != null) listener.onAdClick();
break;
}
return false;
diff --git a/library/src/main/java/com/devlin_n/yinyangplayer/controller/BaseVideoController.java b/library/src/main/java/com/devlin_n/videoplayer/controller/BaseVideoController.java
similarity index 96%
rename from library/src/main/java/com/devlin_n/yinyangplayer/controller/BaseVideoController.java
rename to library/src/main/java/com/devlin_n/videoplayer/controller/BaseVideoController.java
index c7dc7816..53ad7aba 100644
--- a/library/src/main/java/com/devlin_n/yinyangplayer/controller/BaseVideoController.java
+++ b/library/src/main/java/com/devlin_n/videoplayer/controller/BaseVideoController.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yinyangplayer.controller;
+package com.devlin_n.videoplayer.controller;
import android.content.Context;
import android.content.pm.ActivityInfo;
@@ -16,10 +16,11 @@
import android.view.WindowManager;
import android.widget.FrameLayout;
-import com.devlin_n.yinyangplayer.R;
-import com.devlin_n.yinyangplayer.util.Constants;
-import com.devlin_n.yinyangplayer.util.WindowUtil;
-import com.devlin_n.yinyangplayer.widget.CenterView;
+import com.devlin_n.videoplayer.R;
+import com.devlin_n.videoplayer.listener.ControllerListener;
+import com.devlin_n.videoplayer.util.Constants;
+import com.devlin_n.videoplayer.util.WindowUtil;
+import com.devlin_n.videoplayer.widget.CenterView;
import java.util.Formatter;
import java.util.Locale;
@@ -44,6 +45,7 @@ public abstract class BaseVideoController extends FrameLayout {
protected boolean gestureEnabled;
private float downX;
private float downY;
+ protected ControllerListener listener;
public BaseVideoController(@NonNull Context context) {
@@ -102,8 +104,8 @@ public void setPlayState(int playState) {
public void setPlayerState(int playerState) {
}
- public void startFullScreenDirectly() {
-
+ public void setControllerListener(ControllerListener listener) {
+ this.listener = listener;
}
protected void doPauseResume() {
diff --git a/library/src/main/java/com/devlin_n/yinyangplayer/controller/FloatController.java b/library/src/main/java/com/devlin_n/videoplayer/controller/FloatController.java
similarity index 82%
rename from library/src/main/java/com/devlin_n/yinyangplayer/controller/FloatController.java
rename to library/src/main/java/com/devlin_n/videoplayer/controller/FloatController.java
index 8fef7ca8..df5507f8 100644
--- a/library/src/main/java/com/devlin_n/yinyangplayer/controller/FloatController.java
+++ b/library/src/main/java/com/devlin_n/videoplayer/controller/FloatController.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yinyangplayer.controller;
+package com.devlin_n.videoplayer.controller;
import android.content.Context;
import android.support.annotation.NonNull;
@@ -6,9 +6,9 @@
import android.util.AttributeSet;
import android.view.View;
-import com.devlin_n.yinyangplayer.R;
-import com.devlin_n.yinyangplayer.player.YinYangPlayer;
-import com.devlin_n.yinyangplayer.widget.PlayProgressButton;
+import com.devlin_n.videoplayer.R;
+import com.devlin_n.videoplayer.player.IjkVideoView;
+import com.devlin_n.videoplayer.widget.PlayProgressButton;
/**
* 悬浮播放控制器
@@ -59,33 +59,33 @@ public void onClick(View v) {
public void setPlayState(int playState) {
super.setPlayState(playState);
switch (playState) {
- case YinYangPlayer.STATE_IDLE:
+ case IjkVideoView.STATE_IDLE:
break;
- case YinYangPlayer.STATE_PLAYING:
+ case IjkVideoView.STATE_PLAYING:
playProgressButton.setState(PlayProgressButton.STATE_PLAYING);
hide();
break;
- case YinYangPlayer.STATE_PAUSED:
+ case IjkVideoView.STATE_PAUSED:
playProgressButton.setState(PlayProgressButton.STATE_PAUSE);
show(0);
break;
- case YinYangPlayer.STATE_PREPARING:
+ case IjkVideoView.STATE_PREPARING:
playProgressButton.setState(PlayProgressButton.STATE_LOADING);
break;
- case YinYangPlayer.STATE_PREPARED:
+ case IjkVideoView.STATE_PREPARED:
playProgressButton.setVisibility(GONE);
break;
- case YinYangPlayer.STATE_ERROR:
+ case IjkVideoView.STATE_ERROR:
break;
- case YinYangPlayer.STATE_BUFFERING:
+ case IjkVideoView.STATE_BUFFERING:
playProgressButton.setState(PlayProgressButton.STATE_LOADING);
playProgressButton.setVisibility(VISIBLE);
break;
- case YinYangPlayer.STATE_BUFFERED:
+ case IjkVideoView.STATE_BUFFERED:
playProgressButton.setState(PlayProgressButton.STATE_LOADING_END);
if (!mShowing) playProgressButton.setVisibility(GONE);
break;
- case YinYangPlayer.STATE_PLAYBACK_COMPLETED:
+ case IjkVideoView.STATE_PLAYBACK_COMPLETED:
playProgressButton.setState(PlayProgressButton.STATE_PAUSE);
show(0);
break;
diff --git a/library/src/main/java/com/devlin_n/videoplayer/controller/FullScreenController.java b/library/src/main/java/com/devlin_n/videoplayer/controller/FullScreenController.java
new file mode 100644
index 00000000..d083edbc
--- /dev/null
+++ b/library/src/main/java/com/devlin_n/videoplayer/controller/FullScreenController.java
@@ -0,0 +1,360 @@
+package com.devlin_n.videoplayer.controller;
+
+import android.content.Context;
+import android.support.annotation.AttrRes;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.v7.widget.PopupMenu;
+import android.util.AttributeSet;
+import android.view.Gravity;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.ProgressBar;
+import android.widget.SeekBar;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.devlin_n.videoplayer.R;
+import com.devlin_n.videoplayer.player.IjkVideoView;
+import com.devlin_n.videoplayer.util.L;
+import com.devlin_n.videoplayer.util.WindowUtil;
+
+/**
+ * 全屏控制器
+ * Created by Devlin_n on 2017/4/7.
+ */
+
+public class FullScreenController extends BaseVideoController implements View.OnClickListener, SeekBar.OnSeekBarChangeListener {
+ protected TextView totalTime, currTime;
+ protected LinearLayout bottomContainer, topContainer;
+ protected SeekBar videoProgress;
+ protected ImageView moreMenu;
+ protected ImageView backButton;
+ protected ImageView lock;
+ protected TextView title;
+ private boolean isLive;
+ private boolean isDragging;
+
+ private ProgressBar bottomProgress;
+ private ImageView playButton;
+ private ProgressBar loadingProgress;
+ private LinearLayout completeContainer;
+ private Animation showAnim = AnimationUtils.loadAnimation(getContext(), R.anim.anim_alpha_in);
+ private Animation hideAnim = AnimationUtils.loadAnimation(getContext(), R.anim.anim_alpha_out);
+ private PopupMenu popupMenu;
+
+
+ public FullScreenController(@NonNull Context context) {
+ this(context, null);
+ }
+
+ public FullScreenController(@NonNull Context context, @Nullable AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public FullScreenController(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.layout_fullscreen_controller;
+ }
+
+ @Override
+ protected void initView() {
+ super.initView();
+ moreMenu = (ImageView) controllerView.findViewById(R.id.more_menu);
+ moreMenu.setOnClickListener(this);
+ bottomContainer = (LinearLayout) controllerView.findViewById(R.id.bottom_container);
+ topContainer = (LinearLayout) controllerView.findViewById(R.id.top_container);
+ videoProgress = (SeekBar) controllerView.findViewById(R.id.seekBar);
+ videoProgress.setOnSeekBarChangeListener(this);
+ totalTime = (TextView) controllerView.findViewById(R.id.total_time);
+ currTime = (TextView) controllerView.findViewById(R.id.curr_time);
+ backButton = (ImageView) controllerView.findViewById(R.id.back);
+ backButton.setOnClickListener(this);
+ lock = (ImageView) controllerView.findViewById(R.id.lock);
+ lock.setOnClickListener(this);
+ playButton = (ImageView) controllerView.findViewById(R.id.iv_play);
+ playButton.setOnClickListener(this);
+ loadingProgress = (ProgressBar) controllerView.findViewById(R.id.loading);
+ bottomProgress = (ProgressBar) controllerView.findViewById(R.id.bottom_progress);
+ ImageView rePlayButton = (ImageView) controllerView.findViewById(R.id.iv_replay);
+ rePlayButton.setOnClickListener(this);
+ completeContainer = (LinearLayout) controllerView.findViewById(R.id.complete_container);
+ completeContainer.setOnClickListener(this);
+ title = (TextView) controllerView.findViewById(R.id.title);
+ popupMenu = new PopupMenu(getContext(), moreMenu, Gravity.END);
+ popupMenu.getMenuInflater().inflate(R.menu.controller_menu, popupMenu.getMenu());
+ popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ int itemId = item.getItemId();
+ if (itemId == R.id.float_window) {
+ mediaPlayer.startFloatWindow();
+ } else if (itemId == R.id.scale_default) {
+ mediaPlayer.setScreenScale(IjkVideoView.SCREEN_SCALE_DEFAULT);
+ } else if (itemId == R.id.scale_original) {
+ mediaPlayer.setScreenScale(IjkVideoView.SCREEN_SCALE_ORIGINAL);
+ } else if (itemId == R.id.scale_match) {
+ mediaPlayer.setScreenScale(IjkVideoView.SCREEN_SCALE_MATCH_PARENT);
+ } else if (itemId == R.id.scale_16_9) {
+ mediaPlayer.setScreenScale(IjkVideoView.SCREEN_SCALE_16_9);
+ } else if (itemId == R.id.scale_4_3) {
+ mediaPlayer.setScreenScale(IjkVideoView.SCREEN_SCALE_4_3);
+ }
+ popupMenu.dismiss();
+ return false;
+ }
+ });
+ }
+
+ @Override
+ public void onClick(View v) {
+ int i = v.getId();
+ if (i == R.id.lock) {
+ doLockUnlock();
+ } else if (i == R.id.iv_play || i == R.id.iv_replay) {
+ doPauseResume();
+ } else if (i == R.id.more_menu) {
+ popupMenu.show();
+ show();
+ } else if (i == R.id.back) {
+ WindowUtil.scanForActivity(getContext()).finish();
+ }
+ }
+
+ public void showTitle() {
+ title.setVisibility(VISIBLE);
+ }
+
+
+ @Override
+ public void setPlayState(int playState) {
+ super.setPlayState(playState);
+ switch (playState) {
+ case IjkVideoView.STATE_IDLE:
+ L.e("STATE_IDLE");
+ hide();
+ isLocked = false;
+ lock.setSelected(false);
+ mediaPlayer.setLock(false);
+ completeContainer.setVisibility(GONE);
+ bottomProgress.setVisibility(GONE);
+ loadingProgress.setVisibility(GONE);
+ break;
+ case IjkVideoView.STATE_PLAYING:
+ L.e("STATE_PLAYING");
+ post(mShowProgress);
+ playButton.setSelected(true);
+ completeContainer.setVisibility(GONE);
+ break;
+ case IjkVideoView.STATE_PAUSED:
+ L.e("STATE_PAUSED");
+ playButton.setSelected(false);
+ break;
+ case IjkVideoView.STATE_PREPARING:
+ L.e("STATE_PREPARING");
+ completeContainer.setVisibility(GONE);
+ loadingProgress.setVisibility(VISIBLE);
+ break;
+ case IjkVideoView.STATE_PREPARED:
+ L.e("STATE_PREPARED");
+ if (!isLive) bottomProgress.setVisibility(VISIBLE);
+ loadingProgress.setVisibility(GONE);
+ break;
+ case IjkVideoView.STATE_ERROR:
+ L.e("STATE_ERROR");
+ break;
+ case IjkVideoView.STATE_BUFFERING:
+ L.e("STATE_BUFFERING");
+ loadingProgress.setVisibility(VISIBLE);
+ break;
+ case IjkVideoView.STATE_BUFFERED:
+ loadingProgress.setVisibility(GONE);
+ L.e("STATE_BUFFERED");
+ break;
+ case IjkVideoView.STATE_PLAYBACK_COMPLETED:
+ L.e("STATE_PLAYBACK_COMPLETED");
+ hide();
+ completeContainer.setVisibility(VISIBLE);
+ bottomProgress.setProgress(0);
+ bottomProgress.setSecondaryProgress(0);
+ isLocked = false;
+ mediaPlayer.setLock(false);
+ break;
+ }
+ }
+
+ private void doLockUnlock() {
+ if (isLocked) {
+ isLocked = false;
+ mShowing = false;
+ gestureEnabled = true;
+ show();
+ lock.setSelected(false);
+ Toast.makeText(getContext(), R.string.unlocked, Toast.LENGTH_SHORT).show();
+ } else {
+ hide();
+ isLocked = true;
+ gestureEnabled = false;
+ lock.setSelected(true);
+ Toast.makeText(getContext(), R.string.locked, Toast.LENGTH_SHORT).show();
+ }
+ mediaPlayer.setLock(isLocked);
+ }
+
+ /**
+ * 设置是否为直播视频
+ */
+ public void setLive(boolean live) {
+ isLive = live;
+ bottomProgress.setVisibility(GONE);
+ videoProgress.setVisibility(INVISIBLE);
+ totalTime.setVisibility(INVISIBLE);
+// moreMenu.setVisibility(VISIBLE);
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ isDragging = true;
+ removeCallbacks(mShowProgress);
+ removeCallbacks(mFadeOut);
+ }
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ long duration = mediaPlayer.getDuration();
+ long newPosition = (duration * seekBar.getProgress()) / videoProgress.getMax();
+ mediaPlayer.seekTo((int) newPosition);
+ isDragging = false;
+ post(mShowProgress);
+ show();
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ if (!fromUser) {
+ return;
+ }
+
+ long duration = mediaPlayer.getDuration();
+ long newPosition = (duration * progress) / videoProgress.getMax();
+ if (currTime != null)
+ currTime.setText(stringForTime((int) newPosition));
+ }
+
+ @Override
+ public void hide() {
+ if (mShowing) {
+ if (mediaPlayer.isFullScreen()) {
+ lock.setVisibility(GONE);
+ if (!isLocked) {
+ hideAllViews();
+ WindowUtil.hideStatusBar(getContext());
+ WindowUtil.hideNavKey(getContext());
+ }
+ } else {
+ hideAllViews();
+ }
+ if (!isLive && !isLocked) {
+ bottomProgress.setVisibility(VISIBLE);
+ bottomProgress.startAnimation(showAnim);
+ }
+ mShowing = false;
+ }
+ }
+
+ private void hideAllViews() {
+ topContainer.setVisibility(GONE);
+ topContainer.startAnimation(hideAnim);
+ bottomContainer.setVisibility(GONE);
+ bottomContainer.startAnimation(hideAnim);
+ }
+
+ private void show(int timeout) {
+ if (!mShowing) {
+ if (mediaPlayer.isFullScreen()) {
+ lock.setVisibility(VISIBLE);
+ if (!isLocked) {
+ showAllViews();
+ }
+ } else {
+ showAllViews();
+ }
+ if (!isLocked && !isLive) {
+ bottomProgress.setVisibility(GONE);
+ bottomProgress.startAnimation(hideAnim);
+ }
+ mShowing = true;
+ }
+ removeCallbacks(mFadeOut);
+ if (timeout != 0) {
+ postDelayed(mFadeOut, timeout);
+ }
+ }
+
+ private void showAllViews() {
+ bottomContainer.setVisibility(VISIBLE);
+ bottomContainer.startAnimation(showAnim);
+ topContainer.setVisibility(VISIBLE);
+ topContainer.startAnimation(showAnim);
+ WindowUtil.showStatusBar(getContext());
+ WindowUtil.showNavKey(getContext());
+ }
+
+ @Override
+ public void show() {
+ show(sDefaultTimeout);
+ }
+
+ @Override
+ protected int setProgress() {
+ if (mediaPlayer == null || isDragging) {
+ return 0;
+ }
+ int position = mediaPlayer.getCurrentPosition();
+ int duration = mediaPlayer.getDuration();
+ if (videoProgress != null) {
+ if (duration > 0) {
+ videoProgress.setEnabled(true);
+ int pos = (int) (position * 1.0 / duration * videoProgress.getMax());
+ videoProgress.setProgress(pos);
+ bottomProgress.setProgress(pos);
+ } else {
+ videoProgress.setEnabled(false);
+ }
+ int percent = mediaPlayer.getBufferPercentage();
+ if (percent >= 95) { //修复第二进度不能100%问题
+ videoProgress.setSecondaryProgress(videoProgress.getMax());
+ bottomProgress.setSecondaryProgress(bottomProgress.getMax());
+ } else {
+ videoProgress.setSecondaryProgress(percent * 10);
+ bottomProgress.setSecondaryProgress(percent * 10);
+ }
+ }
+
+ if (totalTime != null)
+ totalTime.setText(stringForTime(duration));
+ if (currTime != null)
+ currTime.setText(stringForTime(position));
+ if (title != null)
+ title.setText(mediaPlayer.getTitle());
+ return position;
+ }
+
+
+ @Override
+ protected void slideToChangePosition(float deltaX) {
+ if (isLive) {
+ mNeedSeek = false;
+ } else {
+ super.slideToChangePosition(deltaX);
+ }
+ }
+}
diff --git a/library/src/main/java/com/devlin_n/yinyangplayer/controller/StandardVideoController.java b/library/src/main/java/com/devlin_n/videoplayer/controller/StandardVideoController.java
similarity index 90%
rename from library/src/main/java/com/devlin_n/yinyangplayer/controller/StandardVideoController.java
rename to library/src/main/java/com/devlin_n/videoplayer/controller/StandardVideoController.java
index 85d24348..8a1218eb 100644
--- a/library/src/main/java/com/devlin_n/yinyangplayer/controller/StandardVideoController.java
+++ b/library/src/main/java/com/devlin_n/videoplayer/controller/StandardVideoController.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yinyangplayer.controller;
+package com.devlin_n.videoplayer.controller;
import android.content.Context;
import android.support.annotation.AttrRes;
@@ -20,11 +20,11 @@
import android.widget.TextView;
import android.widget.Toast;
-import com.devlin_n.yinyangplayer.R;
-import com.devlin_n.yinyangplayer.player.YinYangPlayer;
-import com.devlin_n.yinyangplayer.util.Constants;
-import com.devlin_n.yinyangplayer.util.L;
-import com.devlin_n.yinyangplayer.util.WindowUtil;
+import com.devlin_n.videoplayer.R;
+import com.devlin_n.videoplayer.player.IjkVideoView;
+import com.devlin_n.videoplayer.util.Constants;
+import com.devlin_n.videoplayer.util.L;
+import com.devlin_n.videoplayer.util.WindowUtil;
/**
* 直播/点播控制器
@@ -112,15 +112,15 @@ public boolean onMenuItemClick(MenuItem item) {
if (itemId == R.id.float_window) {
mediaPlayer.startFloatWindow();
} else if (itemId == R.id.scale_default) {
- mediaPlayer.setScreenScale(YinYangPlayer.SCREEN_SCALE_DEFAULT);
+ mediaPlayer.setScreenScale(IjkVideoView.SCREEN_SCALE_DEFAULT);
} else if (itemId == R.id.scale_original) {
- mediaPlayer.setScreenScale(YinYangPlayer.SCREEN_SCALE_ORIGINAL);
+ mediaPlayer.setScreenScale(IjkVideoView.SCREEN_SCALE_ORIGINAL);
} else if (itemId == R.id.scale_match) {
- mediaPlayer.setScreenScale(YinYangPlayer.SCREEN_SCALE_MATCH_PARENT);
+ mediaPlayer.setScreenScale(IjkVideoView.SCREEN_SCALE_MATCH_PARENT);
} else if (itemId == R.id.scale_16_9) {
- mediaPlayer.setScreenScale(YinYangPlayer.SCREEN_SCALE_16_9);
+ mediaPlayer.setScreenScale(IjkVideoView.SCREEN_SCALE_16_9);
} else if (itemId == R.id.scale_4_3) {
- mediaPlayer.setScreenScale(YinYangPlayer.SCREEN_SCALE_4_3);
+ mediaPlayer.setScreenScale(IjkVideoView.SCREEN_SCALE_4_3);
}
popupMenu.dismiss();
return false;
@@ -150,7 +150,7 @@ public void showTitle() {
@Override
public void setPlayerState(int playerState) {
switch (playerState) {
- case YinYangPlayer.PLAYER_NORMAL:
+ case IjkVideoView.PLAYER_NORMAL:
L.e("PLAYER_NORMAL");
if (isLocked) return;
setLayoutParams(new FrameLayout.LayoutParams(
@@ -163,7 +163,7 @@ public void setPlayerState(int playerState) {
statusHolder.setVisibility(GONE);
title.setVisibility(INVISIBLE);
break;
- case YinYangPlayer.PLAYER_FULL_SCREEN:
+ case IjkVideoView.PLAYER_FULL_SCREEN:
L.e("PLAYER_FULL_SCREEN");
if (isLocked) return;
postDelayed(new Runnable() {//解决ListView无效问题
@@ -194,7 +194,7 @@ public void run() {
public void setPlayState(int playState) {
super.setPlayState(playState);
switch (playState) {
- case YinYangPlayer.STATE_IDLE:
+ case IjkVideoView.STATE_IDLE:
L.e("STATE_IDLE");
hide();
isLocked = false;
@@ -206,41 +206,41 @@ public void setPlayState(int playState) {
startPlayButton.setVisibility(VISIBLE);
thumb.setVisibility(VISIBLE);
break;
- case YinYangPlayer.STATE_PLAYING:
+ case IjkVideoView.STATE_PLAYING:
L.e("STATE_PLAYING");
post(mShowProgress);
playButton.setSelected(true);
completeContainer.setVisibility(GONE);
thumb.setVisibility(GONE);
break;
- case YinYangPlayer.STATE_PAUSED:
+ case IjkVideoView.STATE_PAUSED:
L.e("STATE_PAUSED");
playButton.setSelected(false);
break;
- case YinYangPlayer.STATE_PREPARING:
+ case IjkVideoView.STATE_PREPARING:
L.e("STATE_PREPARING");
completeContainer.setVisibility(GONE);
startPlayButton.setVisibility(GONE);
loadingProgress.setVisibility(VISIBLE);
break;
- case YinYangPlayer.STATE_PREPARED:
+ case IjkVideoView.STATE_PREPARED:
L.e("STATE_PREPARED");
if (!isLive) bottomProgress.setVisibility(VISIBLE);
loadingProgress.setVisibility(GONE);
break;
- case YinYangPlayer.STATE_ERROR:
+ case IjkVideoView.STATE_ERROR:
L.e("STATE_ERROR");
break;
- case YinYangPlayer.STATE_BUFFERING:
+ case IjkVideoView.STATE_BUFFERING:
L.e("STATE_BUFFERING");
startPlayButton.setVisibility(GONE);
loadingProgress.setVisibility(VISIBLE);
break;
- case YinYangPlayer.STATE_BUFFERED:
+ case IjkVideoView.STATE_BUFFERED:
loadingProgress.setVisibility(GONE);
L.e("STATE_BUFFERED");
break;
- case YinYangPlayer.STATE_PLAYBACK_COMPLETED:
+ case IjkVideoView.STATE_PLAYBACK_COMPLETED:
L.e("STATE_PLAYBACK_COMPLETED");
hide();
thumb.setVisibility(VISIBLE);
@@ -271,19 +271,6 @@ private void doLockUnlock() {
mediaPlayer.setLock(isLocked);
}
- @Override
- public void startFullScreenDirectly() {
- fullScreenButton.setVisibility(GONE);
- backButton.setVisibility(VISIBLE);
- statusHolder.setVisibility(VISIBLE);
- backButton.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- WindowUtil.scanForActivity(getContext()).finish();
- }
- });
- }
-
/**
* 设置是否为直播视频
*/
diff --git a/library/src/main/java/com/devlin_n/videoplayer/listener/ControllerListener.java b/library/src/main/java/com/devlin_n/videoplayer/listener/ControllerListener.java
new file mode 100644
index 00000000..7b600857
--- /dev/null
+++ b/library/src/main/java/com/devlin_n/videoplayer/listener/ControllerListener.java
@@ -0,0 +1,10 @@
+package com.devlin_n.videoplayer.listener;
+
+/**
+ * Created by Devlin_n on 2017/6/26.
+ */
+
+public interface ControllerListener {
+
+ void onAdClick();
+}
diff --git a/library/src/main/java/com/devlin_n/videoplayer/listener/MyControllerListener.java b/library/src/main/java/com/devlin_n/videoplayer/listener/MyControllerListener.java
new file mode 100644
index 00000000..1f97f66f
--- /dev/null
+++ b/library/src/main/java/com/devlin_n/videoplayer/listener/MyControllerListener.java
@@ -0,0 +1,13 @@
+package com.devlin_n.videoplayer.listener;
+
+/**
+ * 实现接口,使用时只需重写需要的方法即可
+ * Created by Devlin_n on 2017/6/26.
+ */
+
+public class MyControllerListener implements ControllerListener {
+ @Override
+ public void onAdClick() {
+
+ }
+}
diff --git a/library/src/main/java/com/devlin_n/videoplayer/listener/MyVideoListener.java b/library/src/main/java/com/devlin_n/videoplayer/listener/MyVideoListener.java
new file mode 100644
index 00000000..dc105c7b
--- /dev/null
+++ b/library/src/main/java/com/devlin_n/videoplayer/listener/MyVideoListener.java
@@ -0,0 +1,28 @@
+package com.devlin_n.videoplayer.listener;
+
+/**
+ * 实现接口,使用时只需重写需要的方法即可
+ * Created by Devlin_n on 2017/6/22.
+ */
+
+public class MyVideoListener implements VideoListener{
+ @Override
+ public void onComplete() {
+
+ }
+
+ @Override
+ public void onPrepared() {
+
+ }
+
+ @Override
+ public void onError() {
+
+ }
+
+ @Override
+ public void onInfo(int what, int extra) {
+
+ }
+}
diff --git a/library/src/main/java/com/devlin_n/videoplayer/listener/VideoListener.java b/library/src/main/java/com/devlin_n/videoplayer/listener/VideoListener.java
new file mode 100644
index 00000000..8b8efdd3
--- /dev/null
+++ b/library/src/main/java/com/devlin_n/videoplayer/listener/VideoListener.java
@@ -0,0 +1,19 @@
+package com.devlin_n.videoplayer.listener;
+
+/**
+ * Created by Devlin_n on 2017/6/22.
+ */
+
+public interface VideoListener {
+
+ //播放完成
+ void onComplete();
+
+ //准备完成
+ void onPrepared();
+
+ void onError();
+
+ void onInfo(int what, int extra);
+
+}
diff --git a/library/src/main/java/com/devlin_n/yinyangplayer/player/BackgroundPlayService.java b/library/src/main/java/com/devlin_n/videoplayer/player/BackgroundPlayService.java
similarity index 88%
rename from library/src/main/java/com/devlin_n/yinyangplayer/player/BackgroundPlayService.java
rename to library/src/main/java/com/devlin_n/videoplayer/player/BackgroundPlayService.java
index f6ec844c..71b864e6 100644
--- a/library/src/main/java/com/devlin_n/yinyangplayer/player/BackgroundPlayService.java
+++ b/library/src/main/java/com/devlin_n/videoplayer/player/BackgroundPlayService.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yinyangplayer.player;
+package com.devlin_n.videoplayer.player;
import android.app.Service;
import android.content.Intent;
@@ -8,11 +8,11 @@
import android.view.Gravity;
import android.view.WindowManager;
-import com.devlin_n.yinyangplayer.controller.FloatController;
-import com.devlin_n.yinyangplayer.util.Constants;
-import com.devlin_n.yinyangplayer.util.KeyUtil;
-import com.devlin_n.yinyangplayer.util.WindowUtil;
-import com.devlin_n.yinyangplayer.widget.FloatView;
+import com.devlin_n.videoplayer.controller.FloatController;
+import com.devlin_n.videoplayer.util.Constants;
+import com.devlin_n.videoplayer.util.KeyUtil;
+import com.devlin_n.videoplayer.util.WindowUtil;
+import com.devlin_n.videoplayer.widget.FloatView;
/**
* 悬浮播放
@@ -22,7 +22,7 @@
public class BackgroundPlayService extends Service {
private WindowManager wm;
private WindowManager.LayoutParams wmParams;
- private YinYangPlayer videoView;
+ private IjkVideoView videoView;
private String url;
private FloatView floatView;
private int position;
diff --git a/library/src/main/java/com/devlin_n/yinyangplayer/player/YinYangPlayer.java b/library/src/main/java/com/devlin_n/videoplayer/player/IjkVideoView.java
similarity index 93%
rename from library/src/main/java/com/devlin_n/yinyangplayer/player/YinYangPlayer.java
rename to library/src/main/java/com/devlin_n/videoplayer/player/IjkVideoView.java
index 6428af91..d2a79ad5 100644
--- a/library/src/main/java/com/devlin_n/yinyangplayer/player/YinYangPlayer.java
+++ b/library/src/main/java/com/devlin_n/videoplayer/player/IjkVideoView.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yinyangplayer.player;
+package com.devlin_n.videoplayer.player;
import android.content.Context;
import android.content.Intent;
@@ -23,15 +23,16 @@
import com.danikula.videocache.CacheListener;
import com.danikula.videocache.HttpProxyCacheServer;
import com.devlin_n.floatWindowPermission.FloatWindowManager;
-import com.devlin_n.yinyangplayer.R;
-import com.devlin_n.yinyangplayer.controller.BaseVideoController;
-import com.devlin_n.yinyangplayer.util.Constants;
-import com.devlin_n.yinyangplayer.util.KeyUtil;
-import com.devlin_n.yinyangplayer.util.NetworkUtil;
-import com.devlin_n.yinyangplayer.util.WindowUtil;
-import com.devlin_n.yinyangplayer.widget.StatusView;
-import com.devlin_n.yinyangplayer.widget.YinYangSurfaceView;
-import com.devlin_n.yinyangplayer.widget.YinYangTextureView;
+import com.devlin_n.videoplayer.R;
+import com.devlin_n.videoplayer.controller.BaseVideoController;
+import com.devlin_n.videoplayer.listener.VideoListener;
+import com.devlin_n.videoplayer.util.Constants;
+import com.devlin_n.videoplayer.util.KeyUtil;
+import com.devlin_n.videoplayer.util.NetworkUtil;
+import com.devlin_n.videoplayer.util.WindowUtil;
+import com.devlin_n.videoplayer.widget.StatusView;
+import com.devlin_n.videoplayer.widget.ResizeSurfaceView;
+import com.devlin_n.videoplayer.widget.ResizeTextureView;
import java.io.File;
import java.io.IOException;
@@ -49,13 +50,14 @@
* Created by Devlin_n on 2017/4/7.
*/
-public class YinYangPlayer extends FrameLayout implements BaseVideoController.MediaPlayerControl {
+public class IjkVideoView extends FrameLayout implements BaseVideoController.MediaPlayerControl {
private IMediaPlayer mMediaPlayer;//ijkPlayer
@Nullable
private BaseVideoController mVideoController;//控制器
- private YinYangSurfaceView mSurfaceView;
- private YinYangTextureView mTextureView;
+ private VideoListener listener;
+ private ResizeSurfaceView mSurfaceView;
+ private ResizeTextureView mTextureView;
private SurfaceTexture mSurfaceTexture;
private DanmakuView mDanmakuView;
private DanmakuContext mContext;
@@ -113,12 +115,12 @@ public class YinYangPlayer extends FrameLayout implements BaseVideoController.Me
private boolean addToPlayerManager;
- public YinYangPlayer(@NonNull Context context) {
+ public IjkVideoView(@NonNull Context context) {
this(context, null);
}
- public YinYangPlayer(@NonNull Context context, @Nullable AttributeSet attrs) {
+ public IjkVideoView(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
initView();
}
@@ -214,7 +216,7 @@ private HttpProxyCacheServer getCacheServer() {
*/
private void addSurfaceView() {
playerContainer.removeView(mSurfaceView);
- mSurfaceView = new YinYangSurfaceView(getContext());
+ mSurfaceView = new ResizeSurfaceView(getContext());
SurfaceHolder surfaceHolder = mSurfaceView.getHolder();
surfaceHolder.addCallback(new SurfaceHolder.Callback() {
@Override
@@ -246,7 +248,7 @@ public void surfaceDestroyed(SurfaceHolder holder) {
private void addTextureView() {
playerContainer.removeView(mTextureView);
mSurfaceTexture = null;
- mTextureView = new YinYangTextureView(getContext());
+ mTextureView = new ResizeTextureView(getContext());
mTextureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width, int height) {
@@ -283,8 +285,8 @@ public void start() {
if (mCurrentState == STATE_IDLE) {
if (mAlwaysFullScreen) startFullScreenDirectly();
if (addToPlayerManager) {
- YinYangPlayerManager.instance().releaseVideoPlayer();
- YinYangPlayerManager.instance().setCurrentVideoPlayer(this);
+ VideoViewManager.instance().releaseVideoPlayer();
+ VideoViewManager.instance().setCurrentVideoPlayer(this);
}
if (mAutoRotate && orientationEventListener != null) orientationEventListener.enable();
if (checkNetwork()) return;
@@ -408,7 +410,7 @@ public void run() {
/**
* 添加弹幕
*/
- public YinYangPlayer addDanmukuView(DanmakuView danmakuView, DanmakuContext context, BaseDanmakuParser parser) {
+ public IjkVideoView addDanmukuView(DanmakuView danmakuView, DanmakuContext context, BaseDanmakuParser parser) {
this.mDanmakuView = danmakuView;
this.mContext = context;
this.mParser = parser;
@@ -418,7 +420,7 @@ public YinYangPlayer addDanmukuView(DanmakuView danmakuView, DanmakuContext cont
/**
* 启用{@link AndroidMediaPlayer},如不调用默认使用 {@link IjkMediaPlayer}
*/
- public YinYangPlayer useAndroidMediaPlayer() {
+ public IjkVideoView useAndroidMediaPlayer() {
this.useAndroidMediaPlayer = true;
return this;
}
@@ -427,7 +429,7 @@ public YinYangPlayer useAndroidMediaPlayer() {
* 设置视频比例
*/
@Override
- public YinYangPlayer setScreenScale(int screenScale) {
+ public IjkVideoView setScreenScale(int screenScale) {
this.mCurrentScreenScale = screenScale;
if (mSurfaceView != null) mSurfaceView.setScreenScale(screenScale);
if (mTextureView != null) mTextureView.setScreenScale(screenScale);
@@ -437,7 +439,7 @@ public YinYangPlayer setScreenScale(int screenScale) {
/**
* 设置视频地址
*/
- public YinYangPlayer setUrl(String url) {
+ public IjkVideoView setUrl(String url) {
this.mCurrentUrl = url;
return this;
}
@@ -445,7 +447,7 @@ public YinYangPlayer setUrl(String url) {
/**
* 一开始播放就seek到预先设置好的位置
*/
- public YinYangPlayer skipPositionWhenPlay(String url, int position) {
+ public IjkVideoView skipPositionWhenPlay(String url, int position) {
this.mCurrentUrl = url;
this.mCurrentPosition = position;
return this;
@@ -454,7 +456,7 @@ public YinYangPlayer skipPositionWhenPlay(String url, int position) {
/**
* 设置一个列表的视频
*/
- public YinYangPlayer setVideos(List videoModels) {
+ public IjkVideoView setVideos(List videoModels) {
this.mVideoModels = videoModels;
playNext();
return this;
@@ -463,7 +465,7 @@ public YinYangPlayer setVideos(List videoModels) {
/**
* 设置标题
*/
- public YinYangPlayer setTitle(String title) {
+ public IjkVideoView setTitle(String title) {
if (title != null) {
this.mCurrentTitle = title;
}
@@ -473,15 +475,15 @@ public YinYangPlayer setTitle(String title) {
/**
* 开启缓存
*/
- public YinYangPlayer enableCache() {
+ public IjkVideoView enableCache() {
isCache = true;
return this;
}
/**
- * 添加到{@link YinYangPlayerManager},如需集成到RecyclerView或ListView请开启此选项
+ * 添加到{@link VideoViewManager},如需集成到RecyclerView或ListView请开启此选项
*/
- public YinYangPlayer addToPlayerManager() {
+ public IjkVideoView addToPlayerManager() {
addToPlayerManager = true;
return this;
}
@@ -502,11 +504,15 @@ private void playNext() {
/**
* 启用SurfaceView
*/
- public YinYangPlayer useSurfaceView() {
+ public IjkVideoView useSurfaceView() {
this.useSurfaceView = true;
return this;
}
+ public void setVideoListener(VideoListener listener) {
+ this.listener = listener;
+ }
+
private boolean isInPlaybackState() {
return (mMediaPlayer != null && mCurrentState != STATE_ERROR
&& mCurrentState != STATE_IDLE && mCurrentState != STATE_PREPARING);
@@ -593,10 +599,9 @@ public void stopFloatWindow() {
public void startFullScreenDirectly() {
WindowUtil.scanForActivity(getContext()).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
startFullScreen();
- if (mVideoController != null) mVideoController.startFullScreenDirectly();
}
- public YinYangPlayer alwaysFullScreen() {
+ public IjkVideoView alwaysFullScreen() {
mAlwaysFullScreen = true;
return this;
}
@@ -685,7 +690,7 @@ public String getTitle() {
/**
* 设置控制器
*/
- public YinYangPlayer setVideoController(BaseVideoController mediaController) {
+ public IjkVideoView setVideoController(BaseVideoController mediaController) {
playerContainer.removeView(mVideoController);
if (mediaController != null) {
mediaController.setMediaPlayer(this);
@@ -702,6 +707,7 @@ public YinYangPlayer setVideoController(BaseVideoController mediaController) {
@Override
public boolean onError(IMediaPlayer iMediaPlayer, int framework_err, int impl_err) {
mCurrentState = STATE_ERROR;
+ if (listener != null) listener.onError();
if (mVideoController != null) mVideoController.setPlayState(mCurrentState);
mCurrentPosition = getCurrentPosition();
playerContainer.removeView(statusView);
@@ -726,6 +732,7 @@ public void onClick(View v) {
@Override
public void onCompletion(IMediaPlayer iMediaPlayer) {
mCurrentState = STATE_PLAYBACK_COMPLETED;
+ if (listener != null) listener.onComplete();
if (mVideoController != null) mVideoController.setPlayState(mCurrentState);
setKeepScreenOn(false);
mCurrentVideoPosition++;
@@ -758,6 +765,7 @@ private void resetPlayer() {
private IMediaPlayer.OnInfoListener onInfoListener = new IMediaPlayer.OnInfoListener() {
@Override
public boolean onInfo(IMediaPlayer iMediaPlayer, int what, int extra) {
+ if (listener != null) listener.onInfo(what, extra);
switch (what) {
case IMediaPlayer.MEDIA_INFO_BUFFERING_START:
mCurrentState = STATE_BUFFERING;
@@ -790,6 +798,7 @@ public void onBufferingUpdate(IMediaPlayer iMediaPlayer, int i) {
@Override
public void onPrepared(IMediaPlayer iMediaPlayer) {
mCurrentState = STATE_PREPARED;
+ if (listener != null) listener.onPrepared();
if (mVideoController != null) mVideoController.setPlayState(mCurrentState);
if (mCurrentPosition > 0) {
seekTo(mCurrentPosition);
@@ -927,7 +936,7 @@ boolean abandonFocus() {
/**
* 设置自动旋转
*/
- public YinYangPlayer autoRotate() {
+ public IjkVideoView autoRotate() {
this.mAutoRotate = true;
if (orientationEventListener == null) {
orientationEventListener = new OrientationEventListener(getContext()) { // 加速度传感器监听,用于自动旋转屏幕
diff --git a/library/src/main/java/com/devlin_n/yinyangplayer/player/VideoCacheManager.java b/library/src/main/java/com/devlin_n/videoplayer/player/VideoCacheManager.java
similarity index 94%
rename from library/src/main/java/com/devlin_n/yinyangplayer/player/VideoCacheManager.java
rename to library/src/main/java/com/devlin_n/videoplayer/player/VideoCacheManager.java
index 62d0fc26..d0a32286 100644
--- a/library/src/main/java/com/devlin_n/yinyangplayer/player/VideoCacheManager.java
+++ b/library/src/main/java/com/devlin_n/videoplayer/player/VideoCacheManager.java
@@ -1,10 +1,10 @@
-package com.devlin_n.yinyangplayer.player;
+package com.devlin_n.videoplayer.player;
import android.content.Context;
import com.danikula.videocache.HttpProxyCacheServer;
import com.danikula.videocache.file.Md5FileNameGenerator;
-import com.devlin_n.yinyangplayer.util.StorageUtil;
+import com.devlin_n.videoplayer.util.StorageUtil;
import java.io.File;
diff --git a/library/src/main/java/com/devlin_n/yinyangplayer/player/VideoModel.java b/library/src/main/java/com/devlin_n/videoplayer/player/VideoModel.java
similarity index 76%
rename from library/src/main/java/com/devlin_n/yinyangplayer/player/VideoModel.java
rename to library/src/main/java/com/devlin_n/videoplayer/player/VideoModel.java
index 3a8bf8dc..57d274d3 100644
--- a/library/src/main/java/com/devlin_n/yinyangplayer/player/VideoModel.java
+++ b/library/src/main/java/com/devlin_n/videoplayer/player/VideoModel.java
@@ -1,6 +1,6 @@
-package com.devlin_n.yinyangplayer.player;
+package com.devlin_n.videoplayer.player;
-import com.devlin_n.yinyangplayer.controller.BaseVideoController;
+import com.devlin_n.videoplayer.controller.BaseVideoController;
/**
* Created by Devlin_n on 2017/4/11.
diff --git a/library/src/main/java/com/devlin_n/yinyangplayer/player/YinYangPlayerManager.java b/library/src/main/java/com/devlin_n/videoplayer/player/VideoViewManager.java
similarity index 55%
rename from library/src/main/java/com/devlin_n/yinyangplayer/player/YinYangPlayerManager.java
rename to library/src/main/java/com/devlin_n/videoplayer/player/VideoViewManager.java
index 78f8d309..ae1540ef 100644
--- a/library/src/main/java/com/devlin_n/yinyangplayer/player/YinYangPlayerManager.java
+++ b/library/src/main/java/com/devlin_n/videoplayer/player/VideoViewManager.java
@@ -1,31 +1,31 @@
-package com.devlin_n.yinyangplayer.player;
+package com.devlin_n.videoplayer.player;
import java.lang.ref.WeakReference;
/**
* 视频播放器管理器.
*/
-public class YinYangPlayerManager {
+public class VideoViewManager {
- private WeakReference mPlayer; //写成弱引用防止内存泄露
+ private WeakReference mPlayer; //写成弱引用防止内存泄露
- private YinYangPlayerManager() {
+ private VideoViewManager() {
}
- private static YinYangPlayerManager sInstance;
+ private static VideoViewManager sInstance;
- public static synchronized YinYangPlayerManager instance() {
+ public static synchronized VideoViewManager instance() {
if (sInstance == null) {
- sInstance = new YinYangPlayerManager();
+ sInstance = new VideoViewManager();
}
return sInstance;
}
- public void setCurrentVideoPlayer(YinYangPlayer player) {
+ public void setCurrentVideoPlayer(IjkVideoView player) {
mPlayer = new WeakReference<>(player);
}
- public YinYangPlayer getCurrentVideoPlayer() {
+ public IjkVideoView getCurrentVideoPlayer() {
if (mPlayer == null) return null;
return mPlayer.get();
}
diff --git a/library/src/main/java/com/devlin_n/yinyangplayer/util/Constants.java b/library/src/main/java/com/devlin_n/videoplayer/util/Constants.java
similarity index 88%
rename from library/src/main/java/com/devlin_n/yinyangplayer/util/Constants.java
rename to library/src/main/java/com/devlin_n/videoplayer/util/Constants.java
index d4e2afca..292ed9ad 100644
--- a/library/src/main/java/com/devlin_n/yinyangplayer/util/Constants.java
+++ b/library/src/main/java/com/devlin_n/videoplayer/util/Constants.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yinyangplayer.util;
+package com.devlin_n.videoplayer.util;
/**
* 常量
diff --git a/library/src/main/java/com/devlin_n/yinyangplayer/util/KeyUtil.java b/library/src/main/java/com/devlin_n/videoplayer/util/KeyUtil.java
similarity index 85%
rename from library/src/main/java/com/devlin_n/yinyangplayer/util/KeyUtil.java
rename to library/src/main/java/com/devlin_n/videoplayer/util/KeyUtil.java
index 3db8aada..b1154d32 100644
--- a/library/src/main/java/com/devlin_n/yinyangplayer/util/KeyUtil.java
+++ b/library/src/main/java/com/devlin_n/videoplayer/util/KeyUtil.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yinyangplayer.util;
+package com.devlin_n.videoplayer.util;
/**
* Created by Devlin_n on 2017/4/14.
diff --git a/library/src/main/java/com/devlin_n/yinyangplayer/util/L.java b/library/src/main/java/com/devlin_n/videoplayer/util/L.java
similarity index 72%
rename from library/src/main/java/com/devlin_n/yinyangplayer/util/L.java
rename to library/src/main/java/com/devlin_n/videoplayer/util/L.java
index 747ea9ef..780d729d 100644
--- a/library/src/main/java/com/devlin_n/yinyangplayer/util/L.java
+++ b/library/src/main/java/com/devlin_n/videoplayer/util/L.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yinyangplayer.util;
+package com.devlin_n.videoplayer.util;
import android.util.Log;
@@ -9,7 +9,7 @@
public class L {
- private static final String TAG = "YinYangPlayer";
+ private static final String TAG = "DCPlayer";
public static void d(String msg) {
diff --git a/library/src/main/java/com/devlin_n/yinyangplayer/util/NetworkUtil.java b/library/src/main/java/com/devlin_n/videoplayer/util/NetworkUtil.java
similarity index 98%
rename from library/src/main/java/com/devlin_n/yinyangplayer/util/NetworkUtil.java
rename to library/src/main/java/com/devlin_n/videoplayer/util/NetworkUtil.java
index d3b8d007..12251952 100644
--- a/library/src/main/java/com/devlin_n/yinyangplayer/util/NetworkUtil.java
+++ b/library/src/main/java/com/devlin_n/videoplayer/util/NetworkUtil.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yinyangplayer.util;
+package com.devlin_n.videoplayer.util;
import android.content.Context;
import android.net.ConnectivityManager;
diff --git a/library/src/main/java/com/devlin_n/yinyangplayer/util/StorageUtil.java b/library/src/main/java/com/devlin_n/videoplayer/util/StorageUtil.java
similarity index 99%
rename from library/src/main/java/com/devlin_n/yinyangplayer/util/StorageUtil.java
rename to library/src/main/java/com/devlin_n/videoplayer/util/StorageUtil.java
index 5f9fac58..8bafb940 100644
--- a/library/src/main/java/com/devlin_n/yinyangplayer/util/StorageUtil.java
+++ b/library/src/main/java/com/devlin_n/videoplayer/util/StorageUtil.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yinyangplayer.util;
+package com.devlin_n.videoplayer.util;
import android.content.Context;
import android.os.Environment;
diff --git a/library/src/main/java/com/devlin_n/yinyangplayer/util/WindowUtil.java b/library/src/main/java/com/devlin_n/videoplayer/util/WindowUtil.java
similarity index 99%
rename from library/src/main/java/com/devlin_n/yinyangplayer/util/WindowUtil.java
rename to library/src/main/java/com/devlin_n/videoplayer/util/WindowUtil.java
index 2ee7789b..27bf0dd1 100644
--- a/library/src/main/java/com/devlin_n/yinyangplayer/util/WindowUtil.java
+++ b/library/src/main/java/com/devlin_n/videoplayer/util/WindowUtil.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yinyangplayer.util;
+package com.devlin_n.videoplayer.util;
import android.app.Activity;
import android.content.Context;
diff --git a/library/src/main/java/com/devlin_n/yinyangplayer/widget/CenterView.java b/library/src/main/java/com/devlin_n/videoplayer/widget/CenterView.java
similarity index 95%
rename from library/src/main/java/com/devlin_n/yinyangplayer/widget/CenterView.java
rename to library/src/main/java/com/devlin_n/videoplayer/widget/CenterView.java
index f8c30dcf..3cc6eb0c 100644
--- a/library/src/main/java/com/devlin_n/yinyangplayer/widget/CenterView.java
+++ b/library/src/main/java/com/devlin_n/videoplayer/widget/CenterView.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yinyangplayer.widget;
+package com.devlin_n.videoplayer.widget;
import android.content.Context;
import android.view.Gravity;
@@ -11,7 +11,7 @@
import android.widget.ProgressBar;
import android.widget.TextView;
-import com.devlin_n.yinyangplayer.R;
+import com.devlin_n.videoplayer.R;
/**
* 显示亮度,音量,进度
diff --git a/library/src/main/java/com/devlin_n/yinyangplayer/widget/FloatView.java b/library/src/main/java/com/devlin_n/videoplayer/widget/FloatView.java
similarity index 87%
rename from library/src/main/java/com/devlin_n/yinyangplayer/widget/FloatView.java
rename to library/src/main/java/com/devlin_n/videoplayer/widget/FloatView.java
index dde7a188..5cdd19e7 100644
--- a/library/src/main/java/com/devlin_n/yinyangplayer/widget/FloatView.java
+++ b/library/src/main/java/com/devlin_n/videoplayer/widget/FloatView.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yinyangplayer.widget;
+package com.devlin_n.videoplayer.widget;
import android.annotation.SuppressLint;
import android.content.Context;
@@ -7,9 +7,9 @@
import android.view.WindowManager;
import android.widget.FrameLayout;
-import com.devlin_n.yinyangplayer.R;
-import com.devlin_n.yinyangplayer.player.YinYangPlayer;
-import com.devlin_n.yinyangplayer.util.WindowUtil;
+import com.devlin_n.videoplayer.R;
+import com.devlin_n.videoplayer.player.IjkVideoView;
+import com.devlin_n.videoplayer.util.WindowUtil;
/**
* 悬浮窗控件(解决滑动冲突)
@@ -22,7 +22,7 @@ public class FloatView extends FrameLayout{
private WindowManager mWindowManager;
private WindowManager.LayoutParams mParams;
- public YinYangPlayer magicVideoView;
+ public IjkVideoView magicVideoView;
public FloatView(@NonNull Context context, WindowManager mWindowManager, WindowManager.LayoutParams mParams) {
super(context);
@@ -36,7 +36,7 @@ private void init() {
setBackgroundResource(R.drawable.shape_float_window_background);
int padding = WindowUtil.dp2px(getContext(), 1);
setPadding(padding, padding, padding, padding);
- magicVideoView = new YinYangPlayer(getContext());
+ magicVideoView = new IjkVideoView(getContext());
addView(magicVideoView);
}
diff --git a/library/src/main/java/com/devlin_n/yinyangplayer/widget/PlayProgressButton.java b/library/src/main/java/com/devlin_n/videoplayer/widget/PlayProgressButton.java
similarity index 96%
rename from library/src/main/java/com/devlin_n/yinyangplayer/widget/PlayProgressButton.java
rename to library/src/main/java/com/devlin_n/videoplayer/widget/PlayProgressButton.java
index 3533cf42..42f433a8 100644
--- a/library/src/main/java/com/devlin_n/yinyangplayer/widget/PlayProgressButton.java
+++ b/library/src/main/java/com/devlin_n/videoplayer/widget/PlayProgressButton.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yinyangplayer.widget;
+package com.devlin_n.videoplayer.widget;
import android.content.Context;
import android.support.annotation.AttrRes;
@@ -11,8 +11,8 @@
import android.widget.ImageView;
import android.widget.ProgressBar;
-import com.devlin_n.yinyangplayer.R;
-import com.devlin_n.yinyangplayer.util.WindowUtil;
+import com.devlin_n.videoplayer.R;
+import com.devlin_n.videoplayer.util.WindowUtil;
/**
* 播放按钮和加载进度条封装
diff --git a/library/src/main/java/com/devlin_n/yinyangplayer/widget/YinYangSurfaceView.java b/library/src/main/java/com/devlin_n/videoplayer/widget/ResizeSurfaceView.java
similarity index 91%
rename from library/src/main/java/com/devlin_n/yinyangplayer/widget/YinYangSurfaceView.java
rename to library/src/main/java/com/devlin_n/videoplayer/widget/ResizeSurfaceView.java
index fcdb79f7..646253b2 100644
--- a/library/src/main/java/com/devlin_n/yinyangplayer/widget/YinYangSurfaceView.java
+++ b/library/src/main/java/com/devlin_n/videoplayer/widget/ResizeSurfaceView.java
@@ -1,26 +1,26 @@
-package com.devlin_n.yinyangplayer.widget;
+package com.devlin_n.videoplayer.widget;
import android.content.Context;
import android.util.AttributeSet;
import android.view.SurfaceView;
-import com.devlin_n.yinyangplayer.player.YinYangPlayer;
+import com.devlin_n.videoplayer.player.IjkVideoView;
/**
* Created by Devlin_n on 2017/4/10.
*/
-public class YinYangSurfaceView extends SurfaceView {
+public class ResizeSurfaceView extends SurfaceView {
private int mVideoWidth;
private int mVideoHeight;
private int screenType;
- public YinYangSurfaceView(Context context) {
+ public ResizeSurfaceView(Context context) {
super(context);
}
- public YinYangSurfaceView(Context context, AttributeSet attrs) {
+ public ResizeSurfaceView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@@ -49,18 +49,18 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
//如果设置了比例
switch (screenType) {
- case YinYangPlayer.SCREEN_SCALE_ORIGINAL:
+ case IjkVideoView.SCREEN_SCALE_ORIGINAL:
width = mVideoWidth;
height = mVideoHeight;
break;
- case YinYangPlayer.SCREEN_SCALE_16_9:
+ case IjkVideoView.SCREEN_SCALE_16_9:
if (height > width / 16 * 9) {
height = width / 16 * 9;
} else {
width = height / 9 * 16;
}
break;
- case YinYangPlayer.SCREEN_SCALE_4_3:
+ case IjkVideoView.SCREEN_SCALE_4_3:
if (height > width / 4 * 3) {
height = width / 4 * 3;
} else {
@@ -68,7 +68,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
}
// Log.d("@@@@", "onMeasure 4:3 : width" + width + " height:" + height);
break;
- case YinYangPlayer.SCREEN_SCALE_MATCH_PARENT:
+ case IjkVideoView.SCREEN_SCALE_MATCH_PARENT:
width = widthMeasureSpec;
height = heightMeasureSpec;
break;
diff --git a/library/src/main/java/com/devlin_n/yinyangplayer/widget/YinYangTextureView.java b/library/src/main/java/com/devlin_n/videoplayer/widget/ResizeTextureView.java
similarity index 91%
rename from library/src/main/java/com/devlin_n/yinyangplayer/widget/YinYangTextureView.java
rename to library/src/main/java/com/devlin_n/videoplayer/widget/ResizeTextureView.java
index def0d9a5..281c72ea 100644
--- a/library/src/main/java/com/devlin_n/yinyangplayer/widget/YinYangTextureView.java
+++ b/library/src/main/java/com/devlin_n/videoplayer/widget/ResizeTextureView.java
@@ -1,16 +1,16 @@
-package com.devlin_n.yinyangplayer.widget;
+package com.devlin_n.videoplayer.widget;
import android.content.Context;
import android.util.AttributeSet;
import android.view.TextureView;
-import com.devlin_n.yinyangplayer.player.YinYangPlayer;
+import com.devlin_n.videoplayer.player.IjkVideoView;
/**
* 用于显示video的,做了横屏与竖屏的匹配,还有需要rotation需求的
*/
-public class YinYangTextureView extends TextureView {
+public class ResizeTextureView extends TextureView {
private int mVideoWidth;
@@ -18,11 +18,11 @@ public class YinYangTextureView extends TextureView {
private int screenType;
- public YinYangTextureView(Context context) {
+ public ResizeTextureView(Context context) {
super(context);
}
- public YinYangTextureView(Context context, AttributeSet attrs) {
+ public ResizeTextureView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@@ -50,18 +50,18 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
//如果设置了比例
switch (screenType) {
- case YinYangPlayer.SCREEN_SCALE_ORIGINAL:
+ case IjkVideoView.SCREEN_SCALE_ORIGINAL:
width = mVideoWidth;
height = mVideoHeight;
break;
- case YinYangPlayer.SCREEN_SCALE_16_9:
+ case IjkVideoView.SCREEN_SCALE_16_9:
if (height > width / 16 * 9) {
height = width / 16 * 9;
} else {
width = height / 9 * 16;
}
break;
- case YinYangPlayer.SCREEN_SCALE_4_3:
+ case IjkVideoView.SCREEN_SCALE_4_3:
if (height > width / 4 * 3) {
height = width / 4 * 3;
} else {
@@ -69,7 +69,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
}
// Log.d("@@@@", "onMeasure 4:3 : width" + width + " height:" + height);
break;
- case YinYangPlayer.SCREEN_SCALE_MATCH_PARENT:
+ case IjkVideoView.SCREEN_SCALE_MATCH_PARENT:
width = widthMeasureSpec;
height = heightMeasureSpec;
break;
diff --git a/library/src/main/java/com/devlin_n/yinyangplayer/widget/StatusView.java b/library/src/main/java/com/devlin_n/videoplayer/widget/StatusView.java
similarity index 93%
rename from library/src/main/java/com/devlin_n/yinyangplayer/widget/StatusView.java
rename to library/src/main/java/com/devlin_n/videoplayer/widget/StatusView.java
index 344f1f21..ca637e13 100644
--- a/library/src/main/java/com/devlin_n/yinyangplayer/widget/StatusView.java
+++ b/library/src/main/java/com/devlin_n/videoplayer/widget/StatusView.java
@@ -1,4 +1,4 @@
-package com.devlin_n.yinyangplayer.widget;
+package com.devlin_n.videoplayer.widget;
import android.content.Context;
import android.content.Intent;
@@ -12,9 +12,9 @@
import android.widget.LinearLayout;
import android.widget.TextView;
-import com.devlin_n.yinyangplayer.R;
-import com.devlin_n.yinyangplayer.player.BackgroundPlayService;
-import com.devlin_n.yinyangplayer.util.Constants;
+import com.devlin_n.videoplayer.R;
+import com.devlin_n.videoplayer.player.BackgroundPlayService;
+import com.devlin_n.videoplayer.util.Constants;
/**
* 错误提示,网络提示
diff --git a/library/src/main/res/layout/layout_float_controller.xml b/library/src/main/res/layout/layout_float_controller.xml
index 64da9b87..0487cf79 100644
--- a/library/src/main/res/layout/layout_float_controller.xml
+++ b/library/src/main/res/layout/layout_float_controller.xml
@@ -2,7 +2,7 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file