Skip to content

Commit

Permalink
improt video cache
Browse files Browse the repository at this point in the history
  • Loading branch information
CarGuo committed Dec 2, 2016
1 parent efe05ef commit d8e556b
Show file tree
Hide file tree
Showing 58 changed files with 2,454 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ compile 'com.shuyu:gsyVideoPlayer:1.3.7'
* <h4>3、详情模式</h4>
<img src="https://github.com/CarGuo/GSYVideoPlayer/blob/master/04.gif" width="240px" height="426px"/>

### 1.3.8 添加了lib封面对复用封面的支持和demo


### 1.3.7 优化了弹出框;优化了暂停的时候(全屏/恢复全屏/退到)会是黑色的问题;解决了暂停的时候拖动进度条问题


Expand Down
3 changes: 1 addition & 2 deletions gsyVideoPlayer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':videoCache')
def viewDependencies = rootProject.ext.viewDependencies
def dataDependencies = rootProject.ext.dataDependencies
compile viewDependencies.ijkplayer_java
compile viewDependencies.ijkplayer_armv7a
compile viewDependencies.ijkplayer_armv5
compile viewDependencies.ijkplayer_x86
compile viewDependencies.ijkplayer_exo
compile viewDependencies.transitionseverywhere
compile dataDependencies.videocache
compile androidDependencies.support_v4
compile androidDependencies.appcompat_v7
}
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include ':app', ':gsyVideoPlayer'
include ':app', ':gsyVideoPlayer', ':videoCache'
49 changes: 49 additions & 0 deletions videoCache/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.novoda:bintray-release:0.3.4'
}
}

apply plugin: 'com.android.library'
apply plugin: 'idea'
apply plugin: 'bintray-release'

android {
compileSdkVersion 23
buildToolsVersion '22.0.1'

defaultConfig {
minSdkVersion 9
targetSdkVersion 23
versionCode 19
versionName '2.6.3'
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}

idea {
module {
downloadJavadoc = true
downloadSources = true
}
}

dependencies {
compile 'org.slf4j:slf4j-android:1.7.21'
}

publish {
userOrg = 'alexeydanilov'
groupId = 'com.danikula'
artifactId = 'videocache'
publishVersion = '2.6.3'
description = 'Cache support for android VideoView'
website = 'https://github.com/danikula/AndroidVideoCache'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Automatically generated file. DO NOT MODIFY
*/
package com.danikula.videocache.test;

public final class BuildConfig {
public static final boolean DEBUG = Boolean.parseBoolean("true");
public static final String APPLICATION_ID = "com.danikula.videocache.test";
public static final String BUILD_TYPE = "debug";
public static final String FLAVOR = "";
public static final int VERSION_CODE = 19;
public static final String VERSION_NAME = "2.6.3";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Automatically generated file. DO NOT MODIFY
*/
package com.danikula.videocache;

public final class BuildConfig {
public static final boolean DEBUG = Boolean.parseBoolean("true");
public static final String APPLICATION_ID = "com.danikula.videocache";
public static final String BUILD_TYPE = "debug";
public static final String FLAVOR = "";
public static final int VERSION_CODE = 19;
public static final String VERSION_NAME = "2.6.3";
}
14 changes: 14 additions & 0 deletions videoCache/build/intermediates/bundles/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
package="com.danikula.videocache"
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="19"
android:versionName="2.6.3" >

<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="23" />

<application />

</manifest>
14 changes: 14 additions & 0 deletions videoCache/build/intermediates/bundles/release/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
package="com.danikula.videocache"
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="19"
android:versionName="2.6.3" >

<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="23" />

<application />

</manifest>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#Fri Dec 02 23:33:54 GMT+08:00 2016
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="debug$Generated" generated="true"><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\build\intermediates\bundles\debug\res"/></dataSet><dataSet config="main$Generated" generated="true"><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\src\androidTest\res"/><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\build\generated\res\rs\androidTest\debug"/><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\build\generated\res\resValues\androidTest\debug"/></dataSet><dataSet config="debug" from-dependency="true" generated-set="debug$Generated"><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\build\intermediates\bundles\debug\res"/></dataSet><dataSet config="main" generated-set="main$Generated"><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\src\androidTest\res"/><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\build\generated\res\rs\androidTest\debug"/><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\build\generated\res\resValues\androidTest\debug"/></dataSet><mergedItems/></merger>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main"><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\src\main\assets"/><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\build\generated\assets\shaders\debug"/></dataSet><dataSet config="debug"><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\src\debug\assets"/></dataSet></merger>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main"><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\src\main\shaders"/></dataSet><dataSet config="debug"><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\src\debug\shaders"/></dataSet></merger>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main"><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\src\main\assets"/><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\build\generated\assets\shaders\release"/></dataSet><dataSet config="release"><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\src\release\assets"/></dataSet></merger>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main"><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\src\main\shaders"/></dataSet><dataSet config="release"><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\src\release\shaders"/></dataSet></merger>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#Fri Dec 02 23:33:52 GMT+08:00 2016
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main$Generated" generated="true"><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\src\main\res"/><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\build\generated\res\rs\debug"/><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\build\generated\res\resValues\debug"/></dataSet><dataSet config="debug$Generated" generated="true"><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\src\debug\res"/></dataSet><dataSet config="main" generated-set="main$Generated"><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\src\main\res"/><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\build\generated\res\rs\debug"/><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\build\generated\res\resValues\debug"/></dataSet><dataSet config="debug" generated-set="debug$Generated"><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\src\debug\res"/></dataSet><mergedItems/></merger>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#Fri Dec 02 23:34:58 GMT+08:00 2016
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main$Generated" generated="true"><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\src\main\res"/><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\build\generated\res\rs\release"/><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\build\generated\res\resValues\release"/></dataSet><dataSet config="release$Generated" generated="true"><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\src\release\res"/></dataSet><dataSet config="main" generated-set="main$Generated"><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\src\main\res"/><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\build\generated\res\rs\release"/><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\build\generated\res\resValues\release"/></dataSet><dataSet config="release" generated-set="release$Generated"><source path="D:\workSpace\android\Github-Code\GSYVideoPlayer\videoCache\src\release\res"/></dataSet><mergedItems/></merger>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.danikula.videocache.test" >

<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="23" />

<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:functionalTest="false"
android:handleProfiling="false"
android:label="Tests for com.danikula.videocache.test"
android:targetPackage="com.danikula.videocache.test" />

<application>
<uses-library android:name="android.test.runner" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
package="com.danikula.videocache"
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="19"
android:versionName="2.6.3" >

<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="23" />

<application />

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
package="com.danikula.videocache"
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="19"
android:versionName="2.6.3" >

<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="23" />

<application />

</manifest>
Binary file not shown.
5 changes: 5 additions & 0 deletions videoCache/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
package="com.danikula.videocache">
<application />
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.danikula.videocache;

import java.io.ByteArrayInputStream;
import java.util.Arrays;

/**
* Simple memory based {@link Cache} implementation.
*
* @author Alexey Danilov (danikula@gmail.com).
*/
public class ByteArrayCache implements Cache {

private volatile byte[] data;
private volatile boolean completed;

public ByteArrayCache() {
this(new byte[0]);
}

public ByteArrayCache(byte[] data) {
this.data = Preconditions.checkNotNull(data);
}

@Override
public int read(byte[] buffer, long offset, int length) throws ProxyCacheException {
if (offset >= data.length) {
return -1;
}
if (offset > Integer.MAX_VALUE) {
throw new IllegalArgumentException("Too long offset for memory cache " + offset);
}
return new ByteArrayInputStream(data).read(buffer, (int) offset, length);
}

@Override
public int available() throws ProxyCacheException {
return data.length;
}

@Override
public void append(byte[] newData, int length) throws ProxyCacheException {
Preconditions.checkNotNull(data);
Preconditions.checkArgument(length >= 0 && length <= newData.length);

byte[] appendedData = Arrays.copyOf(data, data.length + length);
System.arraycopy(newData, 0, appendedData, data.length, length);
data = appendedData;
}

@Override
public void close() throws ProxyCacheException {
}

@Override
public void complete() {
completed = true;
}

@Override
public boolean isCompleted() {
return completed;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.danikula.videocache;

import java.io.ByteArrayInputStream;

/**
* Simple memory based {@link Source} implementation.
*
* @author Alexey Danilov (danikula@gmail.com).
*/
public class ByteArraySource implements Source {

private final byte[] data;
private ByteArrayInputStream arrayInputStream;

public ByteArraySource(byte[] data) {
this.data = data;
}

@Override
public int read(byte[] buffer) throws ProxyCacheException {
return arrayInputStream.read(buffer, 0, buffer.length);
}

@Override
public int length() throws ProxyCacheException {
return data.length;
}

@Override
public void open(int offset) throws ProxyCacheException {
arrayInputStream = new ByteArrayInputStream(data);
arrayInputStream.skip(offset);
}

@Override
public void close() throws ProxyCacheException {
}
}

21 changes: 21 additions & 0 deletions videoCache/src/main/java/com/danikula/videocache/Cache.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.danikula.videocache;

/**
* Cache for proxy.
*
* @author Alexey Danilov (danikula@gmail.com).
*/
public interface Cache {

int available() throws ProxyCacheException;

int read(byte[] buffer, long offset, int length) throws ProxyCacheException;

void append(byte[] data, int length) throws ProxyCacheException;

void close() throws ProxyCacheException;

void complete() throws ProxyCacheException;

boolean isCompleted();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.danikula.videocache;

import java.io.File;

/**
* Listener for cache availability.
*
* @author Egor Makovsky (yahor.makouski@gmail.com)
* @author Alexey Danilov (danikula@gmail.com).
*/
public interface CacheListener {

void onCacheAvailable(File cacheFile, String url, int percentsAvailable);
}
Loading

0 comments on commit d8e556b

Please sign in to comment.