Some fixes

This commit is contained in:
Thomas 2020-12-29 09:55:15 +01:00
parent 4fd8d42d85
commit e475348d39
1 changed files with 19 additions and 3 deletions

View File

@ -100,7 +100,9 @@ import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
import com.google.android.exoplayer2.ui.DefaultTimeBar; import com.google.android.exoplayer2.ui.DefaultTimeBar;
import com.google.android.exoplayer2.ui.PlayerControlView; import com.google.android.exoplayer2.ui.PlayerControlView;
import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DataSpec;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.google.android.exoplayer2.upstream.FileDataSource;
import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoListener; import com.google.android.exoplayer2.video.VideoListener;
@ -251,6 +253,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
@Override @Override
public void onStreamProgress(Torrent torrent, StreamStatus status) { public void onStreamProgress(Torrent torrent, StreamStatus status) {
} }
@Override @Override
@ -1339,9 +1342,22 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
ProgressiveMediaSource videoSource = null; ProgressiveMediaSource videoSource = null;
HlsMediaSource hlsMediaSource = null; HlsMediaSource hlsMediaSource = null;
SingleSampleMediaSource subtitleSource = null; SingleSampleMediaSource subtitleSource = null;
if (video_cache == 0) { DataSource.Factory dataSourceFactory = null;
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(PeertubeActivity.this, if (localTorrentUrl != null) {
Util.getUserAgent(PeertubeActivity.this, null), null); DataSpec dataSpec = new DataSpec(Uri.fromFile(new java.io.File(localTorrentUrl)));
FileDataSource fileDataSource = new FileDataSource();
try {
fileDataSource.open(dataSpec);
} catch (FileDataSource.FileDataSourceException e) {
e.printStackTrace();
}
dataSourceFactory = () -> fileDataSource;
}
if (video_cache == 0 || dataSourceFactory != null) {
if (dataSourceFactory == null) {
dataSourceFactory = new DefaultDataSourceFactory(PeertubeActivity.this,
Util.getUserAgent(PeertubeActivity.this, null), null);
}
if (subtitles != null) { if (subtitles != null) {
MediaItem.Subtitle mediaSubtitle = new MediaItem.Subtitle(subtitles, MimeTypes.TEXT_VTT, lang); MediaItem.Subtitle mediaSubtitle = new MediaItem.Subtitle(subtitles, MimeTypes.TEXT_VTT, lang);