Skip to content

Commit

Permalink
Merge pull request #22 from ShareASmile/share-stream-url
Browse files Browse the repository at this point in the history
Add Ability To Share Stream URL Externally
  • Loading branch information
ShareASmile authored Dec 29, 2023
2 parents 0305a58 + 0892e69 commit c3e7153
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,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 @@ -929,10 +941,10 @@ 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 @@ -1016,6 +1028,20 @@ 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 List<AudioStream> audioStreams = currentInfo.getAudioStreams();
final int streamIndex = ListHelper.getDefaultAudioFormat(activity, audioStreams);
return audioStreams.get(streamIndex);
}

private void prepareDescription(final Description description) {
if (description == null || TextUtils.isEmpty(description.getContent())
|| description == Description.EMPTY_DESCRIPTION) {
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-pa/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<string name="open_in_browser">ਬ੍ਰਾਊਜ਼ਰ ਵਿੱਚ ਖੋਲ੍ਹੋ</string>
<string name="open_in_popup_mode">ਪੌਪ-ਅਪ ਵਿੱਚ ਖੋਲੋ</string>
<string name="share">ਸਾਂਝਾ ਕਰੋ</string>
<string name="share_stream">ਮੀਡੀਆ URL ਸਾਂਝਾ ਕਰੋ</string>
<string name="download">ਡਾਊਨਲੋਡ</string>
<string name="controls_download_desc">ਸਟ੍ਰੀਮ ਫ਼ਾਈਲ ਡਾਊਨਲੋਡ ਕਰੋ</string>
<string name="search">ਖੋਜੋ</string>
Expand Down
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 media URL</string>
<string name="download">Download</string>
<string name="controls_download_desc">Download stream file</string>
<string name="search">Search</string>
Expand Down

0 comments on commit c3e7153

Please sign in to comment.