4
0
mirror of https://github.com/AzuraCast/AzuraCast.git synced 2024-06-15 13:46:37 +00:00

#757 -- Label new (improved) functionality "Shuffle" and re-enable true random.

This commit is contained in:
Buster "Silver Eagle" Neece 2018-08-29 19:45:01 -05:00
parent f44093a6df
commit cc5d3f6db9
4 changed files with 53 additions and 7 deletions

View File

@ -137,10 +137,11 @@ return [
'label' => __('Song Playback Order'),
'required' => true,
'choices' => [
StationPlaylist::ORDER_RANDOM => __('Random (Shuffled)'),
StationPlaylist::ORDER_SHUFFLE => __('Shuffled'),
StationPlaylist::ORDER_RANDOM => __('Random'),
StationPlaylist::ORDER_SEQUENTIAL => __('Sequential'),
],
'default' => StationPlaylist::ORDER_RANDOM,
'default' => StationPlaylist::ORDER_SHUFFLE,
],
],

View File

@ -0,0 +1,42 @@
<?php declare(strict_types=1);
namespace App\Entity\Migration;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20180830003036 extends AbstractMigration
{
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('SELECT 1');
}
public function postUp(Schema $schema)
{
$this->connection->update('station_playlists', [
'playback_order' => 'shuffle',
], [
'playback_order' => 'random',
]);
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('SELECT 1');
}
public function postDown(Schema $schema)
{
$this->connection->update('station_playlists', [
'playback_order' => 'random',
], [
'playback_order' => 'shuffle',
]);
}
}

View File

@ -26,11 +26,9 @@ class StationPlaylist
public const SOURCE_REMOTE_URL ='remote_url';
public const ORDER_RANDOM = 'random';
public const ORDER_SHUFFLE = 'shuffle';
public const ORDER_SEQUENTIAL = 'sequential';
// public const SOURCE_RANDOM = 'random_songs';
// public const SOURCE_SEQUENTIAL = 'sequential_songs';
/**
* @Column(name="id", type="integer")
* @Id
@ -163,7 +161,7 @@ class StationPlaylist
$this->type = self::TYPE_DEFAULT;
$this->source = self::SOURCE_SONGS;
$this->order = self::ORDER_RANDOM;
$this->order = self::ORDER_SHUFFLE;
$this->is_enabled = 1;
$this->weight = 3;

View File

@ -310,8 +310,13 @@ class AutoDJ
$media_queue[] = $media_row['id'];
}
if ($playlist->getOrder() === Entity\StationPlaylist::ORDER_RANDOM) {
if ($playlist->getOrder() === Entity\StationPlaylist::ORDER_SHUFFLE) {
// Build a queue with the song arrangement randomized.
shuffle($media_queue);
} else if ($playlist->getOrder() === Entity\StationPlaylist::ORDER_RANDOM) {
// The queue should always consist of one randomly selected song.
shuffle($media_queue);
$media_queue = [array_pop($media_queue)];
}
}