File tree Expand file tree Collapse file tree
owncloud/android/ui/activity Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ import com.nextcloud.client.player.model.file.PlaybackFiles
2929import com.nextcloud.client.player.model.state.PlaybackState
3030import com.nextcloud.client.player.model.state.RepeatMode
3131import com.nextcloud.client.player.util.PeriodicAction
32+ import com.owncloud.android.datamodel.OCFile
3233import kotlinx.coroutines.CoroutineScope
3334import kotlinx.coroutines.Dispatchers
3435import kotlinx.coroutines.SupervisorJob
@@ -209,6 +210,15 @@ class Media3PlaybackModel @Inject constructor(
209210 }
210211 }
211212
213+ override fun stopPlaying (file : OCFile ) {
214+ controller?.run {
215+ val mediaItemIndex = indexOfFirst { it.mediaId == file.localId.toString() }
216+ if (mediaItemIndex >= 0 ) {
217+ release()
218+ }
219+ }
220+ }
221+
212222 private fun onPlaybackUpdate () {
213223 state.ifPresent(modelCompositeListener::onPlaybackUpdate)
214224 }
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import com.nextcloud.client.player.model.file.PlaybackFile
1212import com.nextcloud.client.player.model.file.PlaybackFiles
1313import com.nextcloud.client.player.model.state.PlaybackState
1414import com.nextcloud.client.player.model.state.RepeatMode
15+ import com.owncloud.android.datamodel.OCFile
1516import kotlinx.coroutines.flow.Flow
1617import java.util.Optional
1718
@@ -50,6 +51,8 @@ interface PlaybackModel {
5051
5152 fun switchToFile (file : PlaybackFile )
5253
54+ fun stopPlaying (file : OCFile )
55+
5356 interface Listener {
5457
5558 fun onPlaybackUpdate (state : PlaybackState )
Original file line number Diff line number Diff line change @@ -2106,7 +2106,7 @@ class FileDisplayActivity :
21062106
21072107 if (result.isSuccess) {
21082108 val removedFile = operation.file
2109- tryStopPlaying(removedFile)
2109+ file?. let { playbackModel.stopPlaying(it) }
21102110 val leftFragment = this .leftFragment
21112111
21122112 // check if file is still available, if so do nothing
@@ -2167,10 +2167,6 @@ class FileDisplayActivity :
21672167 }
21682168 }
21692169
2170- private fun tryStopPlaying (file : OCFile ) {
2171- // TODO: STOP PLAYER
2172- }
2173-
21742170 /* *
21752171 * Updates the view associated to the activity after the finish of an operation trying to move a file.
21762172 *
You can’t perform that action at this time.
0 commit comments