mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 12:09:45 +01:00
save media playback state
Signed-off-by: parneet-guraya <gurayaparneet@gmail.com>
This commit is contained in:
parent
7e07cbd12a
commit
3b557be58f
@ -4,9 +4,11 @@
|
|||||||
* @author Marcel Hibbe
|
* @author Marcel Hibbe
|
||||||
* @author Andy Scherzinger
|
* @author Andy Scherzinger
|
||||||
* @author Ezhil Shanmugham
|
* @author Ezhil Shanmugham
|
||||||
|
* @author Parneet Singh
|
||||||
* Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
|
* Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
|
||||||
* Copyright (C) 2021 Marcel Hibbe <dev@mhibbe.de>
|
* Copyright (C) 2021 Marcel Hibbe <dev@mhibbe.de>
|
||||||
* Copyright (C) 2023 Ezhil Shanmugham <ezhil56x.contact@gmail.com>
|
* Copyright (C) 2023 Ezhil Shanmugham <ezhil56x.contact@gmail.com>
|
||||||
|
* Copyright (c) 2023 Parneet Singh <gurayaparneet@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -53,6 +55,9 @@ class FullScreenMediaActivity : AppCompatActivity(), Player.Listener {
|
|||||||
private lateinit var path: String
|
private lateinit var path: String
|
||||||
private var player: ExoPlayer? = null
|
private var player: ExoPlayer? = null
|
||||||
|
|
||||||
|
private var playWhenReadyState: Boolean = true
|
||||||
|
private var playBackPosition: Long = 0L
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
menuInflater.inflate(R.menu.menu_preview, menu)
|
menuInflater.inflate(R.menu.menu_preview, menu)
|
||||||
return true
|
return true
|
||||||
@ -122,13 +127,7 @@ class FullScreenMediaActivity : AppCompatActivity(), Player.Listener {
|
|||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
initializePlayer()
|
initializePlayer()
|
||||||
|
preparePlayer()
|
||||||
val mediaItem: MediaItem = MediaItem.fromUri(path)
|
|
||||||
player?.let { exoPlayer ->
|
|
||||||
exoPlayer.setMediaItem(mediaItem)
|
|
||||||
exoPlayer.prepare()
|
|
||||||
exoPlayer.play()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
@ -139,14 +138,25 @@ class FullScreenMediaActivity : AppCompatActivity(), Player.Listener {
|
|||||||
private fun initializePlayer() {
|
private fun initializePlayer() {
|
||||||
player = ExoPlayer.Builder(applicationContext).build()
|
player = ExoPlayer.Builder(applicationContext).build()
|
||||||
binding.playerView.player = player
|
binding.playerView.player = player
|
||||||
|
player?.addListener(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun preparePlayer() {
|
||||||
|
val mediaItem: MediaItem = MediaItem.fromUri(path)
|
||||||
player?.let { exoPlayer ->
|
player?.let { exoPlayer ->
|
||||||
exoPlayer.playWhenReady = true
|
exoPlayer.setMediaItem(mediaItem)
|
||||||
exoPlayer.addListener(this)
|
exoPlayer.playWhenReady = playWhenReadyState
|
||||||
|
exoPlayer.seekTo(playBackPosition)
|
||||||
|
exoPlayer.prepare()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun releasePlayer() {
|
private fun releasePlayer() {
|
||||||
player?.release()
|
player?.let { exoPlayer ->
|
||||||
|
playBackPosition = exoPlayer.currentPosition
|
||||||
|
playWhenReadyState = exoPlayer.playWhenReady
|
||||||
|
exoPlayer.release()
|
||||||
|
}
|
||||||
player = null
|
player = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user