From 8a8a433023314e2c52931e849ee299e4487bc369 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 29 Dec 2020 17:11:36 +0100 Subject: [PATCH] Some changes --- .../fedilab/fedilabtube/PeertubeActivity.java | 45 +++++++++---------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java index 7dee14c..9e84c86 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java @@ -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 {