Skip to content
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

Add playlists feature #871

Merged
merged 7 commits into from
Sep 2, 2016
Merged

Add playlists feature #871

merged 7 commits into from
Sep 2, 2016

Conversation

Goldob
Copy link
Contributor

@Goldob Goldob commented Sep 1, 2016

Open multi-file torrents as playlists. Basically #642 after rebase.
Solves #123 and #839.

image

@@ -96,7 +96,7 @@ function chromecastPlayer () {

function open () {
var torrentSummary = state.saved.torrents.find((x) => x.infoHash === state.playing.infoHash)
ret.device.play(state.server.networkURL, {
ret.device.play(state.server.networkURL + '/' + state.playing.fileIndex, {
Copy link
Contributor

@dcposch dcposch Sep 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd put this into its own function to reduce code duplication. (Notice the two lines that look just like this one further down)

@dcposch
Copy link
Contributor

dcposch commented Sep 1, 2016

@Goldob thanks for doing this! Looks great

I think it can be simplified a bit

  • There's a bit of code duplication. Nothing serious
  • I don't know if we need state.playlist. The state object is already pretty enormous, and state.playing already contains the current infohash + file index we're playing. I think that's enough state to implement skip-forward, skip-back, and automatically playing the next file after one finishes.
  • I don't know if we want to add Repeat and Shuffle.

Here's why:

  • Autoplay is great for listening to an album or audiobook, but Shuffle inside a single torrent isn't that useful, right? Usually people want to shuffle across a whole collection.
  • We want to keep the app minimalist
  • We want users (and reviewers) to think of us as a great torrent app, not as an OK media library. Adding a Shuffle and Repeat button starts to feel like ITunes / Media Player / etc.

The new UI (menu buttons plus player icons for skipping forward and back) looks great to me.

@dcposch
Copy link
Contributor

dcposch commented Sep 1, 2016

Tempted to merge this now and make a follow up PR to avoid conflicts with #863

CC @feross @mathiasvr

this._shuffled = false
}

// =============================================================================
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't add ascii banners like this. We don't have them anywhere else in the code

@mathiasvr
Copy link
Contributor

Just tested it, and I get this error when it auto skips to next track:

undefined:1 Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause().

This is probably a Chrome issue as discussed in #599. Not sure if it's serious though.

.filter((object) => TorrentPlayer.isPlayable(object.file))
.sort(function (a, b) {
if (a.file.name < b.file.name) return -1
if (b.file.name < a.file.name) return 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to sort the files by name? I think preserving the original order makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Files in torrent list are displayed alpabetically, so I think it's reasonable to keep that order. Also, when we stick to file indices, the sequence appears totally random.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have an example? All torrents I've checked is ordered reasonably.

Copy link
Contributor Author

@Goldob Goldob Sep 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just checked and you are right. I had problem with one particular torrent and that's why I assumed it would be the case everywhere.

That said, getting rid of file sorting would let for yet another simplification of the code.

Anyway, for the sake of consistency, I think the alphabetical order should go either both in playlists and torrent list or none of them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Goldob @mathiasvr I agree, I think keeping the original order is probably a good idea.

@feross what was the reason for sorting torrents alphabetically?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess sort by name is okay.
I agree that it should be consistent, maybe it would be easier to sort the files initially and stick with that order everywhere else?

@Goldob
Copy link
Contributor Author

Goldob commented Sep 1, 2016

Thank you very much for the feedback! I'll introduce the suggested changes.

The shuffle and repeat options are here only because I implemented them in the original branch (before rebase). I'll revert the commit and you'll be able to just skip it when merging.

@mathiasvr, similar error appears sometimes if you change tracks too fast. It is caused by the Chrome issue, just like you said. In case of autoplaying my guess is that it tries to replay the file after reaching the end, but before it is able to do that, new media object replaces it.

@dcposch
Copy link
Contributor

dcposch commented Sep 2, 2016

@Goldob looks great. I have a few nitpicks still but they're really small and easy to fix later. 🚢 🚢 🚢

@dcposch dcposch merged commit 3073230 into webtorrent:master Sep 2, 2016
@Goldob Goldob deleted the playlists branch September 2, 2016 06:13
@Goldob
Copy link
Contributor Author

Goldob commented Sep 2, 2016

Awesome to see that merged. One remark from me, before actually releasing this it would be nice to add a line to renderer/lib/migrations.js to remove torrentSummary.defaultPlayFileIndex, because we don't use it anymore.

@dcposch
Copy link
Contributor

dcposch commented Sep 2, 2016

@Goldob fixed b8effff

@Goldob Goldob mentioned this pull request Sep 6, 2016
@lock lock bot locked as resolved and limited conversation to collaborators May 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants