Browse Source

Evolution #790: playlist: aléatoire

Bastien Sevajol 11 years ago
parent
commit
6213c2f621

+ 0 - 0
src/Muzich/CoreBundle/Factory/Elements/Sndsc.php View File


+ 13 - 0
src/Muzich/CoreBundle/Resources/public/css/main.css View File

2256
   float: left;
2256
   float: left;
2257
 }
2257
 }
2258
 
2258
 
2259
+a.button.simpleimg
2260
+{
2261
+  padding: 6px;
2262
+  
2263
+}
2264
+
2265
+a.button.simpleimg img
2266
+{
2267
+  float: none;
2268
+}
2269
+
2270
+
2271
+
2259
 a.button span
2272
 a.button span
2260
 {
2273
 {
2261
   float: left;
2274
   float: left;

+ 5 - 0
src/Muzich/CoreBundle/lib/AutoplayManager.php View File

60
     return $list;
60
     return $list;
61
   }
61
   }
62
   
62
   
63
+  public function shuffle()
64
+  {
65
+    shuffle($this->elements);
66
+  }
67
+  
63
 }
68
 }

+ 4 - 1
src/Muzich/PlaylistBundle/Controller/ShowController.php View File

40
     ));
40
     ));
41
   }
41
   }
42
   
42
   
43
-  public function getAutoplayDataAction($playlist_id, $offset = null)
43
+  public function getAutoplayDataAction($playlist_id, $offset = null, $shuffle = false)
44
   {
44
   {
45
     if (($uncondition = $this->userHaveNonConditionToMakeAction(SecurityContext::ACTION_PLAYLIST_DATA_AUTOPLAY)) !== false)
45
     if (($uncondition = $this->userHaveNonConditionToMakeAction(SecurityContext::ACTION_PLAYLIST_DATA_AUTOPLAY)) !== false)
46
       return $this->jsonResponseError($uncondition);
46
       return $this->jsonResponseError($uncondition);
51
     
51
     
52
     $autoplaym = new AutoplayManager($playlist_manager->getPlaylistElements($playlist, $offset), $this->container);
52
     $autoplaym = new AutoplayManager($playlist_manager->getPlaylistElements($playlist, $offset), $this->container);
53
     
53
     
54
+    if ($shuffle)
55
+      $autoplaym->shuffle();
56
+    
54
     return $this->jsonResponse(array(
57
     return $this->jsonResponse(array(
55
       'status'    => 'success',
58
       'status'    => 'success',
56
       'data'      => $autoplaym->getList()
59
       'data'      => $autoplaym->getList()

+ 7 - 1
src/Muzich/PlaylistBundle/Resources/config/routing.yml View File

28
 
28
 
29
 playlist_datas_for_autoplay:
29
 playlist_datas_for_autoplay:
30
   pattern: /ajax/autoplay/playlist/datas/{playlist_id}/{offset}
30
   pattern: /ajax/autoplay/playlist/datas/{playlist_id}/{offset}
31
-  defaults: { _controller: MuzichPlaylistBundle:Show:getAutoplayData, offset: null }
31
+  defaults: { _controller: MuzichPlaylistBundle:Show:getAutoplayData, offset: null, shuffle: false }
32
+  requirements:
33
+    offset:  \d+
34
+  
35
+playlist_datas_for_autoplay_shuffle:
36
+  pattern: /ajax/autoplay/playlist/datas/{playlist_id}/shuffle
37
+  defaults: { _controller: MuzichPlaylistBundle:Show:getAutoplayData, offset: null, shuffle: true }
32
 
38
 
33
 playlist_update_order:
39
 playlist_update_order:
34
   pattern: /ajax/playlist/order/update/{playlist_id}/{token}
40
   pattern: /ajax/playlist/order/update/{playlist_id}/{token}

+ 4 - 0
src/Muzich/PlaylistBundle/Resources/views/Show/show.html.twig View File

11
       <a class="autoplay_playlist button darkbutton" href="{{ path('playlist_datas_for_autoplay', { 'playlist_id' : playlist.id }) }}" >
11
       <a class="autoplay_playlist button darkbutton" href="{{ path('playlist_datas_for_autoplay', { 'playlist_id' : playlist.id }) }}" >
12
         {{ 'playlist.read'|trans({}, 'elements') }}
12
         {{ 'playlist.read'|trans({}, 'elements') }}
13
       </a>
13
       </a>
14
+      
15
+      <a class="autoplay_playlist button simpleimg darkbutton" href="{{ path('playlist_datas_for_autoplay_shuffle', { 'playlist_id' : playlist.id}) }}" >
16
+        <img src="{{ asset('/img/1372889556_random_shuffle.png') }}" alt="shuffle" />
17
+      </a>
14
 
18
 
15
       {% if app.user %}
19
       {% if app.user %}
16
         {% if not playlist.owned(app.user) and viewed_user.id != app.user.id %}
20
         {% if not playlist.owned(app.user) and viewed_user.id != app.user.id %}

BIN
web/img/1372889556_random_shuffle.png View File


+ 0 - 0
web/img/Floor26_design.png View File