google / google/ExoPlayer

Support LRC (LyRiCs) subtitle format

Open
#3,938 4 comments 0 reactions 1 assignee Assigned to @icbaker View on GitHub
enhancement low priority
Dominant language
Java
Stars
21.9k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Hi, everyone, recently,

I use Exoplayer play mp4 files and attach subtitle file with .srt extension file.

And I did it.

Now, I wanna play mp3 file and attach subtitle file with .lrc extension file.

I don't have any idea to attach .lrc subtitle file.

This is the [lrc definision](https://en.wikipedia.org/wiki/LRC_(file_format)).

I know the following code implementing side-loading subtitle and produce MediaResource, and this
is for mp4 with .srt subtitle file.

```java
MediaSource contentMediaSource =
buildMediaSource(Uri.parse(mediaUrl), /* handler= */ null, /* listener= */ null);

Format format = Format.createTextSampleFormat(null, MimeTypes.APPLICATION_SUBRIP, Format.NO_VALUE, "en");

Uri subtitleUri = Uri.parse(subtitleUrl);
MediaSource subtitleMediaSource = new SingleSampleMediaSource.Factory(okHttpDataSourceFactory)
.createMediaSource(subtitleUri, format, C.TIME_UNSET);

mediaSource = new MergingMediaSource(contentMediaSource, subtitleMediaSource);
player.prepare(mediaSource);
```

I can get subtitle change from the following code.
```java
player.addTextOutput(listener);
```
The textOutput have Cue object.

The ultimately object is I wanna play mp3 music file and attach .lrc extension subtitle file, and the

lyric(TextView) can show the hover color representing the singer is singing in this lyric.

But the ```MimeTypes.APPLICATION_SUBRIP``` is not proper for implementation .lrc extension file.

Is there any thought to solve this question? Maybe it's a enhancement I think.

the mp3 file is here: [a song](https://drive.google.com/uc?authuser=0&id=13Z06ZMr7KAYOLvA3H_vV3B8U48uWeLCX&export=download)
the srt file format is: [srt file](https://drive.google.com/uc?authuser=0&id=1vnmAnSF2Ye8so1k8-JklUeIauPO_JyY9&export=download)
the lrc file format is: [lrc file](https://drive.google.com/uc?authuser=0&id=1OopEmHNAtlXR5GldL1oVZwrd3k0RNnnT&export=download)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.