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

[JetStreamCompose] External subtitles not displayed #152

Open
evilsloth opened this issue Feb 10, 2024 · 1 comment
Open

[JetStreamCompose] External subtitles not displayed #152

evilsloth opened this issue Feb 10, 2024 · 1 comment

Comments

@evilsloth
Copy link

evilsloth commented Feb 10, 2024

According to the code, subtitles should be displayed by default if they are defined in movies.json. And in the example there are this subtitles defined for every sample movie:

  {
    "id": "8daa7d22d13a9",
    "videoUri": "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",
    "subtitleUri": "https://thepaciellogroup.github.io/AT-browser-tests/video/subtitles-en.vtt",

and here is the code that loads the subtitles:

    val exoPlayer = rememberExoPlayer(context)
    LaunchedEffect(exoPlayer, movieDetails) {
        exoPlayer.setMediaItem(
            MediaItem.Builder()
                .setUri(movieDetails.videoUri)
                .setSubtitleConfigurations(
                    if (movieDetails.subtitleUri == null) {
                        emptyList()
                    } else {
                        listOf(
                            MediaItem.SubtitleConfiguration.Builder(Uri.parse(movieDetails.subtitleUri))
                                .setMimeType("application/vtt")
                                .setLanguage("en")
                                .setSelectionFlags(C.SELECTION_FLAG_DEFAULT)
                                .build()
                        )
                    }
                ).build()
        )
        exoPlayer.prepare()
    }

But the subtitles are never displayed. Even if we enable default overlay (useController = true), there is no option to enable subtitles there, like it never even loads them.

Is this some exoplayer issue or some problem with using it with compose? I tried to build the sample from the time this code was first added. But it doesn't work either.

@evilsloth
Copy link
Author

Ok, so I finally found a culprit for anyone interested. If you use the default MediaSourceFactory external subtitles start to work fine. Just delete this:

        .setMediaSourceFactory(
            ProgressiveMediaSource.Factory(DefaultDataSource.Factory(context))
        )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant