Skip to content

Commit

Permalink
fix subtitle not loading issue
Browse files Browse the repository at this point in the history
  • Loading branch information
abdalmoniem committed May 13, 2020
1 parent 80baa70 commit 5c36bc9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import butter.droid.base.ButterApplication;
import butter.droid.base.providers.media.models.Episode;
import butter.droid.base.providers.media.models.Media;
import butter.droid.base.providers.subs.SubsProvider;
import butter.droid.base.torrent.StreamInfo;
import butter.droid.base.utils.LocaleUtils;
import butter.droid.base.utils.PrefUtils;

Expand Down Expand Up @@ -93,13 +95,23 @@ public static void set(String playerName, String playerData) {
* @param location Video location
* @return {@code true} if activity started, {@code false} otherwise
*/
public static boolean start(Media media, String subLanguage, String location) {
public static boolean start(StreamInfo streamInfo, String location) {
Context context = ButterApplication.getAppContext();

Media media = streamInfo.getMedia();

String subLanguage = streamInfo.getSubtitleLanguage();


String[] playerData = PrefUtils.get(context, Prefs.DEFAULT_PLAYER, "").split(DELIMITER);
if (playerData.length > 1) {
Intent intent = new Intent();
if (null != media && media.subtitles != null && media.subtitles.size() > 0 && subLanguage != null && !subLanguage.equals("no-subs")) {
File subsLocation = new File(SubsProvider.getStorageLocation(context), media.videoId + "-" + subLanguage + ".srt");

File subsLocation = new File(SubsProvider.getStorageLocation(context), String.format(Locale.US, "%s (%s) [%s] [WEBRip] [YTS.MX].srt",
media.title,
media.year,
streamInfo.getQuality()));
TorrentStreamServer.getInstance().setStreamSrtSubtitle(subsLocation);
intent.putExtra("subs", new Uri[]{Uri.parse(location.substring(0, location.lastIndexOf('.')) + ".srt")});
intent.putExtra("subs.name", new String[]{LocaleUtils.toLocale(subLanguage).getDisplayLanguage()});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ protected void startPlayerActivity(String location, int resumePosition) {
if (BeamManager.getInstance(mContext).isConnected()) {
BeamPlayerActivity.startActivity(mContext, mStreamInfo, resumePosition);
} else {
mPlayingExternal = DefaultPlayer.start(mStreamInfo.getMedia(), mStreamInfo.getSubtitleLanguage(), location);
mPlayingExternal = DefaultPlayer.start(mStreamInfo, location);
if (!mPlayingExternal) {
VideoPlayerActivity.startActivity(mContext, mStreamInfo, resumePosition);
}
Expand All @@ -252,6 +252,6 @@ protected void startPlayerActivity(String location, int resumePosition) {

@OnClick(R.id.startexternal_button)
public void externalClick(View v) {
DefaultPlayer.start(mStreamInfo.getMedia(), mStreamInfo.getSubtitleLanguage(), mStreamInfo.getVideoLocation());
DefaultPlayer.start(mStreamInfo, mStreamInfo.getVideoLocation());
}
}

0 comments on commit 5c36bc9

Please sign in to comment.