summaryrefslogtreecommitdiffstats
path: root/app/src/main/java
diff options
context:
space:
mode:
authorstom79 <tschneider.ac@gmail.com>2019-01-06 14:04:09 +0100
committerstom79 <tschneider.ac@gmail.com>2019-01-06 14:04:09 +0100
commit6cec548123c42c7bcc96e117d3ea8bd1ac91a7a6 (patch)
tree150ffd34ee2289c3f966a31a88c7368b5c87e089 /app/src/main/java
parent51c83dd81a47043b1921427f9b1f1eb20969d4d7 (diff)
Some tests
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/fr/gouv/etalab/mastodon/activities/PeertubeActivity.java34
1 files changed, 33 insertions, 1 deletions
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/PeertubeActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/PeertubeActivity.java
index 018c73262..164284bef 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/PeertubeActivity.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/PeertubeActivity.java
@@ -442,6 +442,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
@Override
public void onStreamError(Torrent torrent, Exception e) {
Log.v(Helper.TAG,"onStreamError");
+ e.printStackTrace();
}
@Override
@@ -640,25 +641,56 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
@Override
public void onClick(DialogInterface dialog, int which) {
String res = arrayAdapter.getItem(which).substring(0, arrayAdapter.getItem(which).length() - 1);
+ Log.v(Helper.TAG,"playerView1: " + playerView);
if( playerView != null) {
loader.setVisibility(View.VISIBLE);
long position = player.getCurrentPosition();
torrentStream.stopStream();
torrentStream.removeListener(torrentListener);
- torrentStream.startStream(peertube.getTorrentUrl(String.format("%s dp",res)));
+
+
+ TorrentOptions torrentOptions = new TorrentOptions.Builder()
+ .saveLocation(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS))
+ .removeFilesAfterStop(true)
+ .build();
+
+
+
+ DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
+ TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
+ trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
+
+ DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getApplicationContext(),
+ Util.getUserAgent(getApplicationContext(), "Mastalab"), null);
+
+ ExtractorMediaSource videoSource = new ExtractorMediaSource.Factory(dataSourceFactory)
+ .createMediaSource(Uri.parse(peertube.getTorrentUrl(null)));
+
+
+ player = ExoPlayerFactory.newSimpleInstance(PeertubeActivity.this, trackSelector);
+ playerView.setPlayer(player);
+ torrentStream = TorrentStream.init(torrentOptions);
+ player.prepare(videoSource);
+ torrentStream.startStream(peertube.getTorrentUrl(res));
+ Log.v(Helper.TAG,"torrentStream1: " + torrentStream);
torrentListener = new TorrentListener() {
@Override
public void onStreamPrepared(Torrent torrent) {
+ Log.v(Helper.TAG,"onStreamPrepared1: " + torrent);
+ resolution.setText(res);
}
@Override
public void onStreamStarted(Torrent torrent) {
+ Log.v(Helper.TAG,"onStreamStarted1: " + torrent);
}
@Override
public void onStreamError(Torrent torrent, Exception e) {
+ Log.v(Helper.TAG,"onStreamError1: " + torrent);
}
@Override
public void onStreamReady(Torrent torrent) {
loader.setVisibility(View.GONE);
+ Log.v(Helper.TAG,"onStreamReady1: " + torrent);
resolution.setText(res);
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getApplicationContext(),
Util.getUserAgent(getApplicationContext(), "Mastalab"), null);