Skip to content

Commit

Permalink
Merge pull request AbedElazizShe#26 from Goooler/master
Browse files Browse the repository at this point in the history
update gradle & add annotations & correct deprecated methods
  • Loading branch information
AbedElazizShe authored Aug 16, 2020
2 parents 343314d + 9de8412 commit 229bea4
Show file tree
Hide file tree
Showing 21 changed files with 113 additions and 91 deletions.
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ VideoCompressor.start(
### Java

```java
VideoCompressor.INSTANCE.start(path, desFile.path, new CompressionListener() {
VideoCompressor.start(path, desFile.path, new CompressionListener() {
@Override
public void onStart() {
// Compression start
Expand Down Expand Up @@ -141,7 +141,6 @@ VideoCompressor.start(
// On Cancelled
}
}, VideoQuality.MEDIUM, false, false);

```

## Common issues
Expand Down
21 changes: 12 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 29
compileSdkVersion 30
defaultConfig {
applicationId "com.abedelazizshe.lightcompressor"
minSdkVersion 21
targetSdkVersion 29
targetSdkVersion 28
versionCode 1
versionName "1.0.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':lightcompressor')

implementation "org.jetbrains.kotlin:kotlin-stdlib:${project.kotlin}"
implementation "androidx.appcompat:appcompat:1.1.0"
implementation "androidx.appcompat:appcompat:${project.appCompat}"
implementation "androidx.core:core-ktx:${project.androidX}"
implementation "androidx.constraintlayout:constraintlayout:${project.constraintlayout}"
implementation "com.google.android.material:material:${project.material}"
Expand All @@ -36,8 +41,6 @@ dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:${project.coroutines}"
kapt "com.github.bumptech.glide:compiler:${project.glide}"
implementation "com.google.android.exoplayer:exoplayer:${project.exoPlayer}"
implementation project(':lightcompressor')

testImplementation "junit:junit:${project.junit}"
androidTestImplementation "androidx.test.ext:junit:${project.testJunit}"
androidTestImplementation "androidx.test.espresso:espresso-core:${project.espresso}"
Expand Down
21 changes: 0 additions & 21 deletions app/proguard-rules.pro

This file was deleted.

6 changes: 2 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
package="com.abedelazizshe.lightcompressor">

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

<application
android:allowBackup="true"
Expand All @@ -15,7 +13,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
<activity android:name=".VideoPlayerActivity" />
<activity
android:name=".MainActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.google.android.exoplayer2.DefaultLoadControl
import com.google.android.exoplayer2.DefaultRenderersFactory
import com.google.android.exoplayer2.ExoPlayerFactory
import com.google.android.exoplayer2.SimpleExoPlayer
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory
import com.google.android.exoplayer2.source.ExtractorMediaSource
import com.google.android.exoplayer2.source.ProgressiveMediaSource
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory
import com.google.android.exoplayer2.util.Util
Expand All @@ -24,12 +22,12 @@ import java.io.File
class VideoPlayerActivity : AppCompatActivity() {

private lateinit var exoPlayer: SimpleExoPlayer
private lateinit var uri: String
private var uri = ""

companion object {
fun start(activity: Activity, uri: String) {
val intent = Intent(activity, VideoPlayerActivity::class.java)
intent.putExtra("uri", uri)
.putExtra("uri", uri)
activity.startActivity(intent)
}
}
Expand All @@ -38,32 +36,29 @@ class VideoPlayerActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_video_player)

if (intent != null) {
val bundle: Bundle = intent.extras!!
uri = bundle.getString("uri", "")
intent?.extras?.let {
uri = it.getString("uri", "")
}

initializePlayer()

}

private fun initializePlayer() {

val trackSelector = DefaultTrackSelector()
val trackSelector = DefaultTrackSelector(this)
val loadControl = DefaultLoadControl()
val rendererFactory = DefaultRenderersFactory(this)

exoPlayer = ExoPlayerFactory.newSimpleInstance(
rendererFactory, trackSelector, loadControl
)
exoPlayer = SimpleExoPlayer.Builder(this, rendererFactory)
.setLoadControl(loadControl)
.setTrackSelector(trackSelector)
.build()
}

private fun play(uri: Uri) {

val userAgent = Util.getUserAgent(this, getString(R.string.app_name))
val mediaSource = ExtractorMediaSource
val mediaSource = ProgressiveMediaSource
.Factory(DefaultDataSourceFactory(this, userAgent))
.setExtractorsFactory(DefaultExtractorsFactory())
.createMediaSource(uri)

ep_video_view.player = exoPlayer
Expand All @@ -88,5 +83,4 @@ class VideoPlayerActivity : AppCompatActivity() {
exoPlayer.stop()
exoPlayer.release()
}

}
7 changes: 3 additions & 4 deletions app/src/main/res/layout/activity_video_player.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:background="@color/colorBlack"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="@color/colorBlack">

<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/ep_video_view"
Expand Down
7 changes: 3 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ buildscript {
repositories {
google()
jcenter()

}
dependencies {
classpath "com.android.tools.build:gradle:$build_gradle"
Expand All @@ -33,10 +32,10 @@ ext {
espresso = "3.2.0"
androidX = "1.3.1"
constraintlayout = "1.1.3"
material = "1.1.0-alpha07"
material = "1.2.0"
glide = "4.11.0"
exoPlayer = "2.8.4"
exoPlayer = "2.11.7"
coroutines = "1.3.8"
testJunit = "1.1.1"
appCompat = "1.1.0"
appCompat = "1.2.0"
}
8 changes: 3 additions & 5 deletions lightcompressor/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 29


defaultConfig {
minSdkVersion 21
targetSdkVersion 29
Expand All @@ -21,15 +20,14 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib:${project.kotlin}"
implementation "androidx.core:core-ktx:${project.androidX}"
implementation files('libs/isoparser-1.0.6.jar')
implementation files('libs/aspectjrt-1.7.3.jar')
implementation "org.jetbrains.kotlin:kotlin-stdlib:${project.kotlin}"
implementation "androidx.core:core-ktx:${project.androidX}"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:${project.coroutines}"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:${project.coroutines}"
testImplementation "junit:junit:${project.junit}"
Expand Down
3 changes: 1 addition & 2 deletions lightcompressor/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.abedelazizshe.lightcompressorlibrary" />
<manifest package="com.abedelazizshe.lightcompressorlibrary" />
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
package com.abedelazizshe.lightcompressorlibrary

import androidx.annotation.MainThread
import androidx.annotation.WorkerThread

/**
* Created by AbedElaziz Shehadeh on 27 Jan, 2020
* [email protected]
*/
interface CompressionListener {
@MainThread
fun onStart()

@MainThread
fun onSuccess()

@MainThread
fun onFailure(failureMessage: String)

@WorkerThread
fun onProgress(percent: Float)

@WorkerThread
fun onCancelled()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package com.abedelazizshe.lightcompressorlibrary
import android.media.*
import android.util.Log
import java.io.File
import java.lang.Exception
import java.lang.IllegalArgumentException
import java.nio.ByteBuffer
import kotlin.math.roundToInt

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,22 @@ private void eglSetup() {
throw new RuntimeException("unable to find RGB888+recordable ES2 EGL config");
}

int[] attrib_list = {
int[] attrs = {
EGL14.EGL_CONTEXT_CLIENT_VERSION, 2,
EGL14.EGL_NONE
};

mEGLContext = EGL14.eglCreateContext(mEGLDisplay, configs[0], EGL14.EGL_NO_CONTEXT, attrib_list, 0);
mEGLContext = EGL14.eglCreateContext(mEGLDisplay, configs[0], EGL14.EGL_NO_CONTEXT, attrs, 0);
checkEglError("eglCreateContext");
if (mEGLContext == null) {
throw new RuntimeException("null context");
}

int[] surfaceAttribs = {
int[] surfaceAttrs = {
EGL14.EGL_NONE
};
mEGLSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, configs[0], mSurface,
surfaceAttribs, 0);
surfaceAttrs, 0);
checkEglError("eglCreateWindowSurface");
if (mEGLSurface == null) {
throw new RuntimeException("surface was null");
Expand Down
Loading

0 comments on commit 229bea4

Please sign in to comment.