Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to androidx-media3 video player #3857

Merged
merged 46 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
03846fc
Squash exoplayer draft branch. Uses exoplayer 2.18.3. Basic video pla…
mcclure Feb 22, 2023
eb85fda
Move exoplayer branch to media3-exoplayer (squash commit)
mcclure Feb 22, 2023
cefb68c
Back out libs.versions.toml changes, upgrade to media3 rc01 and don't…
mcclure Feb 22, 2023
fa7063d
Make player look like media3 branch
mcclure Feb 23, 2023
8530699
Null commit to keep merges clean
mcclure Feb 23, 2023
cca34ad
Remerge develop->media3 branch
mcclure May 9, 2023
6e96576
Upgrade exoplayer 1.0.0-rc01 to 1.0.1
mcclure May 9, 2023
30b8e4f
ktLint
mcclure May 9, 2023
ef0f822
Merge remote-tracking branch 'upstream/pull/3375/head' into media3
nikclayton Jul 15, 2023
1a416ac
Update to newest media3 library version
nikclayton Jul 15, 2023
342002d
Use `by viewBinding`, eliminate `_binding` variable
nikclayton Jul 15, 2023
0010f74
Use OkHttp as the transport for media3
nikclayton Jul 15, 2023
360989e
Additional debug logging for the player
nikclayton Jul 15, 2023
05bf97d
Display playback errors
nikclayton Jul 15, 2023
2cca3e2
Use property access syntax
nikclayton Jul 16, 2023
ef13ab9
More property access syntax
nikclayton Jul 16, 2023
108ffec
Fix bug where the media description was being shown and hidden rapidly
nikclayton Jul 16, 2023
18c59e4
Use the same timeout value (5 seconds) for the player controls and me…
nikclayton Jul 16, 2023
cfcbdea
Remove some dead comments
nikclayton Jul 16, 2023
76d475f
Restore the "Continually display the media description when paused" f…
nikclayton Jul 16, 2023
51509cf
Remove obsolete comments
nikclayton Jul 17, 2023
90e396f
Remove empty onDestroyView
nikclayton Jul 17, 2023
af8045e
Move mediaSourceFactory out of setupMediaView
nikclayton Jul 17, 2023
f4c9e51
Properly release the player where necessary
nikclayton Jul 17, 2023
d30ab95
LIfecycle stuff for API <= 23 and API > 23
nikclayton Jul 17, 2023
d4309e6
Save the seek position when pausing/stopping the fragment, restore it…
nikclayton Jul 17, 2023
557aed5
Remove obsolete comments
nikclayton Jul 17, 2023
dfbf4e2
Move onCreateView and onViewCreated
nikclayton Jul 17, 2023
119f3f7
Show more detailed error messages
nikclayton Jul 18, 2023
400c73f
Rename media3 to androidx-media3
nikclayton Jul 18, 2023
264ac91
Move the controls without needing a custom layout
nikclayton Jul 18, 2023
3ae89bc
ktlint
nikclayton Jul 18, 2023
1596484
Lint
nikclayton Jul 18, 2023
916605a
Move the companion object declaration to the bottom
nikclayton Jul 18, 2023
220248d
Set up the gesture detectors on the video view (which is full screen)…
nikclayton Jul 18, 2023
f4bf23c
ViewMediaFragment does not need to be Injectable
nikclayton Jul 18, 2023
f898ea1
Remove obsolete ExposedPlayPauseVideoView
nikclayton Jul 18, 2023
b28883b
Cleanup
nikclayton Jul 18, 2023
8c400c0
Don't crash if there's no view
nikclayton Jul 18, 2023
ffe0834
Merge remote-tracking branch 'upstream/develop' into media3
nikclayton Jul 19, 2023
668e84b
Set the preview (if it exists) as the media artwork
nikclayton Jul 19, 2023
26aef1a
Fix potential crash when image loading completes after the user hits …
nikclayton Jul 20, 2023
7f026e6
Ignore SyntheticAccessor lint warnings
nikclayton Jul 20, 2023
feb2848
Merge branch 'develop' into media3
nikclayton Jul 20, 2023
89f2a6f
Merge branch 'develop' into media3
nikclayton Jul 26, 2023
5da51cc
Merge branch 'develop' into media3
nikclayton Aug 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ import com.keylesspalace.tusky.pager.SingleImagePagerAdapter
import com.keylesspalace.tusky.util.getTemporaryMediaFilename
import com.keylesspalace.tusky.util.viewBinding
import com.keylesspalace.tusky.viewdata.AttachmentViewData
import dagger.android.DispatchingAndroidInjector
import dagger.android.HasAndroidInjector
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.core.Single
import io.reactivex.rxjava3.schedulers.Schedulers
Expand All @@ -67,10 +69,13 @@ import java.io.FileNotFoundException
import java.io.FileOutputStream
import java.io.IOException
import java.util.Locale
import javax.inject.Inject

typealias ToolbarVisibilityListener = (isVisible: Boolean) -> Unit

class ViewMediaActivity : BaseActivity(), ViewImageFragment.PhotoActionsListener, ViewVideoFragment.VideoActionsListener {
class ViewMediaActivity : BaseActivity(), HasAndroidInjector, ViewImageFragment.PhotoActionsListener, ViewVideoFragment.VideoActionsListener {
@Inject
lateinit var androidInjector: DispatchingAndroidInjector<Any>

private val binding by viewBinding(ActivityViewMediaBinding::inflate)

Expand Down Expand Up @@ -337,6 +342,8 @@ class ViewMediaActivity : BaseActivity(), ViewImageFragment.PhotoActionsListener
shareFile(file, mimeType)
}

override fun androidInjector() = androidInjector

companion object {
private const val EXTRA_ATTACHMENTS = "attachments"
private const val EXTRA_ATTACHMENT_INDEX = "index"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ abstract class ActivitiesModule {
@ContributesAndroidInjector(modules = [FragmentBuildersModule::class])
abstract fun contributesPreferencesActivity(): PreferencesActivity

@ContributesAndroidInjector
@ContributesAndroidInjector(modules = [FragmentBuildersModule::class])
abstract fun contributesViewMediaActivity(): ViewMediaActivity

@ContributesAndroidInjector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,10 @@ import com.keylesspalace.tusky.components.timeline.TimelineFragment
import com.keylesspalace.tusky.components.trending.TrendingFragment
import com.keylesspalace.tusky.components.viewthread.ViewThreadFragment
import com.keylesspalace.tusky.components.viewthread.edits.ViewEditsFragment
import com.keylesspalace.tusky.fragment.ViewVideoFragment
import dagger.Module
import dagger.android.ContributesAndroidInjector

/**
* Created by charlag on 3/24/18.
*/

@Module
abstract class FragmentBuildersModule {
@ContributesAndroidInjector
Expand Down Expand Up @@ -103,4 +100,7 @@ abstract class FragmentBuildersModule {

@ContributesAndroidInjector
abstract fun trendingFragment(): TrendingFragment

@ContributesAndroidInjector
abstract fun viewVideoFragment(): ViewVideoFragment
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ package com.keylesspalace.tusky.fragment

import android.os.Bundle
import android.text.TextUtils
import androidx.annotation.OptIn
import androidx.fragment.app.Fragment
import androidx.media3.common.util.UnstableApi
import com.keylesspalace.tusky.ViewMediaActivity
import com.keylesspalace.tusky.entity.Attachment

Expand Down Expand Up @@ -47,6 +49,7 @@ abstract class ViewMediaFragment : Fragment() {
protected val ARG_SINGLE_IMAGE_URL = "singleImageUrl"

@JvmStatic
@OptIn(UnstableApi::class)
fun newInstance(attachment: Attachment, shouldStartPostponedTransition: Boolean): ViewMediaFragment {
val arguments = Bundle(2)
arguments.putParcelable(ARG_ATTACHMENT, attachment)
Expand Down
Loading