This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Dynamic Playlist - Random by Score

Tags: None
(comma "," separated)
Zimzat
Karma
0

Dynamic Playlist - Random by Score

Fri Aug 12, 2005 9:22 am
I was looking at the dynamic playlist options and noticed that simply \"Random\" doesn\'t work very well, at least not for me. I have some tracks in my \"Music\" folder that aren\'t music and thus I don\'t want them to play, but I\'d rather not move them from my Music folder and the scanner would pick them up even if I manually took them out of the collection.

Thus, this got me thinking on qualifying the \"Random\" playlist by score. The random\'s chance of picking a track would be based on its score. For example, a track with a score would have a 83 would have a 83% chance of being picked, and anything not rated (ie, the tracks I don\'t want to play) wouldn\'t get picked (unlike pure random right now). The way this could work in code would be like the following: (Note, I do web programming in PHP & MySQL so that\'s what I\'ll make my example will be in)

$random = rand(1, 100);
$sql = \"SELECT * FROM `songs` WHERE `score` > \'\" . $random . \"\' ORDER BY RAND() LIMIT 1\";

This would pick a single track with a score greater than $random. If you\'re so concerned about it not returning anything then do this first instead

$sql = \"SELECT MAX(`score`) FROM `songs`\";
if ($result == 0) exit;
$random = rand(1, $result);

Thought this would be more useful than simple random. ;)
Frido Roose
Karma
0
This sounds like a nice idea. Actually, I\'m missing something similar. The \"Favorite tracks\" playlist only selects the top 15 of the most rated tracks.

I wouldn\'t replace the current random function with this though, but it would be nice as a special mode, like you have dynamic mode. This could be a random favorite mode.

As you pointed out, it should be pretty easy to implement...


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], Yahoo [Bot]