@ -1,3 +1,8 @@
|
|||||||
|
### Version 1.0.23 Tag: v1.0.23 (2019-01-06)
|
||||||
|
* Moved video playback into fragment
|
||||||
|
* Added duration to video list
|
||||||
|
* Cleaned up full screen button and activation
|
||||||
|
|
||||||
### Version 1.0.22 Tag: v1.0.22 (2019-01-05)
|
### Version 1.0.22 Tag: v1.0.22 (2019-01-05)
|
||||||
* Cleaned up like/dislike
|
* Cleaned up like/dislike
|
||||||
* Added video download
|
* Added video download
|
||||||
|
16
README.md
@ -6,9 +6,8 @@
|
|||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img width="250" src="https://raw.githubusercontent.com/sschueller/peertube-android/develop/Screenshot_1545425516.png" alt="screenshot" />
|
<img width="250" src="https://raw.githubusercontent.com/sschueller/peertube-android/develop/Screenshot_1546780555.png" alt="screenshot" />
|
||||||
<img width="250" src="https://raw.githubusercontent.com/sschueller/peertube-android/develop/Screenshot_1545425431.png" alt="screenshot" />
|
<img width="250" src="https://raw.githubusercontent.com/sschueller/peertube-android/develop/Screenshot_1546780637.png" alt="screenshot" />
|
||||||
<img width="250" src="https://raw.githubusercontent.com/sschueller/peertube-android/develop/Screenshot_1545425504.png" alt="screenshot" />
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
## Download
|
## Download
|
||||||
@ -27,16 +26,17 @@ Beta Test on Google Play: https://play.google.com/store/apps/details?id=net.schu
|
|||||||
- [X] Themes / Dark mode
|
- [X] Themes / Dark mode
|
||||||
- [X] Background playback
|
- [X] Background playback
|
||||||
- [X] NSFW Filter option
|
- [X] NSFW Filter option
|
||||||
|
- [X] Authentication / Login
|
||||||
|
- [X] Like/dislike video
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
- [ ] Video Playback via WebRTC
|
- [ ] Video Playback via WebRTC
|
||||||
- [ ] Authentication / Login
|
- [ ] Video overlay play and draggable video window
|
||||||
- [ ] Like/dislike video
|
- [ ] Comment videos
|
||||||
- [ ] Comment video
|
- [ ] Report Videos
|
||||||
|
- [ ] User / Channel Overview Page
|
||||||
- [ ] Unit Tests
|
- [ ] Unit Tests
|
||||||
|
|
||||||
- [ ] Lots more missing at this point...
|
- [ ] Lots more missing at this point...
|
||||||
|
|
||||||
|
|
||||||
|
BIN
Screenshot1.png
Before Width: | Height: | Size: 114 KiB |
BIN
Screenshot2.jpg
Before Width: | Height: | Size: 95 KiB |
Before Width: | Height: | Size: 843 KiB |
Before Width: | Height: | Size: 725 KiB |
Before Width: | Height: | Size: 585 KiB |
BIN
Screenshot_1546780555.png
Normal file
After Width: | Height: | Size: 614 KiB |
BIN
Screenshot_1546780637.png
Normal file
After Width: | Height: | Size: 440 KiB |
@ -6,8 +6,8 @@ android {
|
|||||||
applicationId "net.schueller.peertube"
|
applicationId "net.schueller.peertube"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode 1022
|
versionCode 1023
|
||||||
versionName "1.0.22"
|
versionName "1.0.23"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
ext {
|
ext {
|
||||||
libVersions = [
|
libVersions = [
|
||||||
|
@ -55,7 +55,7 @@ import retrofit2.Response;
|
|||||||
import static net.schueller.peertube.helper.Constants.DEFAULT_THEME;
|
import static net.schueller.peertube.helper.Constants.DEFAULT_THEME;
|
||||||
import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY;
|
import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY;
|
||||||
|
|
||||||
public class AccountActivity extends AppCompatActivity {
|
public class AccountActivity extends CommonActivity {
|
||||||
|
|
||||||
|
|
||||||
private static final String TAG = "AccountActivity";
|
private static final String TAG = "AccountActivity";
|
||||||
@ -104,17 +104,8 @@ public class AccountActivity extends AppCompatActivity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
// Set theme
|
|
||||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
|
|
||||||
setTheme(getResources().getIdentifier(
|
|
||||||
sharedPref.getString(THEME_PREF_KEY, DEFAULT_THEME),
|
|
||||||
"style",
|
|
||||||
getPackageName())
|
|
||||||
);
|
|
||||||
|
|
||||||
setContentView(R.layout.activity_account);
|
setContentView(R.layout.activity_account);
|
||||||
|
|
||||||
|
|
||||||
// Attaching the layout to the toolbar object
|
// Attaching the layout to the toolbar object
|
||||||
Toolbar toolbar = findViewById(R.id.tool_bar_user);
|
Toolbar toolbar = findViewById(R.id.tool_bar_user);
|
||||||
// Setting toolbar as the ActionBar with setSupportActionBar() call
|
// Setting toolbar as the ActionBar with setSupportActionBar() call
|
||||||
|
@ -1,3 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 Stefan Schüller <sschueller@techdroid.com>
|
||||||
|
*
|
||||||
|
* License: GPL-3.0+
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package net.schueller.peertube.activity;
|
package net.schueller.peertube.activity;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
@ -49,7 +49,7 @@ import retrofit2.Response;
|
|||||||
import static net.schueller.peertube.helper.Constants.DEFAULT_THEME;
|
import static net.schueller.peertube.helper.Constants.DEFAULT_THEME;
|
||||||
import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY;
|
import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY;
|
||||||
|
|
||||||
public class LoginActivity extends AppCompatActivity {
|
public class LoginActivity extends CommonActivity {
|
||||||
|
|
||||||
private String TAG = "LoginActivity";
|
private String TAG = "LoginActivity";
|
||||||
|
|
||||||
@ -61,14 +61,6 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
// Set theme
|
|
||||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
|
|
||||||
setTheme(getResources().getIdentifier(
|
|
||||||
sharedPref.getString(THEME_PREF_KEY, DEFAULT_THEME),
|
|
||||||
"style",
|
|
||||||
getPackageName())
|
|
||||||
);
|
|
||||||
|
|
||||||
setContentView(R.layout.activity_login);
|
setContentView(R.layout.activity_login);
|
||||||
|
|
||||||
// bind button click
|
// bind button click
|
||||||
|
@ -32,10 +32,8 @@ import com.google.android.material.bottomnavigation.BottomNavigationView;
|
|||||||
import com.google.android.material.bottomnavigation.LabelVisibilityMode;
|
import com.google.android.material.bottomnavigation.LabelVisibilityMode;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatDelegate;
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.appcompat.widget.SearchView;
|
import androidx.appcompat.widget.SearchView;
|
||||||
@ -68,9 +66,6 @@ import retrofit2.Call;
|
|||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
|
|
||||||
import static net.schueller.peertube.helper.Constants.DEFAULT_THEME;
|
|
||||||
import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY;
|
|
||||||
|
|
||||||
public class VideoListActivity extends CommonActivity {
|
public class VideoListActivity extends CommonActivity {
|
||||||
|
|
||||||
private String TAG = "VideoListActivity";
|
private String TAG = "VideoListActivity";
|
||||||
|
@ -18,105 +18,41 @@
|
|||||||
|
|
||||||
package net.schueller.peertube.activity;
|
package net.schueller.peertube.activity;
|
||||||
|
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.ServiceConnection;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.ActivityInfo;
|
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import android.os.Environment;
|
|
||||||
import android.os.IBinder;
|
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.appcompat.widget.PopupMenu;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.Surface;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.github.se_bastiaan.torrentstream.StreamStatus;
|
import android.view.WindowManager;
|
||||||
import com.github.se_bastiaan.torrentstream.Torrent;
|
import android.widget.FrameLayout;
|
||||||
import com.github.se_bastiaan.torrentstream.TorrentOptions;
|
|
||||||
import com.github.se_bastiaan.torrentstream.TorrentStream;
|
import android.widget.RelativeLayout;
|
||||||
import com.github.se_bastiaan.torrentstream.listeners.TorrentListener;
|
|
||||||
import com.google.android.exoplayer2.Format;
|
|
||||||
import com.google.android.exoplayer2.decoder.DecoderCounters;
|
|
||||||
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
|
||||||
import com.google.android.exoplayer2.ui.PlayerView;
|
|
||||||
import com.google.android.exoplayer2.util.Util;
|
|
||||||
import com.google.android.exoplayer2.video.VideoRendererEventListener;
|
|
||||||
import com.mikepenz.iconics.Iconics;
|
|
||||||
import com.squareup.picasso.Picasso;
|
|
||||||
import net.schueller.peertube.R;
|
import net.schueller.peertube.R;
|
||||||
import net.schueller.peertube.fragment.VideoMetaDataFragment;
|
import net.schueller.peertube.fragment.VideoMetaDataFragment;
|
||||||
import net.schueller.peertube.fragment.VideoOptionsFragment;
|
import net.schueller.peertube.fragment.VideoPlayerFragment;
|
||||||
import net.schueller.peertube.helper.APIUrlHelper;
|
|
||||||
import net.schueller.peertube.helper.MetaDataHelper;
|
|
||||||
import net.schueller.peertube.intents.Intents;
|
|
||||||
import net.schueller.peertube.model.Account;
|
|
||||||
import net.schueller.peertube.model.Avatar;
|
|
||||||
import net.schueller.peertube.model.Video;
|
|
||||||
import net.schueller.peertube.network.GetVideoDataService;
|
|
||||||
import net.schueller.peertube.network.RetrofitInstance;
|
|
||||||
import net.schueller.peertube.service.VideoPlayerService;
|
|
||||||
import retrofit2.Call;
|
|
||||||
import retrofit2.Callback;
|
|
||||||
import retrofit2.Response;
|
|
||||||
|
|
||||||
import static net.schueller.peertube.helper.Constants.BACKGROUND_PLAY_PREF_KEY;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
|
||||||
|
|
||||||
|
//import static net.schueller.peertube.helper.Constants.BACKGROUND_PLAY_PREF_KEY;
|
||||||
import static net.schueller.peertube.helper.Constants.DEFAULT_THEME;
|
import static net.schueller.peertube.helper.Constants.DEFAULT_THEME;
|
||||||
import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY;
|
import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY;
|
||||||
|
|
||||||
public class VideoPlayActivity extends AppCompatActivity implements VideoRendererEventListener {
|
public class VideoPlayActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private static final String TAG = "VideoPlayActivity";
|
private static final String TAG = "VideoPlayActivity";
|
||||||
|
|
||||||
private ProgressBar progressBar;
|
|
||||||
private PlayerView simpleExoPlayerView;
|
|
||||||
private Intent videoPlayerIntent;
|
|
||||||
private Context context = this;
|
|
||||||
private TextView fullscreenButton;
|
|
||||||
private Boolean isFullscreen = false;
|
|
||||||
private TorrentStream torrentStream;
|
|
||||||
boolean mBound = false;
|
|
||||||
VideoPlayerService mService;
|
|
||||||
|
|
||||||
private ServiceConnection mConnection = new ServiceConnection() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onServiceConnected(ComponentName className, IBinder service) {
|
|
||||||
Log.d(TAG, "onServiceConnected");
|
|
||||||
VideoPlayerService.LocalBinder binder = (VideoPlayerService.LocalBinder) service;
|
|
||||||
mService = binder.getService();
|
|
||||||
|
|
||||||
// 2. Create the player
|
|
||||||
simpleExoPlayerView.setPlayer(mService.player);
|
|
||||||
mBound = true;
|
|
||||||
|
|
||||||
loadVideo();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onServiceDisconnected(ComponentName componentName) {
|
|
||||||
Log.d(TAG, "onServiceDisconnected");
|
|
||||||
simpleExoPlayerView.setPlayer(null);
|
|
||||||
mBound = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -132,95 +68,22 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere
|
|||||||
|
|
||||||
setContentView(R.layout.activity_video_play);
|
setContentView(R.layout.activity_video_play);
|
||||||
|
|
||||||
progressBar = findViewById(R.id.progress);
|
// get video ID
|
||||||
progressBar.setMax(100);
|
Intent intent = getIntent();
|
||||||
|
String videoUuid = intent.getStringExtra(VideoListActivity.EXTRA_VIDEOID);
|
||||||
|
Log.v(TAG, "click: " + videoUuid);
|
||||||
|
|
||||||
simpleExoPlayerView = new PlayerView(this);
|
VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment)
|
||||||
simpleExoPlayerView = findViewById(R.id.video_view);
|
getSupportFragmentManager().findFragmentById(R.id.video_player_fragment);
|
||||||
|
|
||||||
simpleExoPlayerView.setControllerShowTimeoutMs(1000);
|
assert videoPlayerFragment != null;
|
||||||
simpleExoPlayerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FIT);
|
videoPlayerFragment.start(videoUuid);
|
||||||
|
|
||||||
// Full screen Icon
|
// if we are in landscape set the video to fullscreen
|
||||||
fullscreenButton = findViewById(R.id.exo_fullscreen);
|
int orientation = this.getResources().getConfiguration().orientation;
|
||||||
fullscreenButton.setText(R.string.video_expand_icon);
|
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
new Iconics.IconicsBuilder().ctx(this).on(fullscreenButton).build();
|
setOrientation(true);
|
||||||
|
}
|
||||||
fullscreenButton.setOnClickListener(view -> {
|
|
||||||
Log.d(TAG, "Fullscreen");
|
|
||||||
if (!isFullscreen) {
|
|
||||||
isFullscreen = true;
|
|
||||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
|
||||||
fullscreenButton.setText(R.string.video_compress_icon);
|
|
||||||
} else {
|
|
||||||
isFullscreen = false;
|
|
||||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
|
||||||
fullscreenButton.setText(R.string.video_expand_icon);
|
|
||||||
}
|
|
||||||
new Iconics.IconicsBuilder().ctx(this).on(fullscreenButton).build();
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startPlayer()
|
|
||||||
{
|
|
||||||
Util.startForegroundService(context, videoPlayerIntent);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Torrent Playback
|
|
||||||
*
|
|
||||||
* @return torrent stream
|
|
||||||
*/
|
|
||||||
private TorrentStream setupTorrentStream() {
|
|
||||||
|
|
||||||
TorrentOptions torrentOptions = new TorrentOptions.Builder()
|
|
||||||
.saveLocation(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS))
|
|
||||||
.removeFilesAfterStop(true)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
TorrentStream torrentStream = TorrentStream.init(torrentOptions);
|
|
||||||
|
|
||||||
torrentStream.addListener(new TorrentListener() {
|
|
||||||
@Override
|
|
||||||
public void onStreamReady(Torrent torrent) {
|
|
||||||
String videopath = Uri.fromFile(torrent.getVideoFile()).toString();
|
|
||||||
Log.d(TAG, "Ready! torrentStream videopath:" + videopath);
|
|
||||||
mService.setCurrentStreamUrl(videopath);
|
|
||||||
startPlayer();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStreamProgress(Torrent torrent, StreamStatus streamStatus) {
|
|
||||||
if(streamStatus.bufferProgress <= 100 && progressBar.getProgress() < 100 && progressBar.getProgress() != streamStatus.bufferProgress) {
|
|
||||||
//Log.d(TAG, "Progress: " + streamStatus.bufferProgress);
|
|
||||||
progressBar.setProgress(streamStatus.bufferProgress);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStreamStopped() {
|
|
||||||
Log.d(TAG, "Stopped");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStreamPrepared(Torrent torrent) {
|
|
||||||
Log.d(TAG, "Prepared");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStreamStarted(Torrent torrent) {
|
|
||||||
Log.d(TAG, "Started");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStreamError(Torrent torrent, Exception e) {
|
|
||||||
Log.d(TAG, "Error: " + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
return torrentStream;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -231,145 +94,66 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere
|
|||||||
|
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
|
|
||||||
TextView nameView = findViewById(R.id.name);
|
// Checking the orientation changes of the screen
|
||||||
TextView videoMetaView = findViewById(R.id.videoMeta);
|
|
||||||
TextView descriptionView = findViewById(R.id.description);
|
|
||||||
|
|
||||||
// Checking the orientation of the screen
|
|
||||||
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) simpleExoPlayerView.getLayoutParams();
|
setOrientation(true);
|
||||||
params.width = ViewGroup.LayoutParams.MATCH_PARENT;
|
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||||
params.height = ViewGroup.LayoutParams.MATCH_PARENT;
|
setOrientation(false);
|
||||||
simpleExoPlayerView.setLayoutParams(params);
|
|
||||||
|
|
||||||
nameView.setVisibility(View.GONE);
|
|
||||||
videoMetaView.setVisibility(View.GONE);
|
|
||||||
descriptionView.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
||||||
|
|
||||||
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
|
|
||||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) simpleExoPlayerView.getLayoutParams();
|
|
||||||
params.width = ViewGroup.LayoutParams.MATCH_PARENT;
|
|
||||||
params.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 250, getResources().getDisplayMetrics());
|
|
||||||
simpleExoPlayerView.setLayoutParams(params);
|
|
||||||
|
|
||||||
nameView.setVisibility(View.VISIBLE);
|
|
||||||
videoMetaView.setVisibility(View.VISIBLE);
|
|
||||||
descriptionView.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void loadVideo()
|
|
||||||
{
|
|
||||||
// get video ID
|
|
||||||
Intent intent = getIntent();
|
|
||||||
String videoUuid = intent.getStringExtra(VideoListActivity.EXTRA_VIDEOID);
|
|
||||||
Log.v(TAG, "click: " + videoUuid);
|
|
||||||
|
|
||||||
// get video details from api
|
private void setOrientation(Boolean isLandscape) {
|
||||||
String apiBaseURL = APIUrlHelper.getUrlWithVersion(this);
|
|
||||||
GetVideoDataService service = RetrofitInstance.getRetrofitInstance(apiBaseURL).create(GetVideoDataService.class);
|
|
||||||
|
|
||||||
Call<Video> call = service.getVideoData(videoUuid);
|
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||||
|
VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment);
|
||||||
|
VideoMetaDataFragment videoMetaFragment = (VideoMetaDataFragment) fragmentManager.findFragmentById(R.id.video_meta_data_fragment);
|
||||||
|
|
||||||
call.enqueue(new Callback<Video>() {
|
if (isLandscape) {
|
||||||
@Override
|
assert videoPlayerFragment != null;
|
||||||
public void onResponse(@NonNull Call<Video> call, @NonNull Response<Video> response) {
|
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) Objects.requireNonNull(videoPlayerFragment.getView()).getLayoutParams();
|
||||||
|
params.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
// Toast.makeText(TorrentVideoPlayActivity.this, response.body().getDescription(), Toast.LENGTH_SHORT).show();
|
params.height = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
videoPlayerFragment.getView().setLayoutParams(params);
|
||||||
// TODO: remove this code duplication, similar code as in video list rows
|
|
||||||
|
|
||||||
|
|
||||||
Video video = response.body();
|
|
||||||
|
|
||||||
mService.setCurrentVideo(video);
|
|
||||||
|
|
||||||
if (video == null){
|
|
||||||
Toast.makeText(VideoPlayActivity.this, "Something went wrong...Please try later!", Toast.LENGTH_SHORT).show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
VideoMetaDataFragment videoMetaDataFragment = (VideoMetaDataFragment)
|
|
||||||
getSupportFragmentManager().findFragmentById(R.id.video_meta_data_fragment);
|
|
||||||
|
|
||||||
assert videoMetaDataFragment != null;
|
|
||||||
videoMetaDataFragment.updateVideoMeta(video, mService);
|
|
||||||
|
|
||||||
Log.v(TAG, "url : " + video.getFiles().get(0).getFileUrl());
|
|
||||||
|
|
||||||
mService.setCurrentStreamUrl(video.getFiles().get(0).getFileUrl());
|
|
||||||
|
|
||||||
|
|
||||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
|
||||||
if (sharedPref.getBoolean("pref_torrent_player", false)) {
|
|
||||||
|
|
||||||
String stream = video.getFiles().get(0).getTorrentUrl();
|
|
||||||
Log.v(TAG, "getTorrentUrl : " + video.getFiles().get(0).getTorrentUrl());
|
|
||||||
torrentStream = setupTorrentStream();
|
|
||||||
torrentStream.startStream(stream);
|
|
||||||
} else {
|
|
||||||
startPlayer();
|
|
||||||
}
|
|
||||||
Log.v(TAG,"end of load Video");
|
|
||||||
|
|
||||||
|
if (videoMetaFragment != null) {
|
||||||
|
fragmentManager.beginTransaction()
|
||||||
|
.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out)
|
||||||
|
.hide(videoMetaFragment)
|
||||||
|
.commit();
|
||||||
}
|
}
|
||||||
|
videoPlayerFragment.setIsFullscreen(true);
|
||||||
|
|
||||||
@Override
|
} else {
|
||||||
public void onFailure(@NonNull Call<Video> call, @NonNull Throwable t) {
|
assert videoPlayerFragment != null;
|
||||||
Log.wtf(TAG, t.fillInStackTrace());
|
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) Objects.requireNonNull(videoPlayerFragment.getView()).getLayoutParams();
|
||||||
Toast.makeText(VideoPlayActivity.this, "Something went wrong...Please try later!", Toast.LENGTH_SHORT).show();
|
params.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
params.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 250, getResources().getDisplayMetrics());
|
||||||
|
videoPlayerFragment.getView().setLayoutParams(params);
|
||||||
|
|
||||||
|
if (videoMetaFragment != null) {
|
||||||
|
fragmentManager.beginTransaction()
|
||||||
|
.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out)
|
||||||
|
.show(videoMetaFragment)
|
||||||
|
.commit();
|
||||||
}
|
}
|
||||||
});
|
videoPlayerFragment.setIsFullscreen(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onVideoEnabled(DecoderCounters counters) {
|
|
||||||
Log.v(TAG, "onVideoEnabled()...");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onVideoDecoderInitialized(String decoderName, long initializedTimestampMs, long initializationDurationMs) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onVideoInputFormatChanged(Format format) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDroppedFrames(int count, long elapsedMs) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRenderedFirstFrame(Surface surface) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onVideoDisabled(DecoderCounters counters) {
|
|
||||||
Log.v(TAG, "onVideoDisabled()...");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
simpleExoPlayerView.setPlayer(null);
|
|
||||||
if (torrentStream != null){
|
VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment)
|
||||||
torrentStream.stopStream();
|
getSupportFragmentManager().findFragmentById(R.id.video_player_fragment);
|
||||||
}
|
|
||||||
|
assert videoPlayerFragment != null;
|
||||||
|
videoPlayerFragment.destroyVideo();
|
||||||
|
|
||||||
|
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
Log.v(TAG, "onDestroy...");
|
Log.v(TAG, "onDestroy...");
|
||||||
}
|
}
|
||||||
@ -399,10 +183,12 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere
|
|||||||
// stopService(new Intent(this, VideoPlayerService.class));
|
// stopService(new Intent(this, VideoPlayerService.class));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (mBound) {
|
VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment)
|
||||||
unbindService(mConnection);
|
getSupportFragmentManager().findFragmentById(R.id.video_player_fragment);
|
||||||
mBound = false;
|
|
||||||
}
|
assert videoPlayerFragment != null;
|
||||||
|
videoPlayerFragment.stopVideo();
|
||||||
|
|
||||||
Log.v(TAG, "onStop()...");
|
Log.v(TAG, "onStop()...");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,10 +196,6 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere
|
|||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
|
||||||
if (!mBound) {
|
|
||||||
videoPlayerIntent = new Intent(this, VideoPlayerService.class);
|
|
||||||
bindService(videoPlayerIntent, mConnection, Context.BIND_AUTO_CREATE);
|
|
||||||
}
|
|
||||||
Log.v(TAG, "onStart()...");
|
Log.v(TAG, "onStart()...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,9 +85,12 @@ public class VideoAdapter extends RecyclerView.Adapter<VideoAdapter.VideoViewHol
|
|||||||
.into(holder.avatar);
|
.into(holder.avatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set Name
|
||||||
holder.name.setText(videoList.get(position).getName());
|
holder.name.setText(videoList.get(position).getName());
|
||||||
|
|
||||||
|
// set duration
|
||||||
|
holder.videoDuration.setText( MetaDataHelper.getDuration(videoList.get(position).getDuration().longValue()));
|
||||||
|
|
||||||
// set age and view count
|
// set age and view count
|
||||||
holder.videoMeta.setText(
|
holder.videoMeta.setText(
|
||||||
MetaDataHelper.getMetaString(videoList.get(position).getCreatedAt(),
|
MetaDataHelper.getMetaString(videoList.get(position).getCreatedAt(),
|
||||||
@ -153,7 +156,7 @@ public class VideoAdapter extends RecyclerView.Adapter<VideoAdapter.VideoViewHol
|
|||||||
|
|
||||||
class VideoViewHolder extends RecyclerView.ViewHolder {
|
class VideoViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
TextView name, videoMeta, videoOwner, moreButton;
|
TextView name, videoMeta, videoOwner, moreButton, videoDuration;
|
||||||
ImageView thumb, avatar;
|
ImageView thumb, avatar;
|
||||||
View mView;
|
View mView;
|
||||||
|
|
||||||
@ -165,6 +168,7 @@ public class VideoAdapter extends RecyclerView.Adapter<VideoAdapter.VideoViewHol
|
|||||||
videoMeta = itemView.findViewById(R.id.videoMeta);
|
videoMeta = itemView.findViewById(R.id.videoMeta);
|
||||||
videoOwner = itemView.findViewById(R.id.videoOwner);
|
videoOwner = itemView.findViewById(R.id.videoOwner);
|
||||||
moreButton = itemView.findViewById(R.id.moreButton);
|
moreButton = itemView.findViewById(R.id.moreButton);
|
||||||
|
videoDuration = itemView.findViewById(R.id.video_duration);
|
||||||
mView = itemView;
|
mView = itemView;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 Stefan Schüller <sschueller@techdroid.com>
|
||||||
|
*
|
||||||
|
* License: GPL-3.0+
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package net.schueller.peertube.fragment;
|
package net.schueller.peertube.fragment;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
|
@ -50,7 +50,7 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment {
|
|||||||
@Nullable ViewGroup container,
|
@Nullable ViewGroup container,
|
||||||
@Nullable Bundle savedInstanceState) {
|
@Nullable Bundle savedInstanceState) {
|
||||||
|
|
||||||
View view = inflater.inflate(R.layout.bottom_sheet_video_options_fragment, container,
|
View view = inflater.inflate(R.layout.fragment_video_options_popup_menu, container,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
// Icons
|
// Icons
|
||||||
|
@ -0,0 +1,353 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 Stefan Schüller <sschueller@techdroid.com>
|
||||||
|
*
|
||||||
|
* License: GPL-3.0+
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package net.schueller.peertube.fragment;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.ServiceConnection;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.os.IBinder;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Surface;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.github.se_bastiaan.torrentstream.StreamStatus;
|
||||||
|
import com.github.se_bastiaan.torrentstream.Torrent;
|
||||||
|
import com.github.se_bastiaan.torrentstream.TorrentOptions;
|
||||||
|
import com.github.se_bastiaan.torrentstream.TorrentStream;
|
||||||
|
import com.github.se_bastiaan.torrentstream.listeners.TorrentListener;
|
||||||
|
import com.google.android.exoplayer2.Format;
|
||||||
|
import com.google.android.exoplayer2.decoder.DecoderCounters;
|
||||||
|
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
||||||
|
import com.google.android.exoplayer2.ui.PlayerView;
|
||||||
|
import com.google.android.exoplayer2.util.Util;
|
||||||
|
import com.google.android.exoplayer2.video.VideoRendererEventListener;
|
||||||
|
import com.mikepenz.iconics.Iconics;
|
||||||
|
|
||||||
|
import net.schueller.peertube.R;
|
||||||
|
|
||||||
|
import net.schueller.peertube.helper.APIUrlHelper;
|
||||||
|
import net.schueller.peertube.model.Video;
|
||||||
|
import net.schueller.peertube.network.GetVideoDataService;
|
||||||
|
import net.schueller.peertube.network.RetrofitInstance;
|
||||||
|
import net.schueller.peertube.service.VideoPlayerService;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.Callback;
|
||||||
|
import retrofit2.Response;
|
||||||
|
|
||||||
|
public class VideoPlayerFragment extends Fragment implements VideoRendererEventListener {
|
||||||
|
|
||||||
|
private String mVideoUuid;
|
||||||
|
private ProgressBar progressBar;
|
||||||
|
private PlayerView simpleExoPlayerView;
|
||||||
|
private Intent videoPlayerIntent;
|
||||||
|
private Boolean mBound = false;
|
||||||
|
private Boolean isFullscreen = false;
|
||||||
|
private VideoPlayerService mService;
|
||||||
|
private TorrentStream torrentStream;
|
||||||
|
|
||||||
|
private static final String TAG = "VideoPlayerFragment";
|
||||||
|
|
||||||
|
|
||||||
|
private ServiceConnection mConnection = new ServiceConnection() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onServiceConnected(ComponentName className, IBinder service) {
|
||||||
|
Log.d(TAG, "onServiceConnected");
|
||||||
|
VideoPlayerService.LocalBinder binder = (VideoPlayerService.LocalBinder) service;
|
||||||
|
mService = binder.getService();
|
||||||
|
|
||||||
|
// 2. Create the player
|
||||||
|
simpleExoPlayerView.setPlayer(mService.player);
|
||||||
|
mBound = true;
|
||||||
|
|
||||||
|
loadVideo();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onServiceDisconnected(ComponentName componentName) {
|
||||||
|
Log.d(TAG, "onServiceDisconnected");
|
||||||
|
simpleExoPlayerView.setPlayer(null);
|
||||||
|
mBound = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
// Inflate the layout for this fragment
|
||||||
|
return inflater.inflate(R.layout.fragment_video_player, container, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void start(String videoUuid) {
|
||||||
|
|
||||||
|
// start service
|
||||||
|
Context context = getContext();
|
||||||
|
Activity activity = getActivity();
|
||||||
|
|
||||||
|
mVideoUuid = videoUuid;
|
||||||
|
|
||||||
|
assert activity != null;
|
||||||
|
progressBar = activity.findViewById(R.id.progress);
|
||||||
|
progressBar.setMax(100);
|
||||||
|
|
||||||
|
simpleExoPlayerView = new PlayerView(context);
|
||||||
|
simpleExoPlayerView = activity.findViewById(R.id.video_view);
|
||||||
|
|
||||||
|
simpleExoPlayerView.setControllerShowTimeoutMs(1000);
|
||||||
|
simpleExoPlayerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FIT);
|
||||||
|
|
||||||
|
// Full screen Icon
|
||||||
|
TextView fullscreenButton = activity.findViewById(R.id.exo_fullscreen);
|
||||||
|
fullscreenButton.setText(R.string.video_expand_icon);
|
||||||
|
new Iconics.IconicsBuilder().ctx(context).on(fullscreenButton).build();
|
||||||
|
|
||||||
|
fullscreenButton.setOnClickListener(view -> {
|
||||||
|
Log.d(TAG, "Fullscreen");
|
||||||
|
if (!isFullscreen) {
|
||||||
|
isFullscreen = true;
|
||||||
|
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||||
|
} else {
|
||||||
|
isFullscreen = false;
|
||||||
|
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!mBound) {
|
||||||
|
videoPlayerIntent = new Intent(context, VideoPlayerService.class);
|
||||||
|
activity.bindService(videoPlayerIntent, mConnection, Context.BIND_AUTO_CREATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadVideo() {
|
||||||
|
Context context = getContext();
|
||||||
|
|
||||||
|
|
||||||
|
// get video details from api
|
||||||
|
String apiBaseURL = APIUrlHelper.getUrlWithVersion(context);
|
||||||
|
GetVideoDataService service = RetrofitInstance.getRetrofitInstance(apiBaseURL).create(GetVideoDataService.class);
|
||||||
|
|
||||||
|
Call<Video> call = service.getVideoData(mVideoUuid);
|
||||||
|
|
||||||
|
call.enqueue(new Callback<Video>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(@NonNull Call<Video> call, @NonNull Response<Video> response) {
|
||||||
|
|
||||||
|
Video video = response.body();
|
||||||
|
|
||||||
|
mService.setCurrentVideo(video);
|
||||||
|
|
||||||
|
if (video == null) {
|
||||||
|
Toast.makeText(context, "Something went wrong...Please try later!", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
playVideo(video);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Call<Video> call, @NonNull Throwable t) {
|
||||||
|
Log.wtf(TAG, t.fillInStackTrace());
|
||||||
|
Toast.makeText(context, "Something went wrong...Please try later!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void playVideo(Video video) {
|
||||||
|
|
||||||
|
Context context = getContext();
|
||||||
|
|
||||||
|
// video Meta fragment
|
||||||
|
assert getFragmentManager() != null;
|
||||||
|
VideoMetaDataFragment videoMetaDataFragment = (VideoMetaDataFragment)
|
||||||
|
getFragmentManager().findFragmentById(R.id.video_meta_data_fragment);
|
||||||
|
|
||||||
|
assert videoMetaDataFragment != null;
|
||||||
|
videoMetaDataFragment.updateVideoMeta(video, mService);
|
||||||
|
|
||||||
|
Log.v(TAG, "url : " + video.getFiles().get(0).getFileUrl());
|
||||||
|
|
||||||
|
mService.setCurrentStreamUrl(video.getFiles().get(0).getFileUrl());
|
||||||
|
|
||||||
|
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
if (sharedPref.getBoolean("pref_torrent_player", false)) {
|
||||||
|
|
||||||
|
String stream = video.getFiles().get(0).getTorrentUrl();
|
||||||
|
Log.v(TAG, "getTorrentUrl : " + video.getFiles().get(0).getTorrentUrl());
|
||||||
|
torrentStream = setupTorrentStream();
|
||||||
|
torrentStream.startStream(stream);
|
||||||
|
} else {
|
||||||
|
startPlayer();
|
||||||
|
}
|
||||||
|
Log.v(TAG, "end of load Video");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startPlayer() {
|
||||||
|
Util.startForegroundService(Objects.requireNonNull(getContext()), videoPlayerIntent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void destroyVideo() {
|
||||||
|
simpleExoPlayerView.setPlayer(null);
|
||||||
|
if (torrentStream != null) {
|
||||||
|
torrentStream.stopStream();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopVideo() {
|
||||||
|
|
||||||
|
if (mBound) {
|
||||||
|
Objects.requireNonNull(getContext()).unbindService(mConnection);
|
||||||
|
mBound = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsFullscreen(Boolean fullscreen) {
|
||||||
|
isFullscreen = fullscreen;
|
||||||
|
|
||||||
|
TextView fullscreenButton = getActivity().findViewById(R.id.exo_fullscreen);
|
||||||
|
if (fullscreen) {
|
||||||
|
fullscreenButton.setText(R.string.video_compress_icon);
|
||||||
|
} else {
|
||||||
|
fullscreenButton.setText(R.string.video_expand_icon);
|
||||||
|
}
|
||||||
|
new Iconics.IconicsBuilder().ctx(getContext()).on(fullscreenButton).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getIsFullscreen() {
|
||||||
|
return isFullscreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Torrent Playback
|
||||||
|
*
|
||||||
|
* @return torrent stream
|
||||||
|
*/
|
||||||
|
private TorrentStream setupTorrentStream() {
|
||||||
|
|
||||||
|
TorrentOptions torrentOptions = new TorrentOptions.Builder()
|
||||||
|
.saveLocation(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS))
|
||||||
|
.removeFilesAfterStop(true)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
TorrentStream torrentStream = TorrentStream.init(torrentOptions);
|
||||||
|
|
||||||
|
torrentStream.addListener(new TorrentListener() {
|
||||||
|
@Override
|
||||||
|
public void onStreamReady(Torrent torrent) {
|
||||||
|
String videopath = Uri.fromFile(torrent.getVideoFile()).toString();
|
||||||
|
Log.d(TAG, "Ready! torrentStream videopath:" + videopath);
|
||||||
|
mService.setCurrentStreamUrl(videopath);
|
||||||
|
startPlayer();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStreamProgress(Torrent torrent, StreamStatus streamStatus) {
|
||||||
|
if (streamStatus.bufferProgress <= 100 && progressBar.getProgress() < 100 && progressBar.getProgress() != streamStatus.bufferProgress) {
|
||||||
|
//Log.d(TAG, "Progress: " + streamStatus.bufferProgress);
|
||||||
|
progressBar.setProgress(streamStatus.bufferProgress);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStreamStopped() {
|
||||||
|
Log.d(TAG, "Stopped");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStreamPrepared(Torrent torrent) {
|
||||||
|
Log.d(TAG, "Prepared");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStreamStarted(Torrent torrent) {
|
||||||
|
Log.d(TAG, "Started");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStreamError(Torrent torrent, Exception e) {
|
||||||
|
Log.d(TAG, "Error: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
return torrentStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onVideoEnabled(DecoderCounters counters) {
|
||||||
|
Log.v(TAG, "onVideoEnabled()...");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onVideoDecoderInitialized(String decoderName, long initializedTimestampMs, long initializationDurationMs) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onVideoInputFormatChanged(Format format) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDroppedFrames(int count, long elapsedMs) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRenderedFirstFrame(Surface surface) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onVideoDisabled(DecoderCounters counters) {
|
||||||
|
Log.v(TAG, "onVideoDisabled()...");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -20,6 +20,9 @@ package net.schueller.peertube.helper;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
import net.schueller.peertube.R;
|
import net.schueller.peertube.R;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Period;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class MetaDataHelper {
|
public class MetaDataHelper {
|
||||||
@ -37,4 +40,7 @@ public class MetaDataHelper {
|
|||||||
serverHost;
|
serverHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getDuration(Long duration) {
|
||||||
|
return DateUtils.formatElapsedTime(duration);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.coordinatorlayout.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"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
@ -12,31 +11,16 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<fragment android:name="net.schueller.peertube.fragment.VideoPlayerFragment"
|
||||||
<com.google.android.exoplayer2.ui.PlayerView
|
android:id="@+id/video_player_fragment"
|
||||||
android:id="@+id/video_view"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="250dp"
|
android:layout_height="250dp" />
|
||||||
android:background="@color/videoBackgroundColor"
|
|
||||||
app:controller_layout_id="@layout/video_playback_controls"
|
|
||||||
app:resize_mode="fixed_width"
|
|
||||||
|
|
||||||
/>
|
|
||||||
|
|
||||||
<ProgressBar
|
|
||||||
android:id="@+id/progress"
|
|
||||||
style="?android:attr/progressBarStyleHorizontal"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@id/video_view"
|
|
||||||
android:indeterminate="false"
|
|
||||||
android:max="100" />
|
|
||||||
|
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_below="@id/progress"
|
android:layout_below="@id/video_player_fragment"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
|
26
app/src/main/res/layout/fragment_video_player.xml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<com.google.android.exoplayer2.ui.PlayerView
|
||||||
|
android:id="@+id/video_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/videoBackgroundColor"
|
||||||
|
app:controller_layout_id="@layout/video_playback_controls"
|
||||||
|
app:resize_mode="fixed_width"
|
||||||
|
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progress"
|
||||||
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:indeterminate="false"
|
||||||
|
android:max="100" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -24,6 +24,19 @@
|
|||||||
android:maxHeight="300dp"
|
android:maxHeight="300dp"
|
||||||
android:scaleType="fitXY" />
|
android:scaleType="fitXY" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:paddingStart="4dp"
|
||||||
|
android:paddingEnd="4dp"
|
||||||
|
android:layout_margin="2dp"
|
||||||
|
android:text=""
|
||||||
|
android:layout_above="@+id/avatar"
|
||||||
|
android:gravity="bottom|end"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:id="@+id/video_duration"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="#000000"/>
|
||||||
|
|
||||||
<de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
|
<de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/avatar"
|
android:id="@+id/avatar"
|
||||||
android:layout_width="72dp"
|
android:layout_width="72dp"
|
||||||
|