Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
178e8eda
Commit
178e8eda
authored
Dec 11, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add "player" library module.
parent
a03940df
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
178 additions
and
0 deletions
+178
-0
build.gradle
player/build.gradle
+33
-0
proguard-rules.pro
player/proguard-rules.pro
+21
-0
AndroidManifest.xml
player/src/main/AndroidManifest.xml
+12
-0
PlayerActivity.kt
...rc/main/java/chat/rocket/android/player/PlayerActivity.kt
+89
-0
activity_player.xml
player/src/main/res/layout/activity_player.xml
+11
-0
strings.xml
player/src/main/res/values/strings.xml
+5
-0
styles.xml
player/src/main/res/values/styles.xml
+7
-0
No files found.
player/build.gradle
0 → 100644
View file @
178e8eda
apply
plugin:
'com.android.library'
apply
plugin:
'kotlin-android'
apply
plugin:
'kotlin-android-extensions'
android
{
compileSdkVersion
versions
.
compileSdk
defaultConfig
{
minSdkVersion
21
targetSdkVersion
versions
.
targetSdk
versionCode
1
versionName
"1.0.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes
{
release
{
minifyEnabled
false
proguardFiles
getDefaultProguardFile
(
'proguard-android.txt'
),
'proguard-rules.pro'
}
}
}
dependencies
{
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
])
implementation
libraries
.
kotlin
implementation
libraries
.
appCompat
implementation
libraries
.
exoPlayer
testImplementation
libraries
.
junit
}
\ No newline at end of file
player/proguard-rules.pro
0 → 100644
View file @
178e8eda
# 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
player/src/main/AndroidManifest.xml
0 → 100644
View file @
178e8eda
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"chat.rocket.android.player"
>
<application>
<activity
android:name=
".PlayerActivity"
android:configChanges=
"keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode"
android:theme=
"@style/PlayerTheme"
/>
</application>
</manifest>
\ No newline at end of file
player/src/main/java/chat/rocket/android/player/PlayerActivity.kt
0 → 100644
View file @
178e8eda
package
chat.rocket.android.player
import
android.net.Uri
import
android.os.Bundle
import
android.support.v7.app.AppCompatActivity
import
android.view.View
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.MediaSource
import
com.google.android.exoplayer2.trackselection.DefaultTrackSelector
import
com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory
import
com.google.android.exoplayer2.util.Util
import
kotlinx.android.synthetic.main.activity_player.*
class
PlayerActivity
:
AppCompatActivity
()
{
private
lateinit
var
player
:
SimpleExoPlayer
private
var
isPlayerInitialized
=
false
private
var
playWhenReady
=
true
private
var
currentWindow
=
0
private
var
playbackPosition
=
0L
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_player
)
}
override
fun
onStart
()
{
super
.
onStart
()
if
(
Util
.
SDK_INT
>
23
)
{
initializePlayer
()
}
}
override
fun
onResume
()
{
super
.
onResume
()
hideSystemUi
()
if
(
Util
.
SDK_INT
<=
23
||
!
isPlayerInitialized
)
{
initializePlayer
()
}
}
override
fun
onPause
()
{
super
.
onPause
()
if
(
Util
.
SDK_INT
<=
23
)
{
releasePlayer
()
}
}
override
fun
onStop
()
{
super
.
onStop
()
if
(
Util
.
SDK_INT
>
23
)
{
releasePlayer
()
}
}
private
fun
initializePlayer
()
{
if
(!
isPlayerInitialized
)
{
player
=
ExoPlayerFactory
.
newSimpleInstance
(
DefaultRenderersFactory
(
this
),
DefaultTrackSelector
(),
DefaultLoadControl
())
player_view
.
player
=
player
player
.
playWhenReady
=
playWhenReady
player
.
seekTo
(
currentWindow
,
playbackPosition
)
isPlayerInitialized
=
true
}
val
uri
=
Uri
.
parse
(
"http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4"
)
val
mediaSource
=
buildMediaSource
(
uri
)
player
.
prepare
(
mediaSource
,
true
,
false
)
}
private
fun
releasePlayer
()
{
if
(
isPlayerInitialized
)
{
playbackPosition
=
player
.
currentPosition
currentWindow
=
player
.
currentWindowIndex
playWhenReady
=
player
.
playWhenReady
player
.
release
()
isPlayerInitialized
=
false
}
}
private
fun
buildMediaSource
(
uri
:
Uri
):
MediaSource
=
ExtractorMediaSource
(
uri
,
DefaultHttpDataSourceFactory
(
"rocket-chat-android-player"
),
DefaultExtractorsFactory
(),
null
,
null
)
private
fun
hideSystemUi
()
{
// Read the docs for detailed explanation: https://developer.android.com/training/basics/firstapp/starting-activity.html and https://developer.android.com/design/patterns/fullscreen.html
player_view
.
systemUiVisibility
=
View
.
SYSTEM_UI_FLAG_FULLSCREEN
or
View
.
SYSTEM_UI_FLAG_HIDE_NAVIGATION
}
}
\ No newline at end of file
player/src/main/res/layout/activity_player.xml
0 → 100644
View file @
178e8eda
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<com.google.android.exoplayer2.ui.SimpleExoPlayerView
android:id=
"@+id/player_view"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
</FrameLayout>
\ No newline at end of file
player/src/main/res/values/strings.xml
0 → 100644
View file @
178e8eda
<resources>
<string
name=
"app_name"
>
Rocket Chat Android Player library
</string>
</resources>
\ No newline at end of file
player/src/main/res/values/styles.xml
0 → 100644
View file @
178e8eda
<resources>
<style
name=
"PlayerTheme"
parent=
"Theme.AppCompat.NoActionBar"
>
<item
name=
"android:windowBackground"
>
@null
</item>
</style>
</resources>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment