Merge pull request #5228 from B0pol/share_ts

Remove timestamp from share url for all services except youtube
This commit is contained in:
Tobias Groza 2020-12-20 11:20:34 +01:00 committed by GitHub
commit 0c656abb8e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -103,6 +103,7 @@ import org.schabi.newpipe.util.ShareUtils;
import java.util.List; import java.util.List;
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
import static org.schabi.newpipe.player.MainPlayer.ACTION_CLOSE; import static org.schabi.newpipe.player.MainPlayer.ACTION_CLOSE;
import static org.schabi.newpipe.player.MainPlayer.ACTION_FAST_FORWARD; import static org.schabi.newpipe.player.MainPlayer.ACTION_FAST_FORWARD;
import static org.schabi.newpipe.player.MainPlayer.ACTION_FAST_REWIND; import static org.schabi.newpipe.player.MainPlayer.ACTION_FAST_REWIND;
@ -889,10 +890,17 @@ public class VideoPlayerImpl extends VideoPlayer
private void onShareClicked() { private void onShareClicked() {
// share video at the current time (youtube.com/watch?v=ID&t=SECONDS) // share video at the current time (youtube.com/watch?v=ID&t=SECONDS)
// Timestamp doesn't make sense in a live stream so drop it // Timestamp doesn't make sense in a live stream so drop it
final String ts = isLive() ? "" : ("&t=" + (getPlaybackSeekBar().getProgress() / 1000));
final int ts = getPlaybackSeekBar().getProgress() / 1000;
final MediaSourceTag metadata = getCurrentMetadata();
String videoUrl = getVideoUrl();
if (!isLive() && ts >= 0 && metadata != null
&& metadata.getMetadata().getServiceId() == YouTube.getServiceId()) {
videoUrl += ("&t=" + ts);
}
ShareUtils.shareUrl(service, ShareUtils.shareUrl(service,
getVideoTitle(), getVideoTitle(),
getVideoUrl() + ts); videoUrl);
} }
private void onPlayWithKodiClicked() { private void onPlayWithKodiClicked() {