Added another activity to test torrent video playing
This commit is contained in:
parent
57111a7b5b
commit
32c563483e
@ -43,6 +43,7 @@ dependencies {
|
|||||||
|
|
||||||
implementation 'com.blackboardtheory:android-iconify-fontawesome:3.0.1-SNAPSHOT'
|
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'
|
implementation 'com.android.support:support-v4:27.1.0'
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
|
@ -25,12 +25,16 @@
|
|||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.LoginActivity"
|
android:name=".activity.LoginActivity"
|
||||||
android:label="@string/title_activity_login"></activity>
|
android:label="@string/title_activity_login" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.VideoPlayActivity"
|
android:name=".activity.VideoPlayActivity"
|
||||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||||
android:label="@string/title_activity_vide_play"
|
android:label="@string/title_activity_vide_play"
|
||||||
android:theme="@style/FullscreenTheme"></activity>
|
android:theme="@style/FullscreenTheme" />
|
||||||
|
<activity
|
||||||
|
android:name=".activity.TorrentVideoPlayActivity"
|
||||||
|
android:label="@string/title_activity_torrent_video_play"
|
||||||
|
android:theme="@style/AppTheme"></activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
@ -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<Video> call = service.getVideoData(videoID);
|
||||||
|
|
||||||
|
call.enqueue(new Callback<Video>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(@NonNull Call<Video> call, @NonNull Response<Video> response) {
|
||||||
|
|
||||||
|
Toast.makeText(TorrentVideoPlayActivity.this, response.body().getDescription(), Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
|
// response.body().getFiles()
|
||||||
|
// TorrentOptions torrentOptions = new TorrentOptions.Builder()
|
||||||
|
// .removeFilesAfterStop(true)
|
||||||
|
// .build();
|
||||||
|
//
|
||||||
|
// TorrentStream torrentStream = TorrentStream.init(torrentOptions);
|
||||||
|
// torrentStream.startStream("https://butterpoject.org/test.torrent");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Call<Video> call, @NonNull Throwable t) {
|
||||||
|
Log.wtf("err", t.fillInStackTrace());
|
||||||
|
Toast.makeText(TorrentVideoPlayActivity.this, "Something went wrong...Please try later!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -209,7 +209,7 @@ public class VideoListActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
GetVideoDataService service = RetrofitInstance.getRetrofitInstance(apiBaseURL + "/api/v1/").create(GetVideoDataService.class);
|
GetVideoDataService service = RetrofitInstance.getRetrofitInstance(apiBaseURL + "/api/v1/").create(GetVideoDataService.class);
|
||||||
|
|
||||||
Call<VideoList> call = service.getVideoData(start, count, sort);
|
Call<VideoList> call = service.getVideosData(start, count, sort);
|
||||||
|
|
||||||
/*Log the URL called*/
|
/*Log the URL called*/
|
||||||
Log.d("URL Called", call.request().url() + "");
|
Log.d("URL Called", call.request().url() + "");
|
||||||
|
@ -16,6 +16,7 @@ import android.widget.TextView;
|
|||||||
import com.squareup.picasso.Picasso;
|
import com.squareup.picasso.Picasso;
|
||||||
|
|
||||||
import net.schueller.peertube.R;
|
import net.schueller.peertube.R;
|
||||||
|
import net.schueller.peertube.activity.TorrentVideoPlayActivity;
|
||||||
import net.schueller.peertube.activity.VideoPlayActivity;
|
import net.schueller.peertube.activity.VideoPlayActivity;
|
||||||
import net.schueller.peertube.model.Video;
|
import net.schueller.peertube.model.Video;
|
||||||
|
|
||||||
@ -71,7 +72,7 @@ public class VideoAdapter extends RecyclerView.Adapter<VideoAdapter.VideoViewHol
|
|||||||
|
|
||||||
// Log.v("VideoAdapter", "click: " + videoList.get(position).getName());
|
// Log.v("VideoAdapter", "click: " + videoList.get(position).getName());
|
||||||
|
|
||||||
Intent intent = new Intent(context, VideoPlayActivity.class);
|
Intent intent = new Intent(context, TorrentVideoPlayActivity.class);
|
||||||
intent.putExtra(EXTRA_VIDEOID, videoList.get(position).getUuid());
|
intent.putExtra(EXTRA_VIDEOID, videoList.get(position).getUuid());
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
|
||||||
|
@ -1,16 +1,23 @@
|
|||||||
package net.schueller.peertube.network;
|
package net.schueller.peertube.network;
|
||||||
|
|
||||||
|
import net.schueller.peertube.model.Video;
|
||||||
import net.schueller.peertube.model.VideoList;
|
import net.schueller.peertube.model.VideoList;
|
||||||
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.http.GET;
|
import retrofit2.http.GET;
|
||||||
|
import retrofit2.http.Path;
|
||||||
import retrofit2.http.Query;
|
import retrofit2.http.Query;
|
||||||
|
|
||||||
public interface GetVideoDataService {
|
public interface GetVideoDataService {
|
||||||
@GET("videos/")
|
@GET("videos/")
|
||||||
Call<VideoList> getVideoData(
|
Call<VideoList> getVideosData(
|
||||||
@Query("start") int start,
|
@Query("start") int start,
|
||||||
@Query("count") int count,
|
@Query("count") int count,
|
||||||
@Query("sort") String sort
|
@Query("sort") String sort
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@GET("videos/{id}")
|
||||||
|
Call<Video> getVideoData(
|
||||||
|
@Path(value = "id", encoded = true) String id
|
||||||
|
);
|
||||||
}
|
}
|
33
app/src/main/res/layout/activity_torrent_video_play.xml
Normal file
33
app/src/main/res/layout/activity_torrent_video_play.xml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context="net.schueller.peertube.activity.TorrentVideoPlayActivity">
|
||||||
|
|
||||||
|
<android.support.design.widget.AppBarLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
|
||||||
|
<android.support.v7.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||||
|
|
||||||
|
</android.support.design.widget.AppBarLayout>
|
||||||
|
|
||||||
|
<include layout="@layout/content_torrent_video_play" />
|
||||||
|
|
||||||
|
<android.support.design.widget.FloatingActionButton
|
||||||
|
android:id="@+id/fab"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_margin="@dimen/fab_margin"
|
||||||
|
app:srcCompat="@android:drawable/ic_dialog_email" />
|
||||||
|
|
||||||
|
</android.support.design.widget.CoordinatorLayout>
|
11
app/src/main/res/layout/content_torrent_video_play.xml
Normal file
11
app/src/main/res/layout/content_torrent_video_play.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
|
tools:context="net.schueller.peertube.activity.TorrentVideoPlayActivity"
|
||||||
|
tools:showIn="@layout/activity_torrent_video_play">
|
||||||
|
|
||||||
|
</android.support.constraint.ConstraintLayout>
|
@ -2,4 +2,5 @@
|
|||||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||||
|
<dimen name="fab_margin">16dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -26,5 +26,6 @@
|
|||||||
|
|
||||||
<string name="api_base_url" formatted="false">https://troll.tv</string>
|
<string name="api_base_url" formatted="false">https://troll.tv</string>
|
||||||
<string name="api_url_key_key">api_base_url</string>
|
<string name="api_url_key_key">api_base_url</string>
|
||||||
|
<string name="title_activity_torrent_video_play">TorrentVideoPlayActivity</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -19,4 +19,8 @@
|
|||||||
<item name="android:background">@color/black_overlay</item>
|
<item name="android:background">@color/black_overlay</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||||
|
|
||||||
|
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -20,9 +20,8 @@ allprojects {
|
|||||||
google()
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven {
|
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
|
||||||
url 'https://oss.sonatype.org/content/repositories/snapshots'
|
maven { url 'https://jitpack.io' }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user