Compare commits
2 Commits
67d6cc43ab
...
1118c877d7
Author | SHA1 | Date |
---|---|---|
Ivan Agosto | 1118c877d7 | |
Ivan Agosto | 8972fdc305 |
|
@ -6,19 +6,28 @@ import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
|
import android.view.View
|
||||||
import androidx.appcompat.app.ActionBarDrawerToggle
|
import androidx.appcompat.app.ActionBarDrawerToggle
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.widget.SearchView
|
import androidx.appcompat.widget.SearchView
|
||||||
import androidx.core.view.GravityCompat
|
import androidx.core.view.GravityCompat
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import androidx.transition.Visibility
|
||||||
import com.google.android.material.navigation.NavigationView
|
import com.google.android.material.navigation.NavigationView
|
||||||
import com.squareup.picasso.Picasso
|
import com.squareup.picasso.Picasso
|
||||||
import kotlinx.android.synthetic.main.activity_main.drawer_layout
|
import kotlinx.android.synthetic.main.activity_main.drawer_layout
|
||||||
import kotlinx.android.synthetic.main.activity_main.nav_view
|
import kotlinx.android.synthetic.main.activity_main.nav_view
|
||||||
import kotlinx.android.synthetic.main.app_bar_main.toolbar
|
import kotlinx.android.synthetic.main.app_bar_main.toolbar
|
||||||
|
import kotlinx.android.synthetic.main.content_main.mini
|
||||||
import kotlinx.android.synthetic.main.content_main.swipeContainer
|
import kotlinx.android.synthetic.main.content_main.swipeContainer
|
||||||
|
import kotlinx.android.synthetic.main.mini_player.mini_play_pause
|
||||||
|
import kotlinx.android.synthetic.main.mini_player.mini_player
|
||||||
|
import kotlinx.android.synthetic.main.mini_player.mini_player_author
|
||||||
|
import kotlinx.android.synthetic.main.mini_player.mini_player_image
|
||||||
|
import kotlinx.android.synthetic.main.mini_player.mini_player_title
|
||||||
import kotlinx.android.synthetic.main.nav_header_main.*
|
import kotlinx.android.synthetic.main.nav_header_main.*
|
||||||
|
import kotlinx.android.synthetic.main.view_video.view.thumb
|
||||||
import org.libre.agosto.p2play.adapters.VideosAdapter
|
import org.libre.agosto.p2play.adapters.VideosAdapter
|
||||||
import org.libre.agosto.p2play.ajax.Videos
|
import org.libre.agosto.p2play.ajax.Videos
|
||||||
import org.libre.agosto.p2play.models.VideoModel
|
import org.libre.agosto.p2play.models.VideoModel
|
||||||
|
@ -62,6 +71,12 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
||||||
this.refresh()
|
this.refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mini_player_image.setOnClickListener { this.resumeVideo() }
|
||||||
|
mini_player_title.setOnClickListener { this.resumeVideo() }
|
||||||
|
mini_player_author.setOnClickListener { this.resumeVideo() }
|
||||||
|
mini.setOnClickListener { this.resumeVideo() }
|
||||||
|
mini_play_pause.setOnClickListener { this.playPausePlayer() }
|
||||||
|
|
||||||
Handler().postDelayed({
|
Handler().postDelayed({
|
||||||
// Title for nav_bar
|
// Title for nav_bar
|
||||||
side_emailTxt?.text = getString(R.string.nav_header_subtitle) + " " + this.packageManager.getPackageInfo(this.packageName, 0).versionName
|
side_emailTxt?.text = getString(R.string.nav_header_subtitle) + " " + this.packageManager.getPackageInfo(this.packageName, 0).versionName
|
||||||
|
@ -348,8 +363,14 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
||||||
super.onResume()
|
super.onResume()
|
||||||
setSideData()
|
setSideData()
|
||||||
|
|
||||||
if (PlaybackSingleton.player != null) {
|
if (PlaybackSingleton.player != null && PlaybackSingleton.player!!.isPlaying) {
|
||||||
PlaybackSingleton.runMediaSession(this)
|
PlaybackSingleton.runMediaSession(this)
|
||||||
|
mini_player_title.text = PlaybackSingleton.video!!.name
|
||||||
|
mini_player_author.text = PlaybackSingleton.video!!.username
|
||||||
|
// Picasso.get().load("https://${ManagerSingleton.url}${PlaybackSingleton.video!!.thumbUrl}").into(mini_player_image.thumb)
|
||||||
|
mini.visibility = View.VISIBLE
|
||||||
|
} else {
|
||||||
|
mini.visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,4 +455,20 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun resumeVideo () {
|
||||||
|
val intent = Intent(this, ReproductorActivity::class.java)
|
||||||
|
intent.putExtra("resume", true)
|
||||||
|
startActivity(intent)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun playPausePlayer () {
|
||||||
|
PlaybackSingleton.player?.let {
|
||||||
|
if (it.isPlaying) {
|
||||||
|
it.stop()
|
||||||
|
} else {
|
||||||
|
it.play()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,7 +151,7 @@ class ReproductorActivity : AppCompatActivity() {
|
||||||
exoPlayer.player = player
|
exoPlayer.player = player
|
||||||
|
|
||||||
println("----- video --------")
|
println("----- video --------")
|
||||||
println(video.streamingData?.playlistUrl)
|
println(videoPlayback.streamingData?.playlistUrl)
|
||||||
|
|
||||||
if (!isResume) {
|
if (!isResume) {
|
||||||
val mediaItem = MediaItem.Builder()
|
val mediaItem = MediaItem.Builder()
|
||||||
|
|
|
@ -78,7 +78,7 @@ class VideoModel(
|
||||||
while (data.hasNext()) {
|
while (data.hasNext()) {
|
||||||
val key2 = data.nextName()
|
val key2 = data.nextName()
|
||||||
when (key2.toString()) {
|
when (key2.toString()) {
|
||||||
"fileDownloadUrl" -> {
|
"fileUrl" -> {
|
||||||
streamingData = StreamingModel()
|
streamingData = StreamingModel()
|
||||||
streamingData!!.playlistUrl = data.nextString()
|
streamingData!!.playlistUrl = data.nextString()
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,9 @@ class VideoModel(
|
||||||
}
|
}
|
||||||
data.endObject()
|
data.endObject()
|
||||||
}
|
}
|
||||||
|
while (data.hasNext()) {
|
||||||
|
data.skipValue()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
data.endArray()
|
data.endArray()
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,16 +16,18 @@ object PlaybackSingleton {
|
||||||
var video: VideoModel? = null
|
var video: VideoModel? = null
|
||||||
private var withMediaSession = false
|
private var withMediaSession = false
|
||||||
|
|
||||||
fun setData(mediaItem: MediaItem, video: VideoModel): ExoPlayer {
|
fun setData(mediaItem: MediaItem, video: VideoModel): ExoPlayer? {
|
||||||
if (this.player!!.isPlaying) {
|
player?.let {
|
||||||
this.player!!.stop()
|
if (it.isPlaying) {
|
||||||
|
it.stop()
|
||||||
|
}
|
||||||
|
it.setMediaItem(mediaItem)
|
||||||
|
// it.prepare()
|
||||||
|
this.video = video
|
||||||
|
return it
|
||||||
}
|
}
|
||||||
this.player!!.setMediaItem(mediaItem)
|
|
||||||
this.player!!.prepare()
|
|
||||||
|
|
||||||
this.video = video
|
return null
|
||||||
|
|
||||||
return this.player!!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun release() {
|
fun release() {
|
||||||
|
@ -41,8 +43,6 @@ object PlaybackSingleton {
|
||||||
controllerFuture.addListener(
|
controllerFuture.addListener(
|
||||||
{
|
{
|
||||||
val med = controllerFuture.get()
|
val med = controllerFuture.get()
|
||||||
Log.d("is running", med.isPlaying.toString())
|
|
||||||
Log.d("session", med.currentMediaItem?.localConfiguration?.uri.toString())
|
|
||||||
},
|
},
|
||||||
MoreExecutors.directExecutor(),
|
MoreExecutors.directExecutor(),
|
||||||
)
|
)
|
||||||
|
|
|
@ -379,4 +379,5 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -25,4 +25,18 @@
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/mini"
|
||||||
|
layout="@layout/mini_player"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -0,0 +1,59 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="#fff"
|
||||||
|
android:elevation="5dp"
|
||||||
|
android:clickable="true"
|
||||||
|
android:id="@+id/mini_player">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/mini_player_image"
|
||||||
|
android:layout_width="60dp"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:srcCompat="@drawable/default_avatar"
|
||||||
|
tools:srcCompat="@drawable/default_avatar" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/mini_player_title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="12dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:text="Video"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/mini_player_image"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/mini_player_author"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="12dp"
|
||||||
|
android:layout_marginBottom="4dp"
|
||||||
|
android:text="Author"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/mini_player_image" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/mini_play_pause"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:adjustViewBounds="false"
|
||||||
|
android:contentDescription="@string/likeBtn"
|
||||||
|
android:cropToPadding="false"
|
||||||
|
android:scaleType="center"
|
||||||
|
android:visibility="visible"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:srcCompat="@drawable/ic_pause_24"
|
||||||
|
app:tint="@color/colorAccent" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue