Some changes

This commit is contained in:
Thomas 2020-12-29 17:11:36 +01:00
parent 5c27292543
commit 8a8a433023
1 changed files with 22 additions and 23 deletions

View File

@ -257,29 +257,30 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
for (int i = 0; i < torrent.getFileNames().length; i++) {
torrent.getTorrentHandle().renameFile(i, torrent.getFileNames()[0].replaceAll("[^a-zA-Z0-9/.-]", "_"));
}
}
startStream(peertube, torrent.getVideoFile().getAbsolutePath().replaceAll("[^a-zA-Z0-9/.-]", "_"), null, autoPlay, -1, null, null, true);
PlayerControlView controlView = binding.doubleTapPlayerView.findViewById(R.id.exo_controller);
ConstraintLayout torrent_info = controlView.findViewById(R.id.torrent_info);
TextView dowload_rate = controlView.findViewById(R.id.dowload_rate);
TextView upload_rate = controlView.findViewById(R.id.upload_rate);
torrent_info.setVisibility(View.VISIBLE);
startStream(peertube, torrent.getVideoFile().getAbsolutePath().replaceAll("[^a-zA-Z0-9/.-]", "_"), null, autoPlay, -1, null, null, true);
PlayerControlView controlView = binding.doubleTapPlayerView.findViewById(R.id.exo_controller);
ConstraintLayout torrent_info = controlView.findViewById(R.id.torrent_info);
TextView dowload_rate = controlView.findViewById(R.id.dowload_rate);
TextView upload_rate = controlView.findViewById(R.id.upload_rate);
torrent_info.setVisibility(View.VISIBLE);
new Timer().scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
SessionManager sessionManager = torrentStream.getSessionManager();
if (sessionManager != null) {
long upload = sessionManager.uploadRate();
long download = sessionManager.downloadRate();
int seeds = sessionManager.maxActiveSeeds();
runOnUiThread(() -> {
dowload_rate.setText(String.format(" %s", Helper.rateSize(PeertubeActivity.this, download)));
upload_rate.setText(String.format("▲ %s", Helper.rateSize(PeertubeActivity.this, upload)));
});
new Timer().scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
SessionManager sessionManager = torrentStream.getSessionManager();
if (sessionManager != null) {
long upload = sessionManager.uploadRate();
long download = sessionManager.downloadRate();
runOnUiThread(() -> {
dowload_rate.setText(String.format("▼ %s", Helper.rateSize(PeertubeActivity.this, download)));
upload_rate.setText(String.format(" %s", Helper.rateSize(PeertubeActivity.this, upload)));
});
}
}
}
}, 0, 1000);
}, 0, 1000);
} else {
Toasty.error(PeertubeActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
}
}
@ -1381,8 +1382,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
SingleSampleMediaSource subtitleSource = null;
DataSource.Factory dataSourceFactory = null;
if (localTorrentUrl != null) {
java.io.File localFile = new java.io.File(localTorrentUrl);
DataSpec dataSpec = new DataSpec(Uri.fromFile(new java.io.File(localTorrentUrl)));
FileDataSource fileDataSource = new FileDataSource();
try {