
A new core playlist for VLC 4 - rom1v
https://blog.rom1v.com/2019/05/a-new-core-playlist-for-vlc-4/
======
AdmiralAsshat
Since this has turned into a "dump on VLC" thread: thank-you, VLC devs, for
all the work that you do. I've been a diehard VLC user since 2006/2007, when I
happily discovered a single .exe program could handle all of the files that I
was continuously updating the ever-growing K-Lite Media Pack in order to
handle. It found additional use as a Portable App that lived on the flash
drive in my pocket, allowing me to pull it out at late-night piracy parties
and confidently play the unviewable file that someone had grabbed off Kazaa.

To this day, it's the one program I can recommend to friends and family to
install, regardless of OS/platform, that I will be confident can handle
anything they throw at it. You guys do great work.

~~~
munk-a
VLC is amazing, I love the work you guys are doing and heartily recommend it
to my friends and family as well!

------
PetitPrince
> The randomizer stores a single vector containing all the items of the
> playlist. This vector is not shuffled at once. Instead, steps of the Fisher-
> Yates algorithm are executed one-by-one on demand.

Fisher-Yates is the generalization of what is known as the "7-bag randomizer"
in the Tetris community (same problem: you want to distribute 7 pieces
randomly but want to avoid repetition). It's funny how what you think as
inconsequential trivia about your niche hobby can turn out in unexpected
places !

~~~
Normal_gaussian
Fisher-Yates was one of the first algorithms my CS course exposed me to;
nicknamed the knuth shuffle, not 100% why but it is in TAOCP.

I implement it relatively frequently (~once a year) as it is often quicker to
write than find an implementation.

Surveying some peers I was very surprised to find they weren't aware of it!

~~~
vanderZwan
IIRC, Knuth made it famous (because TAOCP). Often with the naming of these
things there is a misalignment with who discovered/published it first and who
popularized it first.

(I personally think naming the algorithm after both is a good compromise)

------
pilif
_> But here, we’re in C, so there is nothing_

there's your problem.

I mean, I'm sure your `vlc_vector` you've spent so much time optimizing and
securing is as good as or even better than `other_project_vector` and
`some_library_vector` or maybe even `some_other_vector`

All of which were implemented by various projects out of necessity because the
language they chose doesn't have such an essential data structure in its
standard library and because the culture around the language values NIH more
than anything else.

Remind me again, why C is a good thing and not a liability these days?

~~~
leetcrew
c and c++ are still great choices when you care more about performance than
correctness.

a media player doesn't (or shouldn't at least) modify any of my essential
data, so the worst it can really do is crash every now and then. for a program
like vlc, mild instability is not a bad trade-off if it means less dropped
frames on old computers.

~~~
wgoodall01
I wouldn't agree with that---media players are often fed untrusted content
from the Internet, so a security issue in a shared media player API can be
critical. See the Android StageFright vulnerability from a few years back.

Writing it in C for a marginal performance gain just isn't worth it.

------
ttoinou
Will their ever fix the infinite loop you get when you open a broken file and
VLC just try to read the 1-file playlist indefinitely and the UI gets stuck
forever ?

~~~
rom1v
Definitely, we are aware of this stupid behavior, it will be fixed (at the
latest) in 4.0.

~~~
rom1v
I just proposed a patch to fix the problem on VLC 3:
[https://mailman.videolan.org/pipermail/vlc-
devel/2019-May/12...](https://mailman.videolan.org/pipermail/vlc-
devel/2019-May/124882.html)

(proposed != merged)

~~~
ttoinou

       Instead, wait some delay before starting the next item,   depending on the
      number of consecutive errors
    

That's smart !

What if I have two items on the playlist that both fails, is it going to
remember the number of consecutive errors ?

~~~
rom1v
> What if I have two items on the playlist that both fails, is it going to
> remember the number of consecutive errors ?

Yes, it will, the counter is reset only on successful playback.

------
jacobolus
I used VLC for years, but more recently have found the Mac app IINA
[https://iina.io/](https://iina.io/) to be a (not perfect but) substantially
nicer tool in the same niche (i.e. an open-source video player that handles
whatever I throw at it). VLC is just too full of incidental complication.

~~~
terramex
Two things that convinced me to switch to IINA was integrated subtitle
downloader and ability to position those subtitles onto lower matte in
letterboxed videos.

~~~
Philipp__
VLC has a plugin called VLsub which works almost perfectly as subtitle
downloader.

~~~
jbk
And it is inside VLC by default.

------
josteink
> User interfaces need random access to the playlist items, so a vector is the
> most natural structure to store the items. A vector is provided by the
> standard library of many languages (vector in C++, Vec in Rust, ArrayList in
> Java…). But here, we’re in C, so there is nothing.

I so do not miss working with C.

Having higher level abstractions and a working, useful standard library is
just too nice.

~~~
bo1024
This was the one that got me:

> model.get(4); // out-of-range, undefined behavior (probably segfault)

------
albertzeyer
This sounds interesting. I personally would be more interested though if it
would introduce some concept of an infinite queue, because that is usually the
way I listen to music. I want to be able to select some music and to queue
that, but when that finished, it should continue playing, with related/similar
songs, or maybe according to some other rules/genre or so.

Many other music players have this. Also e.g. Spotify. Or iTunes DJ mode.
Amarok had this. Sometimes it was called PartyShuffle.

I like the separation of the playlist/queue and the UI. But if it is an
infinite queue, it is not possible to get a full copy of it. Only maybe to the
finite preselected upcoming queue. But maybe that is not much of a problem
then. The core infinite logic usually is implemented like: If the queue of
songs contains less than N next songs, select some more songs from some
database, according to some probability distribution.

I implemented my own music player at some point, where my main focus was
around this concept of an infinite queue. ([https://github.com/albertz/music-
player/blob/master/WhatIsAM...](https://github.com/albertz/music-
player/blob/master/WhatIsAMusicPlayer.md#intelligent-automatic-queue)
[https://news.ycombinator.com/item?id=4771999](https://news.ycombinator.com/item?id=4771999))
One reason was that I wanted to take this concept much further than any
existing music player. E.g. even introducing some clever machine learning
models to guide the infinite music queue.

I was actually quite happy with it, but it took too much time to really
polish, to make it cross platform, etc. Now I mostly use Spotify, which gets
close to what I wanted to implement in the first place. And they are working
to improve the intelligent infinite queue, or generate playlists automatically
in other ways.

So, now that there is some work by VLC on the playlist, I was wondering, how
easy is it to extend that? E.g. maybe some Python interface, so I could maybe
plugin some neural network, and add new songs to it when it runs out of songs.
That would be really nice.

Related to that, what is the current state in VLC about other music player
related features, like e.g. gapless playback?

~~~
rom1v
IMO, an infinite queue does not really apply to VLC.

If all songs are correctly tagged (which cannot be assumed in VLC), what
Spotify does is interesting: [https://labs.spotify.com/2014/02/28/how-to-
shuffle-songs/](https://labs.spotify.com/2014/02/28/how-to-shuffle-songs/)

~~~
albertzeyer
Is there some API to be able to script VLC? E.g. that I can develop a
plugin/module or external app/script, where I have a DB, and maybe a GUI
(maybe web interface) for the DB as well.

For the API, I would need:

* Some way to get the current playlist. * Some way to get which item in the playlist is currently being played. * Some way to add items to the end of the playlist.

Also, maybe in addition:

* Some way to mark that the logic about playlist handling (adding to it, shuffling, etc) is handled by this external module (such that VLC does not do shuffling as well).

The logic of this external module is pretty simple then for the infinite
queue: When the currently played item reaches almost the end of the playlist,
it would add some more songs to it. For this logic, it would maybe also nice
to remove some of the earlier played songs (otherwise the playlist would just
grow and grow).

~~~
rom1v
> Is there some API to be able to script VLC?

[https://wiki.videolan.org/Documentation:Building_Lua_Playlis...](https://wiki.videolan.org/Documentation:Building_Lua_Playlist_Scripts/)

(I recently changed its implementation to use the new playlist/player [1], but
the API was kept unchanged not to break existing scripts)

[1]:
[https://code.videolan.org/videolan/vlc/commits/3b46a2c42c5c1...](https://code.videolan.org/videolan/vlc/commits/3b46a2c42c5c14d7ace68f1fab3846d88d23b4ef)

> Some way to mark that the logic about playlist handling (adding to it,
> shuffling, etc) is handled by this external module (such that VLC does not
> do shuffling as well)

Not supported.

------
saagarjha
> Thus, the playlist may not be bound to the event loop of some specific user
> interface. Moreover, the playlist may be modified from a player thread; for
> example, playing a zip archive will replace the item by its content
> automatically.

As you probably figured out, this is quite hard to do correctly :) I have a
similar design in some software I've written, but sadly I get a number of
crashes that tell me that I've haven't done it quite right…

------
plibither8
Edit: It's online again.

The website seems to be unreachable right now, here's the archived version:
[http://web.archive.org/web/20190522045257/https://blog.rom1v...](http://web.archive.org/web/20190522045257/https://blog.rom1v.com/2019/05/a-new-
core-playlist-for-vlc-4/)

------
mikevm
I dumped VLC due to the simple reason that when a video is paused, it will
stop the computer from going to sleep. The developer thinks this behavior is
OK and refused to fix it so I just found a nicer and minimalist player called
[https://mpv.io/](https://mpv.io/)

~~~
rom1v
> when a video is paused, it will stop the computer from going to sleep

This seems to be fixed:

\-
[https://trac.videolan.org/vlc/ticket/3724](https://trac.videolan.org/vlc/ticket/3724)

\-
[https://trac.videolan.org/vlc/ticket/19463](https://trac.videolan.org/vlc/ticket/19463)

\-
[https://trac.videolan.org/vlc/ticket/20092](https://trac.videolan.org/vlc/ticket/20092)

------
fabioborellini
Last time I downloaded VLC on Windows, an ad on the download page started
download for "VLC Torrent Streamer" or something equally confusing. I never
launched that EXE but started wondering what kind of crapware I would have
gotten if I had.

I thought VLC was better than scams like that.

~~~
ahje
When I look at the download page now, there are no ads (disclaimer: I use an
ad-blocker and I use noscript). Furthermore, VLC is available from the
Microsoft Store, so that you don't have to fetch untrusted executables anyway.

~~~
TorKlingberg
Here is what the official Videolan download page looks like on Windows Chrome
without adblocker: [https://imgur.com/a/ZWZdtk5](https://imgur.com/a/ZWZdtk5)

The VLC download is started in the background, but the "Download Now" buttons
are highly misleading. This time it's Avast rather than "VLC Torrent
Streamer".

Videolan should be ashamed using dark patterns to trick people into installing
adware.

~~~
ahje
Jeez, it's easy to forget how unusable the web is without an adblocker
nowadays.

------
DiseasedBadger
VLC continues to be riddled with crashes in the menus, because of a bug in how
they use A List, that is almost 10 years old.

The only way I can make sense of it, is that they must build VLC against a
modified Qt distribution, or something they just never update.

I've totally switched to SMPlayer and MPV.

~~~
rom1v
> VLC continues to be riddled with crashes in the menus, because of a bug in
> how they use A List, that is almost 10 years old.

Could you be more specific, please? Which menu, in which circumstances?

~~~
DiseasedBadger
I'd have to install it again to reproduce it, but I believe there are several
menus that don't expect certain things to be empty.

I think one triggers when selecting "Open Capture Device".

There is a closed bug report for this, that was closed I think as unable to
reproduce. Years old.

I'll see if I can get back to exactly what it was.

------
enriquto
Why does a video viewer need a "playlist"? Isn't that feature already
accomplished by the file open dialog?

~~~
TazeTSchnitzel
Why does an HTML viewer need history and tabs? Aren't these features already
accomplished by the xterm window the user must be invoking it from?

~~~
LeoPanthera
You're being sarcastic, but there's a grain of truth in your argument against
tabs. It does feel like the kind of thing the OS should provide for _any_ app.

------
npstr
The VLC Android App is unusable since an update earlier this year. Any plans
to fix that? I reverted to an older version and would like to come aboard
again once the bugs are fixed & bad UI decisions corrected. There was plenty
of feedback on the playstore to act on and there was at least one bug fix
release, but current reviews are still negative :/

~~~
BigJono
Unusable in what way? It's still working just fine for me.

~~~
anoncake
It can't play some videos properly for me but otherwise, it works for me too.

------
Krasnol
Just downloaded the nightly build...it's horrible. I hope there is a way to
reverse everything to how it is at the moment.

There is a point in software where the UI reaches it's optimum. It is at that
point with VLC atm. I never had any issues with the playlist. The playlist is
not a especially relevant part in the whole thing. I drag files/folder in
there and it does what it does.

Please don't overdo it...

I'd rather see the render to chromecast issues fixed. Can't pause with VLC or
the video stops after a few seconds resuming and I need to start over.

~~~
rom1v
> I never had any issues with the playlist. The playlist is not a especially
> relevant part in the whole thing.

The playlist rewrite I detail in this blogpost is an internal technical
refactor, so you're absolutely right, it's not a relevant thing for the users.

It is independant of the UI. In theory, it could have been used with the old
UI, but technically a big part of the old UI code would have needed to be
rewritten to use the new core playlist.

Since a new modern UI is being developed, this was not worth the effort to do
the work twice. So only the new UI will use the new playlist/player.

> Just downloaded the nightly build...it's horrible. I hope there is a way to
> reverse everything to how it is at the moment.

The master branch is a development branch. Everything has been merged recently
to avoid that everyone work on their own branch and resolve conflicts all the
time, and the new components need to interact (playlist, player, clock, media
library, qt ui…). But it's in development, it's not a release.

~~~
stevekemp
12 years ago I wrote a blog post being annoyed that when using Xine in "random
shuffle" mode - pressing "previous track" did not replay the previous track.

[https://blog.steve.fi/it_eats_the_pain.html](https://blog.steve.fi/it_eats_the_pain.html)

If VLC can now do that properly, which I think is what I took from your blog
post, that's a huge change which makes me very happy, and would make me switch
back.

~~~
rom1v
I'm glad that supporting "previous" in random mode will not be useless, then
:)

------
Kaiyou
Did VLC ever lose it's reputation of being the worst video player of all time?

~~~
TeMPOraL
It never had it. It had, and probably still has, the reputation of being the
_best_ video player on Windows - it was bullshit-free, and the only one that
worked OOTB with whatever you threw at it, without making you install these
things called "codecs".

~~~
Kaiyou
VLC being the worst thing ever was a meme back in 2007. Everyone saying that
he used it got flamed into oblivion.

~~~
oblio
The Internet is a big place, we were probably hanging out in different circles
cause I never heard that.

~~~
TeMPOraL
Indeed. In my circles around that time we were all switching _to_ VLC.

