Fix issue #47 - Seek to last known position
This commit is contained in:
parent
ffa5d0883a
commit
8ab237a957
|
@ -174,7 +174,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
private List<Comment> commentsThread;
|
||||
private BroadcastReceiver mPowerKeyReceiver = null;
|
||||
private boolean isPlayInMinimized;
|
||||
private Intent urlIntent;
|
||||
public static List<String> playedVideos = new ArrayList<>();
|
||||
private VideoData.Video nextVideo;
|
||||
private TorrentStream torrentStream;
|
||||
|
@ -241,7 +240,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
setContentView(view);
|
||||
videoOrientationType = videoOrientation.LANDSCAPE;
|
||||
max_id = "0";
|
||||
urlIntent = null;
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
||||
|
@ -430,6 +428,9 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
return;
|
||||
}
|
||||
peertube = apiResponse.getPeertubes().get(0);
|
||||
if( peertube.getUserHistory() != null) {
|
||||
player.seekTo(peertube.getUserHistory().getCurrentTime()*1000);
|
||||
}
|
||||
sepiaSearch = false;
|
||||
playVideo();
|
||||
}
|
||||
|
@ -524,7 +525,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
peertube = new VideoData.Video();
|
||||
peertube.setUuid(uuid);
|
||||
peertube.setEmbedUrl(url);
|
||||
urlIntent = intent;
|
||||
SearchVM viewModelSearch = new ViewModelProvider(PeertubeActivity.this).get(SearchVM.class);
|
||||
viewModelSearch.getVideos("0", peertube.getEmbedUrl()).observe(PeertubeActivity.this, this::manageVIewVideos);
|
||||
}else {
|
||||
|
@ -565,7 +565,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
setFullscreen(FullScreenMediaController.fullscreen.OFF);
|
||||
fullScreenMode = false;
|
||||
}
|
||||
updateHistory(0);
|
||||
binding.peertubePlaylist.setVisibility(View.VISIBLE);
|
||||
binding.peertubeBookmark.setVisibility(View.GONE);
|
||||
TimelineVM feedsViewModel = new ViewModelProvider(PeertubeActivity.this).get(TimelineVM.class);
|
||||
|
@ -582,12 +581,14 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
binding.peertubeDescriptionMore.setVisibility(View.GONE);
|
||||
show_more_content = null;
|
||||
}else{
|
||||
if( peertube != null && peertube.getDescription() != null && description.getDescription().compareTo(peertube.getDescription()) > 0) {
|
||||
binding.peertubeDescriptionMore.setVisibility(View.VISIBLE);
|
||||
show_more_content = description.getDescription();
|
||||
}else{
|
||||
binding.peertubeDescriptionMore.setVisibility(View.GONE);
|
||||
show_more_content = null;
|
||||
if( !PeertubeActivity.this.isFinishing()) {
|
||||
if (peertube != null && peertube.getDescription() != null && description.getDescription().compareTo(peertube.getDescription()) > 0) {
|
||||
binding.peertubeDescriptionMore.setVisibility(View.VISIBLE);
|
||||
show_more_content = description.getDescription();
|
||||
} else {
|
||||
binding.peertubeDescriptionMore.setVisibility(View.GONE);
|
||||
show_more_content = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -619,9 +620,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
if (item.getItemId() == android.R.id.home) {
|
||||
if (playInMinimized && player != null) {
|
||||
finishAndRemoveTask();
|
||||
Intent intent = new Intent(PeertubeActivity.this, MainActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
startActivity(intent);
|
||||
}
|
||||
finish();
|
||||
return true;
|
||||
|
@ -714,7 +712,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
public void manageVIewVideo(APIResponse apiResponse) {
|
||||
|
||||
if (apiResponse == null || (apiResponse.getError() != null) || apiResponse.getPeertubes() == null || apiResponse.getPeertubes().size() == 0) {
|
||||
Toasty.error(PeertubeActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||
binding.loader.setVisibility(View.GONE);
|
||||
|
@ -725,7 +722,10 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
binding.loader.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
|
||||
long position = -1;
|
||||
if( peertube.getUserHistory() != null) {
|
||||
position = peertube.getUserHistory().getCurrentTime() * 1000;
|
||||
}
|
||||
|
||||
peertube = apiResponse.getPeertubes().get(0);
|
||||
if( peertube.getTags() != null && peertube.getTags().size() > 0) {
|
||||
|
@ -873,7 +873,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
startStream(
|
||||
apiResponse.getPeertubes().get(0).getFileUrl(null, PeertubeActivity.this),
|
||||
apiResponse.getPeertubes().get(0).getStreamingPlaylists().size()>0?apiResponse.getPeertubes().get(0).getStreamingPlaylists().get(0).getPlaylistUrl():null,
|
||||
autoPlay,-1, null, null);
|
||||
autoPlay,position, null, null);
|
||||
player.prepare();
|
||||
player.setPlayWhenReady(autoPlay);
|
||||
}
|
||||
|
@ -966,7 +966,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
uri = Uri.parse("https://" + peertubeInstance + captions.get(which - 1).getCaptionPath());
|
||||
}
|
||||
}
|
||||
long position = player.getCurrentPosition();
|
||||
long newPosition = player.getCurrentPosition();
|
||||
|
||||
if (player != null)
|
||||
player.release();
|
||||
|
@ -979,7 +979,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
apiResponse.getPeertubes().get(0).getFileUrl(null, PeertubeActivity.this),
|
||||
null,
|
||||
true,
|
||||
position,
|
||||
newPosition,
|
||||
uri,
|
||||
itemsKeyLanguage[which]
|
||||
);
|
||||
|
|
|
@ -121,6 +121,8 @@ public class VideoData {
|
|||
private List<String> trackerUrls;
|
||||
@SerializedName("updatedAt")
|
||||
private Date updatedAt;
|
||||
@SerializedName("userHistory")
|
||||
private UserHistory userHistory;
|
||||
@SerializedName("uuid")
|
||||
private String uuid;
|
||||
@SerializedName("views")
|
||||
|
@ -178,6 +180,7 @@ public class VideoData {
|
|||
this.trackerUrls = in.createStringArrayList();
|
||||
long tmpUpdatedAt = in.readLong();
|
||||
this.updatedAt = tmpUpdatedAt == -1 ? null : new Date(tmpUpdatedAt);
|
||||
this.userHistory = in.readParcelable(UserHistory.class.getClassLoader());
|
||||
this.uuid = in.readString();
|
||||
this.views = in.readInt();
|
||||
this.waitTranscoding = in.readByte() != 0;
|
||||
|
@ -578,6 +581,14 @@ public class VideoData {
|
|||
this.playlistExists = playlistExists;
|
||||
}
|
||||
|
||||
public UserHistory getUserHistory() {
|
||||
return userHistory;
|
||||
}
|
||||
|
||||
public void setUserHistory(UserHistory userHistory) {
|
||||
this.userHistory = userHistory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
|
@ -618,6 +629,7 @@ public class VideoData {
|
|||
dest.writeString(this.thumbnailPath);
|
||||
dest.writeStringList(this.trackerUrls);
|
||||
dest.writeLong(this.updatedAt != null ? this.updatedAt.getTime() : -1);
|
||||
dest.writeParcelable(this.userHistory, flags);
|
||||
dest.writeString(this.uuid);
|
||||
dest.writeInt(this.views);
|
||||
dest.writeByte(this.waitTranscoding ? (byte) 1 : (byte) 0);
|
||||
|
@ -686,6 +698,51 @@ public class VideoData {
|
|||
|
||||
}
|
||||
|
||||
public static class UserHistory implements Parcelable{
|
||||
|
||||
public static final Creator<UserHistory> CREATOR = new Creator<UserHistory>() {
|
||||
@Override
|
||||
public UserHistory createFromParcel(Parcel in) {
|
||||
return new UserHistory(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserHistory[] newArray(int size) {
|
||||
return new UserHistory[size];
|
||||
}
|
||||
};
|
||||
|
||||
@SerializedName("currentTime")
|
||||
long currentTime;
|
||||
|
||||
public UserHistory() {
|
||||
}
|
||||
|
||||
protected UserHistory(Parcel in) {
|
||||
this.currentTime = in.readLong();
|
||||
}
|
||||
|
||||
|
||||
public long getCurrentTime() {
|
||||
return currentTime;
|
||||
}
|
||||
|
||||
public void setCurrentTime(long currentTime) {
|
||||
this.currentTime = currentTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel parcel, int i) {
|
||||
parcel.writeLong(currentTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class Description{
|
||||
@SerializedName("description")
|
||||
private String description;
|
||||
|
|
Loading…
Reference in New Issue