提交 d285bbf1 编写于 作者: G guoshuyu

调整框架,剔除exoplayer到外部依赖

上级 4516fb6a
......@@ -88,6 +88,7 @@ dependencies {
}
annotationProcessor dataDependencies.permissionsdispatcherProcessor
//jcenter
//implementation "com.shuyu:GSYVideoPlayer:$gsyVideoVersion"
......
......@@ -4,8 +4,16 @@ import android.app.Application;
import android.support.multidex.MultiDexApplication;
import com.shuyu.gsyvideoplayer.GSYVideoManager;
import com.shuyu.gsyvideoplayer.cache.CacheFactory;
import com.shuyu.gsyvideoplayer.cache.ProxyCacheManager;
import com.shuyu.gsyvideoplayer.player.IjkPlayerManager;
import com.shuyu.gsyvideoplayer.player.PlayerFactory;
import com.shuyu.gsyvideoplayer.player.SystemPlayerManager;
import com.shuyu.gsyvideoplayer.utils.GSYVideoType;
import tv.danmaku.ijk.media.exo2.Exo2PlayerManager;
import tv.danmaku.ijk.media.exo2.ExoPlayerCacheManager;
//import com.squareup.leakcanary.LeakCanary;
/**
......@@ -24,13 +32,15 @@ public class GSYApplication extends MultiDexApplication {
//}
//LeakCanary.install(this);
//GSYVideoType.enableMediaCodec();
//GSYVideoType.enableMediaCodecTexture();
//GSYVideoManager.instance().setVideoType(this, GSYVideoType.IJKEXOPLAYER); //EXO 1 播放内核,弃用
//GSYVideoManager.instance().setVideoType(this, GSYVideoType.IJKEXOPLAYER2); //EXO 2 播放内核
//GSYVideoManager.instance().setVideoType(this, GSYVideoType.SYSTEMPLAYER); //系统播放器
PlayerFactory.setPlayManager(new Exo2PlayerManager());//EXO模式
//PlayerFactory.setPlayManager(new SystemPlayerManager());//系统模式
//PlayerFactory.setPlayManager(new IjkPlayerManager());//ijk模式
CacheFactory.setCacheManager(new ExoPlayerCacheManager());//exo缓存模式,支持m3u8,只支持exo
//CacheFactory.setCacheManager(new ProxyCacheManager());//代理缓存模式,支持所有模式,不支持m3u8等
//GSYVideoType.setShowType(GSYVideoType.SCREEN_MATCH_FULL);
//GSYVideoType.setShowType(GSYVideoType.SCREEN_TYPE_FULL);
......
......@@ -49,7 +49,7 @@ public class GSYExoVideoManager extends GSYVideoBaseManager {
}
@Override
protected IPlayerManager getPlayManager(int videoType) {
protected IPlayerManager getPlayManager() {
return new GSYExoPlayerManager();
}
......
......@@ -17,7 +17,7 @@ public class SimpleDetailActivityMode1 extends GSYBaseActivityDetail<StandardGSY
StandardGSYVideoPlayer detailPlayer;
private String url = "http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4";
private String url = "http://7xp06y.com1.z0.glb.clouddn.com/b10/%E4%B8%80%E6%97%A0%E6%89%80%E6%9C%89%E6%9C%89%E6%A2%A6%E8%80%8C%E5%B7%B2%20solo%20cut.mp3";
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -42,7 +42,7 @@ public class SimpleDetailActivityMode1 extends GSYBaseActivityDetail<StandardGSY
public GSYVideoOptionBuilder getGSYVideoOptionBuilder() {
//内置封面可参考SampleCoverVideo
ImageView imageView = new ImageView(this);
loadCover(imageView, url);
//loadCover(imageView, url);
return new GSYVideoOptionBuilder()
.setThumbImageView(imageView)
.setUrl(url)
......
......@@ -9,7 +9,7 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
org.gradle.jvmargs=-Xmx2048m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
......
......@@ -9,7 +9,7 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
#org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
......
......@@ -9,7 +9,7 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
#org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
......
......@@ -9,7 +9,7 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
#org.gradle.jvmargs=-Xmx1024m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
......
group = PROJ_GROUP
version = PROJ_VERSION
project.archivesBaseName = PROJ_ARTIFACTID
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.dcendents.android-maven'
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += configurations.compile
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
javadoc {
options{
encoding "UTF-8"
charSet 'UTF-8'
author true
version true
links "http://docs.oracle.com/javase/7/docs/api"
title "$PROJ_NAME $PROJ_VERSION"
}
}
artifacts {
archives sourcesJar
archives javadocJar
}
install {
repositories.mavenInstaller {
pom.project {
name PROJ_NAME
description PROJ_DESCRIPTION
url PROJ_WEBSITEURL
inceptionYear '2016'
packaging 'aar'
groupId PROJ_GROUP
artifactId PROJ_ARTIFACTID
version PROJ_VERSION
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
scm {
connection PROJ_VCSURL
url PROJ_WEBSITEURL
}
developers {
developer {
id DEVELOPER_ID
name DEVELOPER_NAME
email DEVELOPER_EMAIL
}
}
}
}
}
bintray {
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : project.property('BINTRAY_USER')
key = project.hasProperty('bintrayKey') ? project.property('bintrayKey') : project.property('BINTRAY_KEY')
configurations = ['archives']
dryRun = false
publish = true
pkg {
//userOrg = PROJ_USER_ORG //这个是你创建时的organization,必须要有,不然没办法找到指定路径
repo = PROJ_USER_MAVEN
name = PROJ_NAME
licenses = ['Apache-2.0']
vcsUrl = PROJ_VCSURL
websiteUrl = PROJ_WEBSITEURL
issueTrackerUrl = PROJ_ISSUETRACKERURL
publicDownloadNumbers = true
version {
name = PROJ_VERSION
desc = PROJ_DESCRIPTION
vcsTag = PROJ_VERSION
gpg {
sign = true
}
}
}
}
apply plugin: 'com.android.library'
android {
def globalConfiguration = rootProject.extensions.getByName("ext")
compileSdkVersion globalConfiguration.androidCompileSdkVersion
buildToolsVersion globalConfiguration.androidBuildToolsVersion
defaultConfig {
minSdkVersion globalConfiguration.androidMinSdkVersion
targetSdkVersion globalConfiguration.androidTargetSdkVersion
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
def viewDependencies = rootProject.ext.viewDependencies
api viewDependencies.ijkplayer_java
//compile fileTree(dir: 'libs', include: ['*.jar'])
//def viewDependencies = rootProject.ext.viewDependencies
//compile viewDependencies.ijkplayer_java
}
apply from: './bintray.gradle'
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
#org.gradle.jvmargs=-Xmx1024m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
PROJ_NAME=GSYVideoPlayer-base
PROJ_ARTIFACTID=GSYVideoPlayer-base
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.shuyu.gsy.base" />
......@@ -3,8 +3,8 @@ package com.shuyu.gsyvideoplayer.player;
import android.content.Context;
import android.os.Message;
import com.shuyu.gsyvideoplayer.cache.ICacheManager;
import com.shuyu.gsyvideoplayer.model.VideoOptionModel;
import com.shuyu.gsyvideoplayer.cache.ICacheManager;
import java.util.List;
......
......@@ -9,7 +9,7 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
#org.gradle.jvmargs=-Xmx1024m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
......
......@@ -33,24 +33,23 @@ dependencies {
implementation androidDependencies.appcompat_v7
def viewDependencies = rootProject.ext.viewDependencies
def dataDependencies = rootProject.ext.dataDependencies
api viewDependencies.ijkplayer_java
api viewDependencies.ijkplayer_exo
api viewDependencies.transitionseverywhere
//api dataDependencies.videocache
//api "com.shuyu:GSYVideoPlayer-exo2:$gsyVideoVersion"
//api "com.shuyu:GSYVideoPlayer-base:$gsyVideoVersion"
api project(':gsyvideoplayer-androidvideocache')
api project(':gsyvideoplayer-exo2')
api project(':gsyVideoPlayer-base')
// compile fileTree(dir: 'libs', include: ['*.jar'])
// compile androidDependencies.appcompat_v7
// def viewDependencies = rootProject.ext.viewDependencies
// def dataDependencies = rootProject.ext.dataDependencies
// compile viewDependencies.ijkplayer_java
// compile viewDependencies.transitionseverywhere
// compile "com.shuyu:gsyvideoplayer-androidvideocache:$gsyVideoVersion"
// compile "com.shuyu:GSYVideoPlayer-exo2:$gsyVideoVersion"
// compile "com.shuyu:GSYVideoPlayer-base:$gsyVideoVersion"
}
apply from: './bintray.gradle'
......@@ -9,7 +9,7 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
#org.gradle.jvmargs=-Xmx1024m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
......
package com.shuyu.gsyvideoplayer;
import android.media.AudioManager;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import android.view.Surface;
import com.shuyu.gsyvideoplayer.model.GSYModel;
import java.io.IOException;
import java.util.Map;
import tv.danmaku.ijk.media.player.IMediaPlayer;
import tv.danmaku.ijk.media.player.IjkMediaPlayer;
/**
* 小窗口预览管理
* Created by shuyu on 2016/12/11.
*/
@Deprecated
public class GSYPreViewManager implements IMediaPlayer.OnPreparedListener, IjkMediaPlayer.OnSeekCompleteListener {
public static String TAG = "GSYPreViewManager";
private static GSYPreViewManager videoManager;
private static final int HANDLER_PREPARE = 0;
private static final int HANDLER_SETDISPLAY = 1;
private static final int HANDLER_RELEASE = 2;
private IjkMediaPlayer mediaPlayer;
private HandlerThread mMediaHandlerThread;
private MediaHandler mMediaHandler;
private boolean seekToComplete = true;
public static synchronized GSYPreViewManager instance() {
if (videoManager == null) {
videoManager = new GSYPreViewManager();
}
return videoManager;
}
private GSYPreViewManager() {
mediaPlayer = new IjkMediaPlayer();
mMediaHandlerThread = new HandlerThread(TAG);
mMediaHandlerThread.start();
mMediaHandler = new MediaHandler((mMediaHandlerThread.getLooper()));
}
private class MediaHandler extends Handler {
MediaHandler(Looper looper) {
super(looper);
}
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case HANDLER_PREPARE:
initVideo(msg);
break;
case HANDLER_SETDISPLAY:
showDisplay(msg);
break;
case HANDLER_RELEASE:
if (mediaPlayer != null) {
mediaPlayer.release();
}
break;
}
}
}
private void initVideo(Message msg) {
try {
mediaPlayer.release();
initIJKPlayer(msg);
mediaPlayer.setOnPreparedListener(GSYPreViewManager.this);
mediaPlayer.setOnSeekCompleteListener(this);
mediaPlayer.setVolume(0, 0);
mediaPlayer.prepareAsync();
} catch (Exception e) {
e.printStackTrace();
}
}
private void initIJKPlayer(Message msg) {
mediaPlayer = new IjkMediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
mediaPlayer.setDataSource(((GSYModel) msg.obj).getUrl(), ((GSYModel) msg.obj).getMapHeadData());
} catch (IOException e) {
e.printStackTrace();
}
}
private void showDisplay(Message msg) {
if (msg.obj == null && mediaPlayer != null) {
mediaPlayer.setSurface(null);
} else {
Surface holder = (Surface) msg.obj;
if (mediaPlayer != null && holder.isValid()) {
mediaPlayer.setSurface(holder);
}
}
}
@Override
public void onPrepared(IMediaPlayer mp) {
mp.pause();
seekToComplete = true;
}
@Override
public void onSeekComplete(IMediaPlayer mp) {
seekToComplete = true;
}
public void prepare(final String url, final Map<String, String> mapHeadData, boolean loop, float speed) {
if (TextUtils.isEmpty(url)) return;
Message msg = new Message();
msg.what = HANDLER_PREPARE;
GSYModel fb = new GSYModel(url, mapHeadData, loop, speed, false, null);
msg.obj = fb;
mMediaHandler.sendMessage(msg);
}
public void releaseMediaPlayer() {
Message msg = new Message();
msg.what = HANDLER_RELEASE;
mMediaHandler.sendMessage(msg);
}
public void setDisplay(Surface holder) {
Message msg = new Message();
msg.what = HANDLER_SETDISPLAY;
msg.obj = holder;
mMediaHandler.sendMessage(msg);
}
public IjkMediaPlayer getMediaPlayer() {
return mediaPlayer;
}
public boolean isSeekToComplete() {
return seekToComplete;
}
public void setSeekToComplete(boolean seekToComplete) {
this.seekToComplete = seekToComplete;
}
}
\ No newline at end of file
......@@ -111,11 +111,6 @@ public abstract class GSYVideoBaseManager implements IMediaPlayer.OnPreparedList
*/
protected int timeOut = 8 * 1000;
/**
* 播放类型,默认IJK
*/
protected int videoType = GSYVideoType.IJKPLAYER;
/**
* 是否需要静音
*/
......@@ -143,7 +138,7 @@ public abstract class GSYVideoBaseManager implements IMediaPlayer.OnPreparedList
if (cacheManager != null) {
cacheManager.clearCache(context, cacheDir, url);
} else {
getCacheManager(videoType).clearCache(context, cacheDir, url);
getCacheManager().clearCache(context, cacheDir, url);
}
}
......@@ -154,12 +149,12 @@ public abstract class GSYVideoBaseManager implements IMediaPlayer.OnPreparedList
mainThreadHandler = new Handler();
}
protected IPlayerManager getPlayManager(int videoType) {
return PlayerFactory.getPlayManager(videoType);
protected IPlayerManager getPlayManager() {
return PlayerFactory.getPlayManager();
}
protected ICacheManager getCacheManager(int videoType) {
return CacheFactory.getCacheManager(videoType);
protected ICacheManager getCacheManager() {
return CacheFactory.getCacheManager();
}
@Override
......@@ -408,7 +403,7 @@ public abstract class GSYVideoBaseManager implements IMediaPlayer.OnPreparedList
*/
@Override
public boolean cachePreview(Context context, File cacheDir, String url) {
return getCacheManager(videoType).cachePreview(context, cacheDir, url);
return getCacheManager().cachePreview(context, cacheDir, url);
}
@Override
......@@ -589,8 +584,8 @@ public abstract class GSYVideoBaseManager implements IMediaPlayer.OnPreparedList
if (playerManager != null) {
playerManager.release();
}
playerManager = getPlayManager(videoType);
cacheManager = getCacheManager(videoType);
playerManager = getPlayManager();
cacheManager = getCacheManager();
if (cacheManager != null) {
cacheManager.setCacheAvailableListener(this);
}
......@@ -662,21 +657,6 @@ public abstract class GSYVideoBaseManager implements IMediaPlayer.OnPreparedList
}
}
public int getVideoType() {
return videoType;
}
/**
* 设置了视频的播放类型
* IJKPLAYER = 0; 默认IJK
* IJKEXOPLAYER2 = 2;EXOPlayer2
* SYSTEMPLAYER = 4;系统播放器
*/
public void setVideoType(Context context, int videoType) {
this.context = context.getApplicationContext();
this.videoType = videoType;
}
public void initContext(Context context) {
this.context = context.getApplicationContext();
}
......
......@@ -60,7 +60,6 @@ public class GSYVideoManager extends GSYVideoBaseManager {
gsyVideoManager.lastState = videoManager.lastState;
gsyVideoManager.playPosition = videoManager.playPosition;
gsyVideoManager.timeOut = videoManager.timeOut;
gsyVideoManager.videoType = videoManager.videoType;
gsyVideoManager.needMute = videoManager.needMute;
gsyVideoManager.needTimeOutOther = videoManager.needTimeOutOther;
gsyVideoManager.setListener(listener);
......
package com.shuyu.gsyvideoplayer.cache;
import com.shuyu.gsyvideoplayer.utils.GSYVideoType;
/**
* 缓存到本地服务工厂
* Created by guoshuyu on 2018/5/21.
*/
public class CacheFactory {
/**
* 不使用cache服务
*/
public final static int CACHE_NULL = -1;
/**
* 默认缓存服务,EXO使用Source缓存,其他使用proxy缓存
*/
public final static int EXO_DEFAULT = 0;
/**
* ExoPlayer使用Proxy服务缓存,只对EXO播放内核生效
*/
public final static int EXO_CACHE_PROXY = 1;
private static int sCacheMode = EXO_DEFAULT;
private static ICacheManager sICacheManager;
public static ICacheManager getCacheManager(int videoType) {
if (sCacheMode == CACHE_NULL) {
return null;
}
switch (videoType) {
case GSYVideoType.IJKEXOPLAYER2:
if (sCacheMode == EXO_DEFAULT) {
//针对exoPlayer的source cache处理
return new ExoPlayerCacheManager();
}
case GSYVideoType.SYSTEMPLAYER:
case GSYVideoType.IJKPLAYER:
default:
return new ProxyCacheManager();
}
public static void setCacheManager(ICacheManager cacheManager) {
sICacheManager = cacheManager;
}
/**
* 设置缓存模式, 默认EXO使用Source缓存,其他使用proxy缓存
*
* @param mode CACHE_NULL、EXO_CACHE_PROXY、EXO_DEFAULT
*/
public static void setCacheMode(int mode) {
sCacheMode = mode;
public static ICacheManager getCacheManager() {
if (sICacheManager == null) {
sICacheManager = new ProxyCacheManager();
}
return sICacheManager;
}
}
package com.shuyu.gsyvideoplayer.player;
import com.shuyu.gsyvideoplayer.utils.GSYVideoType;
/**
* 播放内核工厂
* Created by guoshuyu on 2018/5/21.
*/
public class PlayerFactory {
public static IPlayerManager getPlayManager(int videoType) {
switch (videoType) {
case GSYVideoType.IJKEXOPLAYER2:
return new Exo2PlayerManager();
case GSYVideoType.SYSTEMPLAYER:
return new SystemPlayerManager();
case GSYVideoType.IJKPLAYER:
default:
return new IjkPlayerManager();
private static IPlayerManager sPlayerManager;
public static void setPlayManager(IPlayerManager playManager) {
sPlayerManager = playManager;
}
public static IPlayerManager getPlayManager() {
if(sPlayerManager == null) {
sPlayerManager = new IjkPlayerManager();
}
return sPlayerManager;
}
}
......@@ -22,21 +22,6 @@ public class GSYVideoType {
//全屏拉伸显示,使用这个属性时,surface_container建议使用FrameLayout
public final static int SCREEN_MATCH_FULL = -4;
//默认播放内核IJK
public final static int IJKPLAYER = 0;
/**
* IJKEXOPLAYER 和 IJKEXOPLAYER2 是互斥的
* IJKEXOPLAYER2 must be compile com.shuyu:gsyVideoPlayer-exo2:$gsyVideoVersion
*/
//EXO 2 播放内核
public final static int IJKEXOPLAYER2 = 2;
//EXO 1 播放内核,弃用,现在使用的是IJKEXOPLAYER2
@Deprecated
public final static int IJKEXOPLAYER = IJKEXOPLAYER2;
//系统播放器
public final static int SYSTEMPLAYER = 4;
/**
* GLSurfaceView 主要用于OpenGL渲染的
*/
......
package com.shuyu.gsyvideoplayer.video;
import android.content.Context;
import android.graphics.SurfaceTexture;
import android.util.AttributeSet;
import android.view.Surface;
import android.view.TextureView;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import com.shuyu.gsyvideoplayer.GSYPreViewManager;
import com.shuyu.gsyvideoplayer.render.view.GSYTextureView;
import com.shuyu.gsyvideoplayer.R;
import com.shuyu.gsyvideoplayer.video.base.GSYBaseVideoPlayer;
/**
* Created by shuyu on 2016/12/10.
* 进度图小图预览,目前对本地视频还可以,网络视频效果不好,不建议使用
*/
@Deprecated
public class CustomGSYVideoPlayer extends StandardGSYVideoPlayer {
private RelativeLayout mPreviewLayout;
private GSYTextureView mPreviewTexture;
//是否因为用户点击
private boolean mIsFromUser;
//是否打开滑动预览
private boolean mOpenPreView;
private int mPreProgress = -2;
/**
* 1.5.0开始加入,如果需要不同布局区分功能,需要重载
*/
public CustomGSYVideoPlayer(Context context, Boolean fullFlag) {
super(context, fullFlag);
}
public CustomGSYVideoPlayer(Context context) {
super(context);
}
public CustomGSYVideoPlayer(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void init(Context context) {
super.init(context);
initView();
}
private void initView() {
mPreviewLayout = (RelativeLayout) findViewById(R.id.preview_layout);
}
@Override
public int getLayoutId() {
return R.layout.video_layout_custom;
}
@Override
protected void addTextureView() {
super.addTextureView();
if (mPreviewLayout.getChildCount() > 0) {
mPreviewLayout.removeAllViews();
}
mPreviewTexture = null;
mPreviewTexture = new GSYTextureView(getActivityContext());
mPreviewTexture.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
GSYPreViewManager.instance().setDisplay(new Surface(surface));
}
@Override
public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
}
@Override
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
GSYPreViewManager.instance().setDisplay(null);
return true;
}
@Override
public void onSurfaceTextureUpdated(SurfaceTexture surface) {
}
});
mPreviewTexture.setRotation(mRotate);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
mPreviewLayout.addView(mPreviewTexture, layoutParams);
}
@Override
protected void prepareVideo() {
GSYPreViewManager.instance().prepare(mUrl, mMapHeadData, mLooping, mSpeed);
super.prepareVideo();
}
@Override
public void onProgressChanged(SeekBar seekBar, final int progress, boolean fromUser) {
super.onProgressChanged(seekBar, progress, fromUser);
if (fromUser && mOpenPreView) {
int width = seekBar.getWidth();
int offset = (int) (width - (getResources().getDimension(R.dimen.seek_bar_image) / 2)) / 100 * progress;
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mPreviewLayout.getLayoutParams();
layoutParams.leftMargin = offset;
//设置帧预览图的显示位置
mPreviewLayout.setLayoutParams(layoutParams);
if (GSYPreViewManager.instance().getMediaPlayer() != null
&& mHadPlay && (mOpenPreView)
&& GSYPreViewManager.instance().isSeekToComplete()) {
GSYPreViewManager.instance().setSeekToComplete(false);
int time = progress * getDuration() / 100;
GSYPreViewManager.instance().getMediaPlayer().seekTo(time);
mPreProgress = progress;
}
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
super.onStartTrackingTouch(seekBar);
if (mOpenPreView) {
mIsFromUser = true;
mPreviewLayout.setVisibility(VISIBLE);
mPreProgress = -2;
}
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
if (mOpenPreView) {
if (mPreProgress >= 0) {
seekBar.setProgress(mPreProgress);
}
super.onStopTrackingTouch(seekBar);
mIsFromUser = false;
mPreviewLayout.setVisibility(GONE);
} else {
super.onStopTrackingTouch(seekBar);
}
}
@Override
protected void setTextAndProgress(int secProgress) {
if (mIsFromUser) {
return;
}
super.setTextAndProgress(secProgress);
}
@Override
public GSYBaseVideoPlayer startWindowFullscreen(Context context, boolean actionBar, boolean statusBar) {
GSYBaseVideoPlayer gsyBaseVideoPlayer = super.startWindowFullscreen(context, actionBar, statusBar);
CustomGSYVideoPlayer customGSYVideoPlayer = (CustomGSYVideoPlayer) gsyBaseVideoPlayer;
customGSYVideoPlayer.mOpenPreView = mOpenPreView;
return gsyBaseVideoPlayer;
}
public boolean isOpenPreView() {
return mOpenPreView;
}
/**
* 如果是需要进度条预览的设置打开,默认关闭
*/
public void setOpenPreView(boolean localFile) {
this.mOpenPreView = localFile;
}
}
......@@ -9,7 +9,7 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
#org.gradle.jvmargs=-Xmx1024m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
......
......@@ -9,7 +9,7 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
#org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
......
......@@ -32,6 +32,7 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
api project(':gsyVideoPlayer-java')
api project(':gsyvideoplayer-exo2')
//api project(':gsyVideoPlayer-armv5')
//api project(':gsyVideoPlayer-armv7a')
//api project(':gsyVideoPlayer-armv64')
......@@ -56,6 +57,7 @@ dependencies {
//compile fileTree(dir: 'libs', include: ['*.jar'])
//compile "com.shuyu:gsyVideoPlayer-java:$gsyVideoVersion"
//compile "com.shuyu:GSYVideoPlayer-exo2:$gsyVideoVersion"
//compile "com.shuyu:gsyVideoPlayer-armv5:$gsyVideoVersion"
//compile "com.shuyu:gsyVideoPlayer-armv7a:$gsyVideoVersion"
//compile "com.shuyu:gsyVideoPlayer-arm64:$gsyVideoVersion"
......
......@@ -9,7 +9,7 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
#org.gradle.jvmargs=-Xmx1024m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
......
......@@ -9,7 +9,7 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
#org.gradle.jvmargs=-Xmx1024m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
......
......@@ -31,17 +31,20 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
def viewDependencies = rootProject.ext.viewDependencies
implementation viewDependencies.ijkplayer_java
api viewDependencies.ijkplayer_java
api viewDependencies.exo_player2
api viewDependencies.exo_player2_rtmp
//api "com.shuyu:GSYVideoPlayer-base:$gsyVideoVersion"
api project(':gsyVideoPlayer-base')
//compile fileTree(dir: 'libs', include: ['*.jar'])
//def viewDependencies = rootProject.ext.viewDependencies
//compile viewDependencies.ijkplayer_java
//compile viewDependencies.exo_player2
//compile viewDependencies.exo_player2_rtmp
//compile "com.shuyu:GSYVideoPlayer-base:$gsyVideoVersion"
}
......
......@@ -9,7 +9,7 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
#org.gradle.jvmargs=-Xmx1024m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
......
package com.shuyu.gsyvideoplayer.player;
package tv.danmaku.ijk.media.exo2;
import android.content.Context;
import android.media.AudioManager;
......@@ -10,10 +10,10 @@ import com.google.android.exoplayer2.video.DummySurface;
import com.shuyu.gsyvideoplayer.cache.ICacheManager;
import com.shuyu.gsyvideoplayer.model.GSYModel;
import com.shuyu.gsyvideoplayer.model.VideoOptionModel;
import com.shuyu.gsyvideoplayer.player.IPlayerManager;
import java.util.List;
import tv.danmaku.ijk.media.exo2.IjkExo2MediaPlayer;
import tv.danmaku.ijk.media.player.IMediaPlayer;
/**
......
package com.shuyu.gsyvideoplayer.cache;
package tv.danmaku.ijk.media.exo2;
import android.content.Context;
import android.net.Uri;
import com.shuyu.gsyvideoplayer.cache.ICacheManager;
import java.io.File;
import java.util.Map;
import tv.danmaku.ijk.media.exo2.ExoSourceManager;
import tv.danmaku.ijk.media.exo2.IjkExo2MediaPlayer;
import tv.danmaku.ijk.media.player.IMediaPlayer;
/**
......
include ':app', ':gsyVideoPlayer', ':gsyVideoPlayer-java', ':gsyVideoPlayer-armv5', ':gsyVideoPlayer-armv7a', ':gsyVideoPlayer-armv64', ':gsyVideoPlayer-x86', ':gsyVideoPlayer-x86_64', ':gsyVideoPlayer-ex_so', ':gsyvideoplayer-androidvideocache', ':gsyvideoplayer-exo2'
include ':app', ':gsyVideoPlayer', ':gsyVideoPlayer-java', ':gsyVideoPlayer-armv5', ':gsyVideoPlayer-armv7a', ':gsyVideoPlayer-armv64', ':gsyVideoPlayer-x86', ':gsyVideoPlayer-x86_64', ':gsyVideoPlayer-ex_so', ':gsyvideoplayer-androidvideocache', ':gsyvideoplayer-exo2', ':gsyVideoPlayer-base'
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册