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:
parent
f44093a6df
commit
cc5d3f6db9
|
@ -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,
|
||||
],
|
||||
],
|
||||
|
||||
|
|
42
src/Entity/Migration/Version20180830003036.php
Normal file
42
src/Entity/Migration/Version20180830003036.php
Normal 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',
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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)];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user