@@ -71,7 +71,6 @@ import com.nextcloud.client.jobs.folderDownload.FolderDownloadEventBroadcaster
7171import com.nextcloud.client.jobs.upload.FileUploadEventBroadcaster
7272import com.nextcloud.client.jobs.upload.FileUploadHelper
7373import com.nextcloud.client.jobs.upload.FileUploadWorker
74- import com.nextcloud.client.media.PlayerServiceConnection
7574import com.nextcloud.client.network.ClientFactory.CreationException
7675import com.nextcloud.client.player.ui.PlayerLauncher
7776import com.nextcloud.client.preferences.AppPreferences
@@ -143,7 +142,6 @@ import com.owncloud.android.ui.interfaces.TransactionInterface
143142import com.owncloud.android.ui.navigation.NavigatorScreen
144143import com.owncloud.android.ui.preview.PreviewImageActivity
145144import com.owncloud.android.ui.preview.PreviewImageFragment
146- import com.owncloud.android.ui.preview.PreviewMediaActivity
147145import com.owncloud.android.ui.preview.PreviewMediaFragment
148146import com.owncloud.android.ui.preview.PreviewMediaFragment.Companion.newInstance
149147import com.owncloud.android.ui.preview.PreviewTextFileFragment
@@ -223,7 +221,6 @@ class FileDisplayActivity :
223221 private var searchOpen = false
224222
225223 private var searchView: SearchView ? = null
226- private var mPlayerConnection: PlayerServiceConnection ? = null
227224 private var lastDisplayedAccountName: String? = null
228225
229226 @Inject
@@ -295,10 +292,7 @@ class FileDisplayActivity :
295292 showSortListGroup(savedInstanceState.getBoolean(KEY_IS_SORT_GROUP_VISIBLE ))
296293 }
297294
298- mPlayerConnection = PlayerServiceConnection (this )
299-
300295 checkStoragePath()
301-
302296 observeWorkerState()
303297 startMetadataSyncForRoot()
304298 handleBackPress()
@@ -866,14 +860,17 @@ class FileDisplayActivity :
866860 }
867861 }
868862
863+ fun canBePreviewed (file : OCFile ? ): Boolean =
864+ file != null && (MimeTypeUtil .isAudio(file) || MimeTypeUtil .isVideo(file))
865+
869866 private fun tryStartWaitingPreview (success : Boolean ): Boolean {
870867 if (! success) return false
871868
872869 mWaitingToPreview = mWaitingToPreview?.fileId?.let { storageManager.getFileById(it) }
873870 val file = mWaitingToPreview ? : return false
874871
875872 return when {
876- PreviewMediaActivity . canBePreviewed(file) -> {
873+ canBePreviewed(file) -> {
877874 startMediaPreview(file, 0 , true , true , true , true )
878875 true
879876 }
@@ -2039,7 +2036,7 @@ class FileDisplayActivity :
20392036 } else if (PreviewTextFileFragment .canBePreviewed(file)) {
20402037 setFabVisible?.onComplete(false )
20412038 startTextPreview(file, false )
2042- } else if (PreviewMediaActivity . Companion . canBePreviewed(file)) {
2039+ } else if (canBePreviewed(file)) {
20432040 setFabVisible?.onComplete(false )
20442041 startMediaPreview(file, 0 , true , true , false , true )
20452042 } else {
@@ -2181,7 +2178,7 @@ class FileDisplayActivity :
21812178
21822179 if (result.isSuccess) {
21832180 val removedFile = operation.file
2184- tryStopPlaying(removedFile)
2181+ file?. let { playbackModel.stopPlaying(it) }
21852182 val leftFragment = this .leftFragment
21862183
21872184 // check if file is still available, if so do nothing
@@ -2299,13 +2296,6 @@ class FileDisplayActivity :
22992296 }
23002297 }
23012298
2302- private fun tryStopPlaying (file : OCFile ) {
2303- // placeholder for stop-on-delete future code
2304- if (mPlayerConnection != null && MimeTypeUtil .isAudio(file) && mPlayerConnection?.isPlaying() == true ) {
2305- mPlayerConnection?.stop(file)
2306- }
2307- }
2308-
23092299 /* *
23102300 * Updates the view associated to the activity after the finish of an operation trying to move a file.
23112301 *
0 commit comments