Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,18 @@ public boolean onOptionsItemSelected(final MenuItem item) {
currentInfo.getOriginalUrl());
}
return true;
case R.id.menu_item_share_stream:
if (currentInfo != null) {
final Stream stream;
if (currentInfo.getVideoStreams().isEmpty()
&& currentInfo.getVideoOnlyStreams().isEmpty()) {
stream = getDefaultAudioStream();
} else {
stream = getSelectedVideoStream();
}
ShareUtils.shareUrl(requireContext(), currentInfo.getName(), stream.getUrl());
}
return true;
case R.id.menu_item_openInBrowser:
if (currentInfo != null) {
ShareUtils.openUrlInBrowser(requireContext(), currentInfo.getOriginalUrl());
Expand Down Expand Up @@ -927,10 +939,9 @@ private boolean shouldShowComments() {
//////////////////////////////////////////////////////////////////////////*/

private void openBackgroundPlayer(final boolean append) {
AudioStream audioStream = currentInfo.getAudioStreams()
.get(ListHelper.getDefaultAudioFormat(activity, currentInfo.getAudioStreams()));
final AudioStream audioStream = getDefaultAudioStream();

boolean useExternalAudioPlayer = PreferenceManager.getDefaultSharedPreferences(activity)
final boolean useExternalAudioPlayer = PreferenceManager.getDefaultSharedPreferences(activity)
.getBoolean(activity.getString(R.string.use_external_audio_player_key), false);

if (!useExternalAudioPlayer && android.os.Build.VERSION.SDK_INT >= 16) {
Expand Down Expand Up @@ -1014,6 +1025,19 @@ private VideoStream getSelectedVideoStream() {
return sortedVideoStreams != null ? sortedVideoStreams.get(selectedVideoStreamIndex) : null;
}

/**
* Get the stream to play when the current stream is an audio-only stream.
*
* This is the audio-only equivalent of getSelectedVideoStream,
* without the ability for the user to select a custom stream quality.
*
* @return AudioStream instance according to user settings
*/
private AudioStream getDefaultAudioStream() {
final int streamIndex = ListHelper.getDefaultAudioFormat(activity, currentInfo.getAudioStreams());
return currentInfo.getAudioStreams().get(streamIndex);
}

private void prepareDescription(final Description description) {
if (TextUtils.isEmpty(description.getContent())
|| description == Description.emptyDescription) {
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/menu/video_detail_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@
android:orderInCategory="2"
android:title="@string/open_in_browser"
app:showAsAction="never"/>

<item
android:id="@+id/menu_item_share_stream"
android:orderInCategory="3"
android:title="@string/share_stream"
app:showAsAction="never"/>
</menu>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<string name="open_in_browser">Open in browser</string>
<string name="open_in_popup_mode">Open in popup mode</string>
<string name="share">Share</string>
<string name="share_stream">Share stream link</string>
<string name="download">Download</string>
<string name="controls_download_desc">Download stream file</string>
<string name="search">Search</string>
Expand Down