Skip to content

Commit

Permalink
添加FullScreenController
Browse files Browse the repository at this point in the history
  • Loading branch information
Doikki committed Jun 27, 2017
1 parent 6e4e035 commit 2de4f7a
Show file tree
Hide file tree
Showing 61 changed files with 911 additions and 322 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -39,24 +39,24 @@ 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
<com.devlin_n.yinyangplayer.player.YinYangPlayer
<com.devlin_n.videoplayer.player.YinYangPlayer
android:id="@+id/player"
android:layout_width="match_parent"
android:layout_height="300dp" />
```

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
Expand All @@ -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();
}
}
Expand Down Expand Up @@ -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.**
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.devlin_n.yyplayer">
package="com.devlin_n.dcplayer">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:name="com.devlin_n.yyplayer.app.MyApplication"
android:name="com.devlin_n.dcplayer.app.MyApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name="com.devlin_n.yyplayer.MainActivity"
android:name="com.devlin_n.dcplayer.MainActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden">
Expand All @@ -24,31 +24,31 @@
</intent-filter>
</activity>
<activity
android:name="com.devlin_n.yyplayer.activity.VodPlayerActivity"
android:name="com.devlin_n.dcplayer.activity.VodPlayerActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait" />
<activity
android:name="com.devlin_n.yyplayer.activity.LivePlayerActivity"
android:name="com.devlin_n.dcplayer.activity.LivePlayerActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait" />
<activity
android:name="com.devlin_n.yyplayer.activity.FullScreenActivity"
android:name="com.devlin_n.dcplayer.activity.FullScreenActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait" />
<activity
android:name="com.devlin_n.yyplayer.activity.RecyclerViewActivity"
android:name="com.devlin_n.dcplayer.activity.RecyclerViewActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait" />
<activity
android:name="com.devlin_n.yyplayer.activity.PlayerActivity"
android:name="com.devlin_n.dcplayer.activity.PlayerActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait" />
<activity
android:name="com.devlin_n.yyplayer.activity.DanmakuActivity"
android:name="com.devlin_n.dcplayer.activity.DanmakuActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait" />
<activity
android:name="com.devlin_n.yyplayer.activity.ListViewActivity"
android:name="com.devlin_n.dcplayer.activity.ListViewActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait" />
</application>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.devlin_n.yyplayer;
package com.devlin_n.dcplayer;

import android.Manifest;
import android.content.Intent;
Expand All @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.devlin_n.yyplayer.activity;
package com.devlin_n.dcplayer.activity;

import android.content.Intent;
import android.graphics.Canvas;
Expand All @@ -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;

Expand All @@ -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";

Expand All @@ -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()
Expand All @@ -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();
}
}
Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.devlin_n.yyplayer.activity;
package com.devlin_n.dcplayer.activity;

import android.content.Intent;
import android.os.Bundle;
Expand All @@ -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;

/**
* 全屏播放
Expand All @@ -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();
}
}
Expand All @@ -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();
}
Expand Down
Loading

0 comments on commit 2de4f7a

Please sign in to comment.