-
-
Notifications
You must be signed in to change notification settings - Fork 574
pick random song from tracklist #339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Rigellute
merged 11 commits into
Rigellute:master
from
BKitor:pick-random-song-with-shift-s
Mar 20, 2020
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b368296
pick random song from playlist
BKitor 122b554
play a random song from the current saved_tracks
BKitor 392db76
shuffle for playlist search
BKitor 9c0430c
shuffle pick from MadeForYou context
BKitor a1d1844
code review
BKitor bbff58d
help menu instructions
BKitor 402483d
added help text
BKitor e63b213
Merge branch 'master' into pick-random-song-with-shift-s
BKitor 8b855d4
replace .unwrap() with and_then
BKitor d4a639d
Merge branch 'master' into pick-random-song-with-shift-s
BKitor b93f5a5
update CHANGELOG
BKitor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
shuffle pick from MadeForYou context
- Loading branch information
commit 9c0430ca15b5eff57888bff17971edadb26f1a36
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -227,9 +227,28 @@ fn play_random_song(app: &mut App) { | |
| Some(thread_rng().gen_range(0, num_tracks)), | ||
| )) | ||
| } | ||
| // let rand_playlist_idx = thread_rng().gen_range(0, ) | ||
| } | ||
| TrackTableContext::MadeForYou => {} | ||
| TrackTableContext::MadeForYou => { | ||
| let (context_uri, track_json) = match app | ||
| .library | ||
| .made_for_you_playlists | ||
| .get_results(Some(0)) | ||
| .unwrap() | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you able to remove these TrackTableContext::MadeForYou => {
if let Some(playlist) = &app
.library
.made_for_you_playlists
.get_results(Some(0))
.and_then(|playlist| playlist.items.get(app.made_for_you_index))
{
if let Some(num_tracks) = &playlist
.tracks
.get("total")
.and_then(|total| -> Option<usize> { from_value(total.clone()).ok() })
{
let uri = Some(playlist.uri.clone());
app.dispatch(IoEvent::StartPlayback(
uri,
None,
Some(thread_rng().gen_range(0, num_tracks)),
));
}
};
}
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This works great! I didn't know and_then() existed. Thanks for the tip. |
||
| .items | ||
| .get(app.made_for_you_index) | ||
| .unwrap() | ||
| { | ||
| playlist => (Some(playlist.uri.to_owned()), playlist.tracks.get("total")), | ||
| }; | ||
| if let Some(val) = track_json{ | ||
| let num_tracks:usize = from_value(val.clone()).unwrap(); | ||
| app.dispatch(IoEvent::StartPlayback( | ||
| context_uri, | ||
| None, | ||
| Some(thread_rng().gen_range(0, num_tracks)) | ||
| )) | ||
| } | ||
| } | ||
| }, | ||
| None => {} | ||
| }; | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.