From 32c563483e2f7f6a2d010880e27c51fa6f9d10bf Mon Sep 17 00:00:00 2001 From: Stefan Schueller Date: Sun, 4 Mar 2018 21:04:32 +0100 Subject: [PATCH] Added another activity to test torrent video playing --- app/build.gradle | 1 + app/src/main/AndroidManifest.xml | 8 +- .../activity/TorrentVideoPlayActivity.java | 89 +++++++++++++++++++ .../peertube/activity/VideoListActivity.java | 2 +- .../peertube/adapter/VideoAdapter.java | 3 +- .../peertube/network/GetVideoDataService.java | 9 +- .../layout/activity_torrent_video_play.xml | 33 +++++++ .../res/layout/content_torrent_video_play.xml | 11 +++ app/src/main/res/values/dimens.xml | 1 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/values/styles.xml | 4 + build.gradle | 5 +- 12 files changed, 159 insertions(+), 8 deletions(-) create mode 100644 app/src/main/java/net/schueller/peertube/activity/TorrentVideoPlayActivity.java create mode 100644 app/src/main/res/layout/activity_torrent_video_play.xml create mode 100644 app/src/main/res/layout/content_torrent_video_play.xml diff --git a/app/build.gradle b/app/build.gradle index 7ae9a98..62fbd80 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -43,6 +43,7 @@ dependencies { implementation 'com.blackboardtheory:android-iconify-fontawesome:3.0.1-SNAPSHOT' + implementation 'com.github.TorrentStream:TorrentStream-Android:2.5.0' implementation 'com.android.support:support-v4:27.1.0' testImplementation 'junit:junit:4.12' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 825e7d4..4b061f6 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -25,12 +25,16 @@ + android:label="@string/title_activity_login" /> + android:theme="@style/FullscreenTheme" /> + \ No newline at end of file diff --git a/app/src/main/java/net/schueller/peertube/activity/TorrentVideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/TorrentVideoPlayActivity.java new file mode 100644 index 0000000..d20c596 --- /dev/null +++ b/app/src/main/java/net/schueller/peertube/activity/TorrentVideoPlayActivity.java @@ -0,0 +1,89 @@ +package net.schueller.peertube.activity; + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.os.Environment; +import android.support.annotation.NonNull; +import android.support.design.widget.FloatingActionButton; +import android.support.design.widget.Snackbar; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.view.View; +import android.widget.Toast; + +import com.github.se_bastiaan.torrentstream.TorrentOptions; +import com.github.se_bastiaan.torrentstream.TorrentStream; + +import net.schueller.peertube.R; +import net.schueller.peertube.model.Video; +import net.schueller.peertube.model.VideoList; +import net.schueller.peertube.network.GetVideoDataService; +import net.schueller.peertube.network.RetrofitInstance; + +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; + +public class TorrentVideoPlayActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_torrent_video_play); + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) + .setAction("Action", null).show(); + } + }); + + // get video ID + Intent intent = getIntent(); + String videoID = intent.getStringExtra(VideoListActivity.EXTRA_VIDEOID); + Log.v("TorrentVideoPlayActivity", "click: " + videoID); + + + // get video details from api + SharedPreferences sharedPref = this.getPreferences(Context.MODE_PRIVATE); + String defaultApiURL = getResources().getString(R.string.api_base_url); + String apiBaseURL = sharedPref.getString(getString(R.string.api_url_key_key), defaultApiURL); + GetVideoDataService service = RetrofitInstance.getRetrofitInstance(apiBaseURL + "/api/v1/").create(GetVideoDataService.class); + + Call