|
@@ -64,7 +64,6 @@ import com.nextcloud.client.jobs.download.FileDownloadHelper
|
|
import com.nextcloud.client.media.BackgroundPlayerService
|
|
import com.nextcloud.client.media.BackgroundPlayerService
|
|
import com.nextcloud.client.media.ErrorFormat
|
|
import com.nextcloud.client.media.ErrorFormat
|
|
import com.nextcloud.client.media.ExoplayerListener
|
|
import com.nextcloud.client.media.ExoplayerListener
|
|
-import com.nextcloud.client.media.ExoplayerListener.Companion
|
|
|
|
import com.nextcloud.client.media.NextcloudExoPlayer.createNextcloudExoplayer
|
|
import com.nextcloud.client.media.NextcloudExoPlayer.createNextcloudExoplayer
|
|
import com.nextcloud.client.network.ClientFactory
|
|
import com.nextcloud.client.network.ClientFactory
|
|
import com.nextcloud.client.network.ClientFactory.CreationException
|
|
import com.nextcloud.client.network.ClientFactory.CreationException
|
|
@@ -111,6 +110,7 @@ import javax.inject.Inject
|
|
* instantiation too.
|
|
* instantiation too.
|
|
*/
|
|
*/
|
|
@Suppress("TooManyFunctions")
|
|
@Suppress("TooManyFunctions")
|
|
|
|
+@OptIn(UnstableApi::class)
|
|
class PreviewMediaActivity :
|
|
class PreviewMediaActivity :
|
|
FileActivity(),
|
|
FileActivity(),
|
|
FileFragment.ContainerActivity,
|
|
FileFragment.ContainerActivity,
|
|
@@ -144,7 +144,6 @@ class PreviewMediaActivity :
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
super.onCreate(savedInstanceState)
|
|
|
|
|
|
-
|
|
|
|
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.O) {
|
|
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.O) {
|
|
setTheme(R.style.Theme_ownCloud_Toolbar)
|
|
setTheme(R.style.Theme_ownCloud_Toolbar)
|
|
}
|
|
}
|
|
@@ -157,10 +156,10 @@ class PreviewMediaActivity :
|
|
applyWindowInsets()
|
|
applyWindowInsets()
|
|
initArguments(savedInstanceState)
|
|
initArguments(savedInstanceState)
|
|
|
|
|
|
- if(MimeTypeUtil.isVideo(file)){
|
|
|
|
|
|
+ if (MimeTypeUtil.isVideo(file)) {
|
|
// release any background media session if exists
|
|
// release any background media session if exists
|
|
sendAudioSessionReleaseBroadcast()
|
|
sendAudioSessionReleaseBroadcast()
|
|
- }else if(MimeTypeUtil.isAudio(file)){
|
|
|
|
|
|
+ } else if (MimeTypeUtil.isAudio(file)) {
|
|
val stopPlayer = Intent(BackgroundPlayerService.STOP_MEDIA_SESSION_BROADCAST_ACTION).apply {
|
|
val stopPlayer = Intent(BackgroundPlayerService.STOP_MEDIA_SESSION_BROADCAST_ACTION).apply {
|
|
setPackage(packageName)
|
|
setPackage(packageName)
|
|
}
|
|
}
|
|
@@ -344,7 +343,7 @@ class PreviewMediaActivity :
|
|
nextcloudClient?.let { client ->
|
|
nextcloudClient?.let { client ->
|
|
handler.post {
|
|
handler.post {
|
|
videoPlayer = createNextcloudExoplayer(this, client)
|
|
videoPlayer = createNextcloudExoplayer(this, client)
|
|
- videoMediaSession = MediaSession.Builder(this,videoPlayer as Player).build()
|
|
|
|
|
|
+ videoMediaSession = MediaSession.Builder(this, videoPlayer as Player).build()
|
|
|
|
|
|
videoPlayer?.let { player ->
|
|
videoPlayer?.let { player ->
|
|
player.addListener(
|
|
player.addListener(
|
|
@@ -386,13 +385,14 @@ class PreviewMediaActivity :
|
|
playAudio()
|
|
playAudio()
|
|
binding.audioControllerView.setMediaPlayer(audioMediaController)
|
|
binding.audioControllerView.setMediaPlayer(audioMediaController)
|
|
} catch (e: Exception) {
|
|
} catch (e: Exception) {
|
|
- Log_OC.e(TAG,"exception raised while getting the media controller ${e.message}")
|
|
|
|
|
|
+ Log_OC.e(TAG, "exception raised while getting the media controller ${e.message}")
|
|
}
|
|
}
|
|
},
|
|
},
|
|
MoreExecutors.directExecutor()
|
|
MoreExecutors.directExecutor()
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Suppress("TooGenericExceptionCaught")
|
|
private fun playAudio() {
|
|
private fun playAudio() {
|
|
if (file.isDown) {
|
|
if (file.isDown) {
|
|
prepareAudioPlayer(file.storageUri)
|
|
prepareAudioPlayer(file.storageUri)
|
|
@@ -400,7 +400,7 @@ class PreviewMediaActivity :
|
|
try {
|
|
try {
|
|
LoadStreamUrl(this, user, clientFactory).execute(file.localId)
|
|
LoadStreamUrl(this, user, clientFactory).execute(file.localId)
|
|
} catch (e: Exception) {
|
|
} catch (e: Exception) {
|
|
- Log_OC.e(TAG, "Loading stream url not possible: $e")
|
|
|
|
|
|
+ Log_OC.e(TAG, "Loading stream url for Audio not possible: $e")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -434,7 +434,7 @@ class PreviewMediaActivity :
|
|
MaterialAlertDialogBuilder(this@PreviewMediaActivity)
|
|
MaterialAlertDialogBuilder(this@PreviewMediaActivity)
|
|
.setMessage(message)
|
|
.setMessage(message)
|
|
.setPositiveButton(R.string.common_ok) { _: DialogInterface?, _: Int ->
|
|
.setPositiveButton(R.string.common_ok) { _: DialogInterface?, _: Int ->
|
|
- audioPlayer.seekToDefaultPosition()
|
|
|
|
|
|
+ audioPlayer.seekToDefaultPosition()
|
|
audioPlayer.pause()
|
|
audioPlayer.pause()
|
|
}
|
|
}
|
|
.setCancelable(false)
|
|
.setCancelable(false)
|
|
@@ -468,7 +468,6 @@ class PreviewMediaActivity :
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- @OptIn(markerClass = [UnstableApi::class])
|
|
|
|
private fun applyWindowInsets() {
|
|
private fun applyWindowInsets() {
|
|
val playerView = binding.exoplayerView
|
|
val playerView = binding.exoplayerView
|
|
val exoControls = playerView.findViewById<FrameLayout>(R.id.exo_bottom_bar)
|
|
val exoControls = playerView.findViewById<FrameLayout>(R.id.exo_bottom_bar)
|
|
@@ -497,7 +496,6 @@ class PreviewMediaActivity :
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- @OptIn(UnstableApi::class)
|
|
|
|
private fun setupVideoView() {
|
|
private fun setupVideoView() {
|
|
initWindowInsetsController()
|
|
initWindowInsetsController()
|
|
val type = WindowInsetsCompat.Type.systemBars()
|
|
val type = WindowInsetsCompat.Type.systemBars()
|
|
@@ -692,7 +690,7 @@ class PreviewMediaActivity :
|
|
try {
|
|
try {
|
|
LoadStreamUrl(this, user, clientFactory).execute(file.localId)
|
|
LoadStreamUrl(this, user, clientFactory).execute(file.localId)
|
|
} catch (e: Exception) {
|
|
} catch (e: Exception) {
|
|
- Log_OC.e(TAG, "Loading stream url not possible: $e")
|
|
|
|
|
|
+ Log_OC.e(TAG, "Loading stream url for Video not possible: $e")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -770,7 +768,7 @@ class PreviewMediaActivity :
|
|
}
|
|
}
|
|
|
|
|
|
override fun onDestroy() {
|
|
override fun onDestroy() {
|
|
- mediaControllerFuture?.let {MediaController.releaseFuture(it)}
|
|
|
|
|
|
+ mediaControllerFuture?.let { MediaController.releaseFuture(it) }
|
|
super.onDestroy()
|
|
super.onDestroy()
|
|
|
|
|
|
Log_OC.v(TAG, "onDestroy")
|
|
Log_OC.v(TAG, "onDestroy")
|