Use url at current time for long click on player share button
This commit is contained in:
parent
5532666ad5
commit
bede758507
1 changed files with 14 additions and 17 deletions
|
@ -2918,6 +2918,18 @@ public final class Player implements
|
||||||
: currentMetadata.getMetadata().getUrl();
|
: currentMetadata.getMetadata().getUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
private String getVideoUrlAtCurrentTime() {
|
||||||
|
final int timeSeconds = binding.playbackSeekBar.getProgress() / 1000;
|
||||||
|
String videoUrl = getVideoUrl();
|
||||||
|
if (!isLive() && timeSeconds >= 0 && currentMetadata != null
|
||||||
|
&& currentMetadata.getMetadata().getServiceId() == YouTube.getServiceId()) {
|
||||||
|
// Timestamp doesn't make sense in a live stream so drop it
|
||||||
|
videoUrl += ("&t=" + timeSeconds);
|
||||||
|
}
|
||||||
|
return videoUrl;
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public String getVideoTitle() {
|
public String getVideoTitle() {
|
||||||
return currentMetadata == null
|
return currentMetadata == null
|
||||||
|
@ -3581,7 +3593,7 @@ public final class Player implements
|
||||||
} else if (v.getId() == binding.moreOptionsButton.getId()) {
|
} else if (v.getId() == binding.moreOptionsButton.getId()) {
|
||||||
onMoreOptionsClicked();
|
onMoreOptionsClicked();
|
||||||
} else if (v.getId() == binding.share.getId()) {
|
} else if (v.getId() == binding.share.getId()) {
|
||||||
onShareClicked();
|
ShareUtils.shareText(context, getVideoTitle(), getVideoUrlAtCurrentTime());
|
||||||
} else if (v.getId() == binding.playWithKodi.getId()) {
|
} else if (v.getId() == binding.playWithKodi.getId()) {
|
||||||
onPlayWithKodiClicked();
|
onPlayWithKodiClicked();
|
||||||
} else if (v.getId() == binding.openInBrowser.getId()) {
|
} else if (v.getId() == binding.openInBrowser.getId()) {
|
||||||
|
@ -3631,9 +3643,7 @@ public final class Player implements
|
||||||
hideControls(0, 0);
|
hideControls(0, 0);
|
||||||
hideSystemUIIfNeeded();
|
hideSystemUIIfNeeded();
|
||||||
} else if (v.getId() == binding.share.getId()) {
|
} else if (v.getId() == binding.share.getId()) {
|
||||||
if (currentMetadata != null) {
|
ShareUtils.copyToClipboard(context, getVideoUrlAtCurrentTime());
|
||||||
ShareUtils.copyToClipboard(context, currentMetadata.getMetadata().getOriginalUrl());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3705,19 +3715,6 @@ public final class Player implements
|
||||||
showControls(DEFAULT_CONTROLS_DURATION);
|
showControls(DEFAULT_CONTROLS_DURATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onShareClicked() {
|
|
||||||
// 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
|
|
||||||
|
|
||||||
final int ts = binding.playbackSeekBar.getProgress() / 1000;
|
|
||||||
String videoUrl = getVideoUrl();
|
|
||||||
if (!isLive() && ts >= 0 && currentMetadata != null
|
|
||||||
&& currentMetadata.getMetadata().getServiceId() == YouTube.getServiceId()) {
|
|
||||||
videoUrl += ("&t=" + ts);
|
|
||||||
}
|
|
||||||
ShareUtils.shareText(context, getVideoTitle(), videoUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onPlayWithKodiClicked() {
|
private void onPlayWithKodiClicked() {
|
||||||
if (currentMetadata != null) {
|
if (currentMetadata != null) {
|
||||||
pause();
|
pause();
|
||||||
|
|
Loading…
Add table
Reference in a new issue