Browse Source

Merge branch 'feature/v0.9/autoplayer' into stable/v0.9

Sevajol Bastien 12 years ago
parent
commit
c0598432b2
29 changed files with 863 additions and 73 deletions
  1. 4 0
      app/Resources/translations/elements.fr.yml
  2. 140 0
      src/Muzich/CoreBundle/Controller/ElementController.php
  3. 6 0
      src/Muzich/CoreBundle/Entity/Element.php
  4. 11 0
      src/Muzich/CoreBundle/Factory/Elements/Soundcloudcom.php
  5. 16 1
      src/Muzich/CoreBundle/Resources/config/routing.yml
  6. 79 54
      src/Muzich/CoreBundle/Resources/views/SearchElement/element.html.twig
  7. 30 0
      src/Muzich/CoreBundle/Resources/views/layout.html.twig
  8. 64 0
      src/Muzich/CoreBundle/lib/AutoplayManager.php
  9. 7 3
      src/Muzich/FavoriteBundle/Controller/FavoriteController.php
  10. 16 1
      src/Muzich/FavoriteBundle/Resources/views/Favorite/myList.html.twig
  11. 17 1
      src/Muzich/FavoriteBundle/Resources/views/Favorite/userList.html.twig
  12. 9 4
      src/Muzich/HomeBundle/Controller/ShowController.php
  13. 9 0
      src/Muzich/HomeBundle/Resources/views/Home/index.html.twig
  14. 16 1
      src/Muzich/HomeBundle/Resources/views/Show/showGroup.html.twig
  15. 16 1
      src/Muzich/HomeBundle/Resources/views/Show/showUser.html.twig
  16. 62 6
      web/bundles/muzichcore/css/main.css
  17. BIN
      web/bundles/muzichcore/img/1353494305_player_play.png
  18. BIN
      web/bundles/muzichcore/img/1353498913_window-close.png
  19. BIN
      web/bundles/muzichcore/img/1353503730_button-previous.png
  20. BIN
      web/bundles/muzichcore/img/1353503762_button-next.png
  21. BIN
      web/bundles/muzichcore/img/1353505865_button_previous.png
  22. BIN
      web/bundles/muzichcore/img/1353505874_button_next.png
  23. BIN
      web/bundles/muzichcore/img/player_end.png
  24. BIN
      web/bundles/muzichcore/img/player_pause.png
  25. BIN
      web/bundles/muzichcore/img/player_play.png
  26. BIN
      web/bundles/muzichcore/img/player_start.png
  27. 313 0
      web/bundles/muzichcore/js/autoplay.js
  28. 44 1
      web/bundles/muzichcore/js/muzich.js
  29. 4 0
      web/js/swfobject.js

+ 4 - 0
app/Resources/translations/elements.fr.yml View File

@@ -88,6 +88,10 @@ elements:
88 88
   ajax:
89 89
     more:
90 90
       noelements:       Pas d'autres éléments
91
+  autoplay:
92
+    launch:             Lecture automatique
93
+    noelements:
94
+      text:             Aucun partage a lire
91 95
       
92 96
 show:
93 97
   user:

+ 140 - 0
src/Muzich/CoreBundle/Controller/ElementController.php View File

@@ -10,6 +10,8 @@ use Symfony\Component\HttpFoundation\Request;
10 10
 use Muzich\CoreBundle\Entity\Element;
11 11
 use Muzich\CoreBundle\Util\TagLike;
12 12
 use Muzich\CoreBundle\Entity\User;
13
+use Muzich\CoreBundle\lib\AutoplayManager;
14
+use Muzich\CoreBundle\Searcher\ElementSearcher;
13 15
 
14 16
 class ElementController extends Controller
15 17
 {
@@ -985,4 +987,142 @@ class ElementController extends Controller
985 987
     ));
986 988
   }
987 989
   
990
+  /**
991
+   * Retourne les données permettant de faire une playlist
992
+   * 
993
+   * @param Request $request 
994
+   * @param "filter"|"show"|"favorites" $type
995
+   * @param ~ $data
996
+   */
997
+  public function getDatasAutoplayAction(Request $request, $type, $data, $show_type = null, $show_id = null)
998
+  {
999
+    if (($response = $this->mustBeConnected(true)))
1000
+    {
1001
+      return $response;
1002
+    }
1003
+    
1004
+    $elements = array();
1005
+    $elements_json = array();
1006
+    
1007
+    if ($type == 'filter')
1008
+    {
1009
+      // Pour cette option on utilise le dernier filtre appliqué
1010
+      $search_object = $this->getElementSearcher();
1011
+      $search_object->update(array(
1012
+        'count' => $this->container->getParameter('autoplay_max_elements')
1013
+      ));
1014
+      $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId());
1015
+    }
1016
+    elseif ($type == 'show')
1017
+    {
1018
+      if ($show_type != 'user' && $show_type != 'group')
1019
+      {
1020
+        throw $this->createNotFoundException('Not found');
1021
+      }
1022
+      
1023
+      $tags = null;
1024
+      $tag_ids = json_decode($data);
1025
+      $search_object = new ElementSearcher();
1026
+      
1027
+      if (count($tag_ids))
1028
+      {
1029
+        $tags = array();
1030
+        foreach ($tag_ids as $id)
1031
+        {
1032
+          $tags[$id] = $id;
1033
+        }
1034
+      }
1035
+
1036
+      $search_object->init(array(
1037
+        'tags'           => $tags,
1038
+        $show_type.'_id' => $show_id,
1039
+        'count'          => $this->container->getParameter('autoplay_max_elements')
1040
+      ));
1041
+      
1042
+      $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId());
1043
+    }
1044
+    elseif ($type == 'favorite')
1045
+    {
1046
+      $tags = null;
1047
+      $tag_ids = json_decode($data);
1048
+      $search_object = new ElementSearcher();
1049
+      
1050
+      if (count($tag_ids))
1051
+      {
1052
+        $tags = array();
1053
+        foreach ($tag_ids as $id)
1054
+        {
1055
+          $tags[$id] = $id;
1056
+        }
1057
+      }
1058
+
1059
+      $search_object->init(array(
1060
+        'tags'     => $tags,
1061
+        'user_id'  => $show_id,
1062
+        'favorite' => true,
1063
+        'count'    => $this->container->getParameter('autoplay_max_elements')
1064
+      ));
1065
+      
1066
+      $elements = $search_object->getElements($this->getDoctrine(), $this->getUserId());
1067
+    }
1068
+    
1069
+    if (count($elements))
1070
+    {
1071
+      // On récupère les élements
1072
+      $autoplaym = new AutoplayManager($elements, $this->container);
1073
+      $elements_json = $autoplaym->getList();
1074
+    }
1075
+    
1076
+    return $this->jsonResponse(array(
1077
+      'status'    => 'success',
1078
+      'data'      => $elements_json
1079
+    ));
1080
+  }
1081
+  
1082
+  public function getOneDomAction(Request $request, $element_id, $type)
1083
+  {
1084
+    if (($response = $this->mustBeConnected()))
1085
+    {
1086
+      return $response;
1087
+    }
1088
+    
1089
+    if (!in_array($type, array('autoplay')))
1090
+    {
1091
+      return $this->jsonResponse(array(
1092
+        'status' => 'error',
1093
+        'errors' => array('NotAllowed')
1094
+      ));
1095
+    }
1096
+    
1097
+    // variables pour le template
1098
+    $display_edit_actions  = true;
1099
+    $display_player        = true;
1100
+    $display_comments      = true;
1101
+    
1102
+    if ($type == 'autoplay')
1103
+    {
1104
+      $display_edit_actions  = false;
1105
+      $display_player        = false;
1106
+      $display_comments      = false;
1107
+    }
1108
+    
1109
+    if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
1110
+      ->findOneById($element_id)))
1111
+    {
1112
+      throw $this->createNotFoundException('Not found');
1113
+    }
1114
+    
1115
+    $html = $this->render('MuzichCoreBundle:SearchElement:element.html.twig', array(
1116
+      'element'               => $element,
1117
+      'display_edit_actions'  => $display_edit_actions,
1118
+      'display_player'        => $display_player,
1119
+      'display_comments'      => $display_comments
1120
+    ))->getContent();
1121
+    
1122
+    return $this->jsonResponse(array(
1123
+      'status'  => 'success',
1124
+      'data'    => $html
1125
+    ));
1126
+  }
1127
+  
988 1128
 }

+ 6 - 0
src/Muzich/CoreBundle/Entity/Element.php View File

@@ -28,6 +28,12 @@ class Element
28 28
    * @var string 
29 29
    */
30 30
   const DATA_REF_ID         = "data_ref_id";
31
+  
32
+  /**
33
+   * Identifiant de l'objet externe
34
+   * @var string 
35
+   */
36
+  const DATA_NORMALIZED_URL = "data_normalized_url";
31 37
   /**
32 38
    * Adresse HTTP(S) de la jaquette
33 39
    * @var string 

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

@@ -154,6 +154,11 @@ class Soundcloudcom extends ElementFactory
154 154
         {
155 155
           $this->element->setData(Element::DATA_REF_ID, $result['id']);
156 156
         }
157
+        
158
+        if (array_key_exists('uri', $result) )
159
+        {
160
+          $this->element->setData(Element::DATA_NORMALIZED_URL, $result['uri']);
161
+        }
157 162
 
158 163
         if (array_key_exists('artwork_url', $result) )
159 164
         {
@@ -214,6 +219,12 @@ class Soundcloudcom extends ElementFactory
214 219
           .'width="100%" name="embed_'.$embed_id.'"></embed>
215 220
         </object>'
216 221
       );
222
+//      $this->element->setEmbed(
223
+//        '<iframe id="sc-widget_'.$this->element->getData(Element::DATA_REF_ID).
224
+//          '" src="http://w.soundcloud.com/player/?url='.
225
+//          $ref_id.'" width="100%" '.
226
+//          'height="'.$height.'" scrolling="no" frameborder="no"></iframe>'
227
+//      );
217 228
     }
218 229
   }
219 230
   

+ 16 - 1
src/Muzich/CoreBundle/Resources/config/routing.yml View File

@@ -159,8 +159,23 @@ teapot:
159 159
 element_retrieve_api_datas:
160 160
   pattern: /ajax/element/get/datas/api
161 161
   defaults: { _controller: MuzichCoreBundle:Element:getDatasApi }
162
-  requirements:
162
+    
163
+elements_get_filter_data_autoplay:
164
+  pattern: /ajax/elements/get/datas/autoplay/{type}/{data}
165
+  defaults: { _controller: MuzichCoreBundle:Element:getDatasAutoplay, data: null }
166
+    
167
+elements_get_filter_data_autoplay_show:
168
+  pattern: /ajax/show/{show_type}/{show_id}/elements/get/datas/autoplay/{data}
169
+  defaults: { _controller: MuzichCoreBundle:Element:getDatasAutoplay, type: 'show', data: null }
170
+    
171
+elements_get_filter_data_autoplay_favorite:
172
+  pattern: /ajax/favorite/{show_type}/{show_id}/elements/get/datas/autoplay/{data}
173
+  defaults: { _controller: MuzichCoreBundle:Element:getDatasAutoplay, type: 'favorite', data: null }
163 174
     
164 175
 element_show_need_tags:
165 176
   pattern: /need-tags
166 177
   defaults: { _controller: MuzichHomeBundle:Home:needTags }
178
+
179
+element_dom_get_one:
180
+  pattern: /ajax/element/dom/get/{type}/{element_id}
181
+  defaults: { _controller: MuzichCoreBundle:Element:getOneDom, element_id: null }

+ 79 - 54
src/Muzich/CoreBundle/Resources/views/SearchElement/element.html.twig View File

@@ -1,9 +1,19 @@
1
+{% if display_edit_actions is not defined %}
2
+  {% set display_edit_actions = true %}
3
+{% endif %}
4
+{% if display_player is not defined %}
5
+  {% set display_player = true %}
6
+{% endif %}
7
+{% if display_comments is not defined %}
8
+  {% set display_comments = true %}
9
+{% endif %}
10
+
1 11
 <table>
2 12
   <tr>
3 13
     <td class="element_thumbnail">
4 14
       
5 15
       {% if element.embed %}
6
-        <a href="#" class="a_thumbnail element_open element_embed_open_link {% if element.embed %}embed{% else %}noembed{% endif %}">
16
+        <a href="#" class="a_thumbnail {% if display_player %}element_open element_embed_open_link{% endif %} {% if element.embed and display_player %}embed{% else %}noembed{% endif %}">
7 17
           <img class="play" style="display: none;" src="{{ asset('bundles/muzichcore/img/1328283150_media-playback-start.png') }}" alt="" />
8 18
           <img 
9 19
             class="element_thumbnail"
@@ -53,47 +63,55 @@
53 63
       
54 64
       {% if app.user.id != element.owner.id %}
55 65
       
56
-        <a title="{{ 'element.proposition_tags.link_title'|trans({}, 'userui') }}" 
57
-          class="element_propose_tags" 
58
-          href="{{ path('ajax_element_propose_tags_open', {'element_id' : element.id}) }}">
59
-          <img src="{{ asset('bundles/muzichcore/img/1333484018_rss-tag.png') }}" alt="tags_proposition" />
60
-        </a>
61
-        
62
-        <a title="{{ 'element.reshare.link_title'|trans({}, 'userui') }}" 
63
-          class="element_reshare" 
64
-          href="{{ path('ajax_reshare_element', {'element_id':element.id, 'token':app.user.getPersonalHash('reshare_'~element.id)}) }}">
65
-          <img src="{{ asset('bundles/muzichcore/img/1349338086_adept_update.png') }}" alt="re" />
66
-        </a>
66
+      {% if display_edit_actions %}
67 67
       
68
-        <a title="{{ 'element.report.link_title'|trans({}, 'userui') }}" 
69
-          class="element_report" 
70
-          href="{{ path('ajax_report_element', {'element_id':element.id, 'token':app.user.getPersonalHash}) }}">
71
-          <img src="{{ asset('bundles/muzichcore/img/1331832708_comment_alert.png') }}" alt="report" />
72
-        </a>
68
+          <a title="{{ 'element.proposition_tags.link_title'|trans({}, 'userui') }}" 
69
+            class="element_propose_tags" 
70
+            href="{{ path('ajax_element_propose_tags_open', {'element_id' : element.id}) }}">
71
+            <img src="{{ asset('bundles/muzichcore/img/1333484018_rss-tag.png') }}" alt="tags_proposition" />
72
+          </a>
73
+
74
+          <a title="{{ 'element.reshare.link_title'|trans({}, 'userui') }}" 
75
+            class="element_reshare" 
76
+            href="{{ path('ajax_reshare_element', {'element_id':element.id, 'token':app.user.getPersonalHash('reshare_'~element.id)}) }}">
77
+            <img src="{{ asset('bundles/muzichcore/img/1349338086_adept_update.png') }}" alt="re" />
78
+          </a>
79
+
80
+          <a title="{{ 'element.report.link_title'|trans({}, 'userui') }}" 
81
+            class="element_report" 
82
+            href="{{ path('ajax_report_element', {'element_id':element.id, 'token':app.user.getPersonalHash}) }}">
83
+            <img src="{{ asset('bundles/muzichcore/img/1331832708_comment_alert.png') }}" alt="report" />
84
+          </a>
85
+      
86
+      {% endif %}
73 87
       
74 88
       {% endif %}
75 89
       
76 90
       {% if app.user.id == element.owner.id %}
77 91
       
78
-        {% if element.hasTagProposition %}
79
-          <a title="{{ 'element.view_propositions.link'|trans({}, 'elements') }}" class="element_view_propositions_link" 
80
-             href="{{ path('ajax_element_proposed_tags_view', {'element_id' : element.id})  }}"
92
+        {% if display_edit_actions %}
93
+      
94
+          {% if element.hasTagProposition %}
95
+            <a title="{{ 'element.view_propositions.link'|trans({}, 'elements') }}" class="element_view_propositions_link" 
96
+              href="{{ path('ajax_element_proposed_tags_view', {'element_id' : element.id})  }}"
97
+            >
98
+              <img src="{{ asset('bundles/muzichcore/img/1333493527_tag_add.png') }}" alt="tags proposition" />
99
+            </a>
100
+          {% endif %}
101
+
102
+          <a title="{{ 'element.edit.link'|trans({}, 'elements') }}" class="element_edit_link" 
103
+            href="{{ path('element_edit', {'element_id' : element.id})  }}" style="display: none;"
81 104
           >
82
-            <img src="{{ asset('bundles/muzichcore/img/1333493527_tag_add.png') }}" alt="tags proposition" />
105
+            <img src="{{ asset('bundles/muzichcore/img/1327151338_desktop.png') }}" alt="edit" />
106
+          </a>
107
+
108
+          <a title="{{ 'element.remove.link'|trans({}, 'elements') }}" class="element_remove_link" 
109
+            href="{{ path('element_remove', {'element_id' : element.id})  }}" style="display: none;"
110
+          >
111
+            <img src="{{ asset('bundles/muzichcore/img/1327168960_fileclose.png') }}" alt="delete" />
83 112
           </a>
84 113
         {% endif %}
85 114
       
86
-        <a title="{{ 'element.edit.link'|trans({}, 'elements') }}" class="element_edit_link" 
87
-           href="{{ path('element_edit', {'element_id' : element.id})  }}" style="display: none;"
88
-        >
89
-          <img src="{{ asset('bundles/muzichcore/img/1327151338_desktop.png') }}" alt="edit" />
90
-        </a>
91
-
92
-        <a title="{{ 'element.remove.link'|trans({}, 'elements') }}" class="element_remove_link" 
93
-           href="{{ path('element_remove', {'element_id' : element.id})  }}" style="display: none;"
94
-        >
95
-          <img src="{{ asset('bundles/muzichcore/img/1327168960_fileclose.png') }}" alt="delete" />
96
-        </a>
97 115
       {% endif %}
98 116
       
99 117
       <br />
@@ -162,28 +180,31 @@
162 180
         {{ 'element.show.close_embed'|trans({}, 'elements') }}
163 181
       </a>
164 182
       
183
+      {% if display_comments %}
165 184
       
166
-      {% autoescape false %}
167
-        {% if element.comments|length > 1 %}
168
-          <a href="#hide_comments_{{ element.id }}" class="hide_comments" style="display: none;">
169
-            {{ 'element.comments.hideare'|trans({}, 'elements') }}
170
-          </a>  
171
-          <a href="#comments_{{ element.id }}" class="display_comments">
172
-            {{ 'element.comments.thereare'|trans({'%count%':element.comments|length}, 'elements') }}
173
-          </a>
174
-        {% elseif element.comments|length == 1 %}
175
-          <a href="#hide_comments_{{ element.id }}" class="hide_comments" style="display: none;">
176
-            {{ 'element.comments.hideis'|trans({}, 'elements') }}
177
-          </a> 
178
-          <a href="#comments_{{ element.id }}" class="display_comments">
179
-            {{ 'element.comments.thereis'|trans({}, 'elements') }}
180
-          </a>
181
-        {%endif %}
182
-      {% endautoescape %}
183
-                
184
-      <a href="#add_comment_{{ element.id }}" class="add_comment">
185
-        {{ 'element.comments.add'|trans({}, 'elements') }}
186
-      </a>
185
+        {% autoescape false %}
186
+          {% if element.comments|length > 1 %}
187
+            <a href="#hide_comments_{{ element.id }}" class="hide_comments" style="display: none;">
188
+              {{ 'element.comments.hideare'|trans({}, 'elements') }}
189
+            </a>  
190
+            <a href="#comments_{{ element.id }}" class="display_comments">
191
+              {{ 'element.comments.thereare'|trans({'%count%':element.comments|length}, 'elements') }}
192
+            </a>
193
+          {% elseif element.comments|length == 1 %}
194
+            <a href="#hide_comments_{{ element.id }}" class="hide_comments" style="display: none;">
195
+              {{ 'element.comments.hideis'|trans({}, 'elements') }}
196
+            </a> 
197
+            <a href="#comments_{{ element.id }}" class="display_comments">
198
+              {{ 'element.comments.thereis'|trans({}, 'elements') }}
199
+            </a>
200
+          {%endif %}
201
+        {% endautoescape %}
202
+
203
+        <a href="#add_comment_{{ element.id }}" class="add_comment">
204
+          {{ 'element.comments.add'|trans({}, 'elements') }}
205
+        </a>
206
+      
207
+      {% endif %}
187 208
       
188 209
       
189 210
     </td>
@@ -245,7 +266,7 @@
245 266
 {% endif %}
246 267
 {% endif %}
247 268
 
248
-{% if element.embed %}
269
+{% if element.embed and display_player %}
249 270
   {% autoescape false %}
250 271
     <div id="embed_{{ element.id }}" class="element_embed" style="display: none;">
251 272
       {{ element.embed }}
@@ -253,6 +274,8 @@
253 274
   {% endautoescape %}
254 275
 {% endif %}
255 276
 
277
+{% if display_comments %}
278
+
256 279
   <div class="comments" style="display: none;">
257 280
     <ul class="comments">
258 281
     {% if element.comments|length %}
@@ -286,3 +309,5 @@
286 309
     </a>
287 310
       
288 311
   </div>
312
+
313
+{% endif %}

+ 30 - 0
src/Muzich/CoreBundle/Resources/views/layout.html.twig View File

@@ -23,6 +23,14 @@
23 23
   {% endif %}
24 24
   <script src="{{ asset('js/jquery-ui-1.8.7.min.js') }}" type="text/javascript"></script>
25 25
 	<script src="{{ asset('bundles/muzichcore/js/muzich.js') }}" type="text/javascript"></script>
26
+	
27
+  <script type="text/javascript" src="{{ asset('js/swfobject.js') }}"></script> 
28
+  
29
+       <script src="http://connect.soundcloud.com/sdk.js"></script>
30
+       <script src="http://w.soundcloud.com/player/api.js"></script>
31
+       
32
+  <script src="{{ asset('bundles/muzichcore/js/autoplay.js') }}" type="text/javascript"></script>
33
+  
26 34
   <script src="{{ asset('js/tags/jquery.autoGrowInput.js') }}" type="text/javascript"></script>
27 35
   <script src="{{ asset('js/tags/jquery.tagBox.js') }}" type="text/javascript"></script>
28 36
   <script src="{{ asset('js/formdefault/jquery.formdefaults.js') }}" type="text/javascript"></script>
@@ -68,6 +76,7 @@
68 76
     url_global_search = "{{ path('global_search') }}";
69 77
     url_datas_api = "{{ path('element_retrieve_api_datas') }}";
70 78
     url_element_add = "{{ path('element_add') }}";
79
+    url_element_dom_get_one_autoplay = "{{ path('element_dom_get_one', {'type':'autoplay'}) }}";
71 80
     
72 81
     url_img_ajax_loader = "{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}";
73 82
   </script>
@@ -76,6 +85,27 @@
76 85
 </head>
77 86
 <body>
78 87
   
88
+  <div id="autoplay" class="popin_block" style="display: none;">
89
+    <a href="javascript:void(0);" id="autoplay_close" >
90
+      <img src="{{ asset('/bundles/muzichcore/img/1353498913_window-close.png') }}" alt="close" />
91
+    </a>
92
+      
93
+      <a href="javascript:void(0);" id="autoplay_previous">
94
+        <img src="{{ asset('/bundles/muzichcore/img/1353505865_button_previous.png') }}" alt="previous" />
95
+      </a>
96
+      <a href="javascript:void(0);" id="autoplay_next">
97
+        <img src="{{ asset('/bundles/muzichcore/img/1353505874_button_next.png') }}" alt="next" />
98
+      </a>
99
+      
100
+    <ul id="autoplay_element"><li class="element" id="autoplay_element_container"></li></ul>
101
+    <div id="autoplay_player_container">
102
+      <div id="autoplay_player"></div>
103
+    </div>
104
+    <div id="autoplay_player_soundcloud"></div>
105
+    <img id="autoplay_loader" src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loader" />
106
+    <p id="autoplay_noelements_text" style="display: none;">{{ 'elements.autoplay.noelements.text'|trans({}, 'elements') }}</p>
107
+  </div>
108
+    
79 109
   {% include "MuzichCoreBundle:Language:languages.html.twig" %}
80 110
   
81 111
   {% include "MuzichUserBundle:Account:topBar.html.twig" %}

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

@@ -0,0 +1,64 @@
1
+<?php
2
+
3
+namespace Muzich\CoreBundle\lib;
4
+
5
+use Muzich\CoreBundle\Entity\Element;
6
+
7
+/**
8
+ *  Boite a outils pour les Tags. 
9
+ */
10
+class AutoplayManager
11
+{
12
+  
13
+  /**
14
+   *
15
+   * @var array of Element
16
+   */
17
+  private $elements;
18
+  
19
+  /**
20
+   *
21
+   * @var Container 
22
+   */
23
+  protected $container;
24
+  
25
+  /**
26
+   *
27
+   * @param array $elements 
28
+   */
29
+  public function __construct($elements, $container)
30
+  {
31
+    $this->elements = $elements;
32
+    $this->container = $container;
33
+  }
34
+  
35
+  public function getList()
36
+  {
37
+    $list = array();
38
+    
39
+    foreach ($this->elements as $element)
40
+    {
41
+      if (
42
+        // On doit connaitre l'id externe
43
+        ($ref_id = $element->getData(Element::DATA_REF_ID)) && 
44
+        // Et le site doit être pris en charge pour le autoplay
45
+        in_array(
46
+          ($element_type = $element->getType()), 
47
+          $this->container->getParameter('autoplay_sites_enabled')
48
+        )
49
+      )
50
+      
51
+      $list[] = array(
52
+        'element_ref_id'   => $ref_id,
53
+        'element_type'     => $element->getType(),
54
+        'element_id'       => $element->getId(),
55
+        'element_name'     => $element->getName(),
56
+        'element_url'      => $element->getUrl(),
57
+        'element_normalized_url' => $element->getData(Element::DATA_NORMALIZED_URL)
58
+      );
59
+    }
60
+    
61
+    return $list;
62
+  }
63
+  
64
+}

+ 7 - 3
src/Muzich/FavoriteBundle/Controller/FavoriteController.php View File

@@ -246,11 +246,15 @@ class FavoriteController extends Controller
246 246
     
247 247
     $tag_ids = json_decode($tags_ids_json);
248 248
     $search_object = new ElementSearcher();
249
+    $tags = null;
249 250
     
250
-    $tags = array();
251
-    foreach ($tag_ids as $id)
251
+    if (count($tag_ids))
252 252
     {
253
-      $tags[$id] = $id;
253
+      $tags = array();
254
+      foreach ($tag_ids as $id)
255
+      {
256
+        $tags[$id] = $id;
257
+      }
254 258
     }
255 259
     
256 260
     $search_object->init(array(

+ 16 - 1
src/Muzich/FavoriteBundle/Resources/views/Favorite/myList.html.twig View File

@@ -12,6 +12,15 @@
12 12
     'user_id' : app.user.id
13 13
   } %}
14 14
   
15
+  <a href="{{ path('elements_get_filter_data_autoplay_favorite', {
16
+        'show_type'  : 'user',
17
+        'show_id'    : app.user.id, 
18
+        'data'       : '[]'
19
+      }) }}" class="button" id="autoplay_launch" 
20
+     title="{{ 'elements.autoplay.launch'|trans({}, 'elements') }}" >
21
+    <img src="{{ asset('/bundles/muzichcore/img/1353494305_player_play.png') }}" alt="" />
22
+  </a>
23
+  
15 24
   {% include "MuzichCoreBundle:SearchElement:default.html.twig" %}
16 25
     
17 26
   <div class="elements_loader_div">
@@ -21,10 +30,16 @@
21 30
   {% if elements|length %}
22 31
      <span class="elements_more">
23 32
        <input type="hidden" id="more_elements_url" value="{{ path('favorite_get', {'user_id': app.user.id, 'tags_ids_json' : ''}) }}" />
24
-       <a href="{{ path('favorite_get', {'user_id': app.user.id, 'tags_ids_json' : tags_id_json}) }}" class="elements_more button">
33
+       <a href="{{ path('favorite_get', {'user_id': app.user.id, 'tags_ids_json' : '[]'}) }}" class="elements_more button">
25 34
          {{ 'more'|trans({}, 'userui') }}
26 35
        </a>
27 36
      </span>
28 37
   {% endif %}
38
+  
39
+  <input type="hidden" id="autoplay_url" value="{{ path('elements_get_filter_data_autoplay_favorite', {
40
+    'show_type'  : 'user',
41
+    'show_id'    : app.user.id, 
42
+    'data' : ''
43
+  }) }}" />
29 44
     
30 45
 {% endblock %}

+ 17 - 1
src/Muzich/FavoriteBundle/Resources/views/Favorite/userList.html.twig View File

@@ -19,6 +19,16 @@
19 19
   {% include "MuzichCoreBundle:Tag:tagsList.favorite.html.twig" with {
20 20
     'user_id' : viewed_user.id
21 21
   } %}
22
+  
23
+  <a href="{{ path('elements_get_filter_data_autoplay_favorite', {
24
+        'show_type'  : 'user',
25
+        'show_id'    : viewed_user.id, 
26
+        'data'       : '[]'
27
+      }) }}" class="button" id="autoplay_launch" 
28
+     title="{{ 'elements.autoplay.launch'|trans({}, 'elements') }}" >
29
+    <img src="{{ asset('/bundles/muzichcore/img/1353494305_player_play.png') }}" alt="" />
30
+  </a>
31
+  
22 32
 
23 33
   {% include "MuzichCoreBundle:SearchElement:default.html.twig" %}
24 34
     
@@ -29,10 +39,16 @@
29 39
   {% if elements|length %}
30 40
      <span class="elements_more">
31 41
        <input type="hidden" id="more_elements_url" value="{{ path('favorite_get', {'user_id': viewed_user.id, 'tags_ids_json' : ''}) }}" />
32
-       <a href="{{ path('favorite_get', {'user_id': viewed_user.id, 'tags_ids_json' : tags_id_json}) }}" class="elements_more button">
42
+       <a href="{{ path('favorite_get', {'user_id': viewed_user.id, 'tags_ids_json' : '[]'}) }}" class="elements_more button">
33 43
          {{ 'more'|trans({}, 'userui') }}
34 44
        </a>
35 45
      </span>
36 46
   {% endif %}
47
+  
48
+  <input type="hidden" id="autoplay_url" value="{{ path('elements_get_filter_data_autoplay_favorite', {
49
+    'show_type'  : 'user',
50
+    'show_id'    : viewed_user.id, 
51
+    'data' : ''
52
+  }) }}" />
37 53
     
38 54
 {% endblock %}

+ 9 - 4
src/Muzich/HomeBundle/Controller/ShowController.php View File

@@ -156,13 +156,18 @@ class ShowController extends Controller
156 156
       throw new \Exception("Wrong Type.");
157 157
     }
158 158
     
159
-    $tag_ids = json_decode($tags_ids_json);
160 159
     $search_object = new ElementSearcher();
160
+    $tags = null;
161
+    $tag_ids = json_decode($tags_ids_json);
161 162
     
162
-    $tags = array();
163
-    foreach ($tag_ids as $id)
163
+    if (count($tag_ids))
164 164
     {
165
-      $tags[$id] = $id;
165
+
166
+      $tags = array();
167
+      foreach ($tag_ids as $id)
168
+      {
169
+        $tags[$id] = $id;
170
+      }
166 171
     }
167 172
     
168 173
     $search_object->init(array(

+ 9 - 0
src/Muzich/HomeBundle/Resources/views/Home/index.html.twig View File

@@ -90,8 +90,17 @@
90 90
     } %}
91 91
     
92 92
     <input class="main button" type="submit" value="{{ 'filter.submit'|trans({}, 'userui') }}"/>
93
+        
93 94
   </form>
94 95
 
96
+  
97
+  <a href="{{ path('elements_get_filter_data_autoplay', {
98
+    'type' : 'filter'
99
+  }) }}" class="button" id="autoplay_launch" 
100
+     title="{{ 'elements.autoplay.launch'|trans({}, 'elements') }}" >
101
+    <img src="{{ asset('/bundles/muzichcore/img/1353494305_player_play.png') }}" alt="" />
102
+  </a>
103
+
95 104
   <div class="display_more_elements" style="display: none;">
96 105
     <span></span>
97 106
   </div>

+ 16 - 1
src/Muzich/HomeBundle/Resources/views/Show/showGroup.html.twig View File

@@ -54,6 +54,15 @@
54 54
     'object_type' : 'group'
55 55
   } %}
56 56
   
57
+  <a href="{{ path('elements_get_filter_data_autoplay_show', {
58
+        'show_type'  : 'group',
59
+        'show_id'    : group.id, 
60
+        'data'       : '[]'
61
+      }) }}" class="button" id="autoplay_launch" 
62
+     title="{{ 'elements.autoplay.launch'|trans({}, 'elements') }}" >
63
+    <img src="{{ asset('/bundles/muzichcore/img/1353494305_player_play.png') }}" alt="" />
64
+  </a>
65
+  
57 66
   {% if his_group or group.open %}
58 67
   
59 68
     <div id="element_add_box" style="display: none;">
@@ -95,7 +104,7 @@
95 104
      <a href="{{ path('show_elements_get', {
96 105
         'type'          : 'group',
97 106
         'object_id'     : group.id, 
98
-        'tags_ids_json' : tags_id_json
107
+        'tags_ids_json' : '[]'
99 108
       }) }}" class="elements_more button" >
100 109
        {{ 'more'|trans({}, 'userui') }}
101 110
      </a>
@@ -103,4 +112,10 @@
103 112
   {% endif %}
104 113
   {% endif %}
105 114
   
115
+  <input type="hidden" id="autoplay_url" value="{{ path('elements_get_filter_data_autoplay_show', {
116
+    'show_type'          : 'group',
117
+    'show_id'            : group.id, 
118
+    'data' : ''
119
+  }) }}" />
120
+            
106 121
 {% endblock %}

+ 16 - 1
src/Muzich/HomeBundle/Resources/views/Show/showUser.html.twig View File

@@ -85,6 +85,15 @@
85 85
     'object_type' : 'user'
86 86
   } %}
87 87
   
88
+  <a href="{{ path('elements_get_filter_data_autoplay_show', {
89
+        'show_type'  : 'user',
90
+        'show_id'    : viewed_user.id, 
91
+        'data'       : '[]'
92
+      }) }}" class="button" id="autoplay_launch" 
93
+     title="{{ 'elements.autoplay.launch'|trans({}, 'elements') }}" >
94
+    <img src="{{ asset('/bundles/muzichcore/img/1353494305_player_play.png') }}" alt="" />
95
+  </a>
96
+  
88 97
   {% include "MuzichCoreBundle:SearchElement:default.html.twig" %}
89 98
     
90 99
   <div class="elements_loader_div">
@@ -102,7 +111,7 @@
102 111
      <a href="{{ path('show_elements_get', {
103 112
         'type'          : 'user',
104 113
         'object_id'     : viewed_user.id, 
105
-        'tags_ids_json' : tags_id_json
114
+        'tags_ids_json' : '[]'
106 115
       }) }}" class="elements_more button" >
107 116
        {{ 'more'|trans({}, 'userui') }}
108 117
      </a>
@@ -110,4 +119,10 @@
110 119
   {% endif %}
111 120
   {% endif %}
112 121
   
122
+  <input type="hidden" id="autoplay_url" value="{{ path('elements_get_filter_data_autoplay_show', {
123
+    'show_type'          : 'user',
124
+    'show_id'     : viewed_user.id, 
125
+    'data' : ''
126
+  }) }}" />
127
+  
113 128
 {% endblock %}

+ 62 - 6
web/bundles/muzichcore/css/main.css View File

@@ -84,13 +84,13 @@ input.button, button.button {
84 84
   background-color: #39C9CC;
85 85
 }
86 86
 
87
-#container a
87
+#container a, #autoplay a
88 88
 {
89 89
   text-decoration: none;
90 90
   color: #00d0de;
91 91
 }
92 92
 
93
-#container a.button
93
+#container a.button, #autoplay a.button
94 94
 {
95 95
   color: white;
96 96
 }
@@ -542,7 +542,7 @@ li.element
542 542
   left: 483px;
543 543
 }*/
544 544
 
545
-#container li.element a.favorite_link:hover
545
+#container li.element a.favorite_link:hover, #autoplay li.element a.favorite_link:hover
546 546
 {
547 547
   text-decoration: none;
548 548
 }
@@ -585,7 +585,7 @@ li.element img.element_thumbnail
585 585
   height: 90px;
586 586
 }
587 587
 
588
-#container li.element span.element_name a
588
+#container li.element span.element_name a, #autoplay li.element span.element_name a
589 589
 {
590 590
   color: black;
591 591
 }
@@ -596,7 +596,7 @@ li.element img.play, li.element img.open
596 596
   
597 597
 }
598 598
 
599
-ul.elements
599
+ul.elements, ul#autoplay_element
600 600
 {
601 601
   margin-left: 0px;
602 602
 }
@@ -612,7 +612,7 @@ ul.elements li.even
612 612
   margin-left: 0px;
613 613
 }
614 614
   
615
-.elements ul.element_tags li
615
+.elements ul.element_tags li, ul#autoplay_element ul.element_tags li
616 616
 {
617 617
   display: inline;
618 618
   font-size: 90%;
@@ -1306,4 +1306,60 @@ span#add_url_title
1306 1306
 {
1307 1307
   font-weight: bold;
1308 1308
   font-size: 15px;
1309
+}
1310
+
1311
+div#autoplay
1312
+{
1313
+  text-align: left;
1314
+  padding-top: 0px;
1315
+}
1316
+
1317
+a#autoplay_launch
1318
+{
1319
+  float: right;
1320
+  margin-top: -25px;
1321
+}
1322
+
1323
+div#autoplay.popin_block
1324
+{
1325
+  width: 500px;
1326
+}
1327
+
1328
+a#autoplay_previous
1329
+{
1330
+  float: left;
1331
+  text-decoration: none;
1332
+  margin-left: -50px;
1333
+}
1334
+
1335
+a#autoplay_next
1336
+{
1337
+  float: right;
1338
+  text-decoration: none;
1339
+  margin-right: -50px;
1340
+}
1341
+
1342
+div#autoplay_title
1343
+{
1344
+  font-weight: bold;
1345
+  margin-left: 35px;
1346
+  margin-right: 35px;
1347
+}
1348
+
1349
+a#autoplay_close
1350
+{
1351
+  float: right;
1352
+  text-decoration: none;
1353
+  margin-top: -32px;
1354
+  margin-right: -32px;
1355
+}
1356
+
1357
+div#autoplay_player_container
1358
+{
1359
+  text-align: center;
1360
+}
1361
+
1362
+div#autoplay ul.elements, div#autoplay
1363
+{
1364
+  margin-top: 0px;
1309 1365
 }

BIN
web/bundles/muzichcore/img/1353494305_player_play.png View File


BIN
web/bundles/muzichcore/img/1353498913_window-close.png View File


BIN
web/bundles/muzichcore/img/1353503730_button-previous.png View File


BIN
web/bundles/muzichcore/img/1353503762_button-next.png View File


BIN
web/bundles/muzichcore/img/1353505865_button_previous.png View File


BIN
web/bundles/muzichcore/img/1353505874_button_next.png View File


BIN
web/bundles/muzichcore/img/player_end.png View File


BIN
web/bundles/muzichcore/img/player_pause.png View File


BIN
web/bundles/muzichcore/img/player_play.png View File


BIN
web/bundles/muzichcore/img/player_start.png View File


+ 313 - 0
web/bundles/muzichcore/js/autoplay.js View File

@@ -0,0 +1,313 @@
1
+/* Librairie Autoplay pour muzi.ch  */
2
+$(document).ready(function(){
3
+ 
4
+  /*
5
+   * Section commune
6
+   */
7
+  
8
+  // Liste de données pour la lecture
9
+  var autoplay_list = new Array;
10
+  // object player
11
+  var autoplay_player = null;
12
+  // Ritournelle pour le lecteur soundcloud (une seule variable sinon bug)
13
+  var autoplay_player_soundcloud = null;
14
+  // identifiant de la division du lecteur
15
+  var autoplay_player_div_id = "autoplay_player";
16
+  // identifiant du lecteur
17
+  var autoplay_player_id     = "autoplay_player_id";
18
+  // étape de lecture, on commence naturellement a 0
19
+  var autoplay_step = 0;
20
+  
21
+  // En cas de click sur un bouton de lecture
22
+  $('a#autoplay_launch').click(function(){
23
+    
24
+    // On ouvre la boite de dialogue pendant la demande ajax
25
+    open_popin_dialog('autoplay');
26
+    $('img#autoplay_loader').show();
27
+    
28
+    $.getJSON($(this).attr('href'), function(response) {
29
+      if (response.status == 'mustbeconnected')
30
+      {
31
+        $(location).attr('href', url_index);
32
+      }
33
+      
34
+      if (response.status == 'success')
35
+      {
36
+        // On récupère la liste d'élèments
37
+        autoplay_list = response.data;
38
+        autoplay_run(0);
39
+      }
40
+      
41
+    });
42
+    return false;
43
+  });
44
+  
45
+  // Lancement de l'élèment suivant
46
+  function autoplay_run(step)
47
+  {
48
+    // En premier lieu on réinitialise le lecteur en détruisant le dom qui a
49
+    // pu être créé par la lecture précedente.
50
+    $('div#'+autoplay_player_div_id+'_container').html('<div id="'+autoplay_player_div_id+'"></div>');
51
+    $('#autoplay_noelements_text').hide();
52
+    $('li#autoplay_element_container').html('');
53
+    $('img#autoplay_loader').show();
54
+    
55
+    
56
+    ////// TMP to check
57
+    if (autoplay_player_soundcloud)
58
+    {
59
+      autoplay_player_soundcloud.pause();
60
+    }
61
+    $('div#autoplay_player_soundcloud').hide();
62
+    
63
+    if (autoplay_list.length)
64
+    {
65
+    
66
+      if (array_key_exists(step, autoplay_list))
67
+      {
68
+        
69
+        // Récupération du dom d'un élement
70
+        $.getJSON(url_element_dom_get_one_autoplay+'/'+autoplay_list[step].element_id, function(response) {
71
+          if (response.status == 'mustbeconnected')
72
+          {
73
+            $(location).attr('href', url_index);
74
+          }
75
+          
76
+          if (response.status == 'success')
77
+          {
78
+            // On récupère la liste d'élèments
79
+            $('li#autoplay_element_container').html(response.data);
80
+            
81
+            // Youtube case
82
+            if (autoplay_list[step].element_type == 'youtube.com' || autoplay_list[step].element_type == 'youtu.be')
83
+            {
84
+              youtube_create_player(autoplay_list[step].element_ref_id);
85
+            }
86
+            
87
+            if (autoplay_list[step].element_type == 'soundcloud.com')
88
+            {
89
+              soundcloud_create_player(autoplay_list[step].element_ref_id, autoplay_list[step].element_normalized_url);
90
+            }
91
+          }
92
+
93
+        });
94
+        
95
+        
96
+      }
97
+    
98
+    }
99
+    else
100
+    {
101
+      autoplay_display_nomore();
102
+    }
103
+  }
104
+  
105
+  function autoplay_display_nomore()
106
+  {
107
+    $('div#'+autoplay_player_div_id+'_container').html('<div id="'+autoplay_player_div_id+'"></div>');
108
+    $('li#autoplay_element_container').html('');
109
+    $('#autoplay_noelements_text').show();
110
+    $('img#autoplay_loader').hide();
111
+    if (autoplay_player_soundcloud)
112
+    {
113
+      $('div#autoplay_player_soundcloud').hide();
114
+      autoplay_player_soundcloud.pause();
115
+    }
116
+  }
117
+  
118
+  // Avancer d'un élelement dans la liste
119
+  function autoplay_next()
120
+  {
121
+    autoplay_step++;
122
+    if (array_key_exists(autoplay_step, autoplay_list))
123
+    {
124
+      autoplay_run(autoplay_step);
125
+    }
126
+    else
127
+    {
128
+      autoplay_display_nomore();
129
+      autoplay_step = autoplay_list.length;
130
+    }
131
+  }
132
+  
133
+  // Reculer d'un élement dans la liste
134
+  function autoplay_previous()
135
+  {
136
+    autoplay_step--;
137
+    if (array_key_exists(autoplay_step, autoplay_list))
138
+    {
139
+      autoplay_run(autoplay_step);
140
+    }
141
+    else
142
+    {
143
+      autoplay_display_nomore();
144
+      autoplay_step = -1;
145
+    }
146
+  }
147
+  
148
+  // bouton précedent
149
+  $('a#autoplay_previous').click(function(){autoplay_previous();});
150
+  // bouton suivant
151
+  $('a#autoplay_next').click(function(){autoplay_next();});
152
+  // Fermeture de la lecture auto
153
+  $('a#autoplay_close').click(function(){
154
+    // Fond gris
155
+    $('#fade').fadeOut(1000, function(){$('#fade').remove();});
156
+    // On cache le lecteur
157
+    $('#autoplay').hide();
158
+    // On vide le dom du lecteur
159
+    $('div#'+autoplay_player_div_id+'_container').html('<div id="'+autoplay_player_div_id+'"></div>');
160
+  });
161
+   
162
+  
163
+  /*
164
+   *
165
+   *
166
+   *
167
+   * Fonction youtube.com et youtu.be
168
+   * 
169
+   * 
170
+   * 
171
+   */
172
+    
173
+  // Création du lecteur FLASH youtube
174
+  function youtube_create_player(ref_id)
175
+  {
176
+    var playerapiid = "ytplayerapiid";
177
+    var params = {allowScriptAccess: "always"};
178
+    var atts = {id: autoplay_player_id};
179
+    swfobject.embedSWF(
180
+      "http://www.youtube.com/v/"+ref_id+"?enablejsapi=1&playerapiid="+playerapiid+"&version=3",
181
+      autoplay_player_div_id,
182
+      "425",
183
+      "356",
184
+      "8",
185
+      null,
186
+      null,
187
+      params,
188
+      atts
189
+    );
190
+  }
191
+  
192
+  // Fonction appelé par l'ActionScript (flash) du lecteur youtube quand il est prêt
193
+  window.onYouTubePlayerReady = function()
194
+  {
195
+    autoplay_player = document.getElementById(autoplay_player_id);
196
+    autoplay_player.addEventListener("onStateChange", "youtube_StateChange");
197
+    $('img#autoplay_loader').hide();
198
+    youtube_play();
199
+  }
200
+  
201
+  // Fonction appelé par le lecteur youtube quand il change d'état
202
+  window.youtube_StateChange = function(newState)
203
+  {
204
+    // Lorsque la lecture est terminé
205
+    if (newState === 0)
206
+    {
207
+      autoplay_next();
208
+    }
209
+  }
210
+
211
+  // Lecture
212
+  function youtube_play()
213
+  {
214
+    if (autoplay_player)
215
+    {
216
+      autoplay_player.playVideo();
217
+    }
218
+  }
219
+  
220
+  /*
221
+   * 
222
+   * 
223
+   * Fonctions soundcloud
224
+   * 
225
+   * 
226
+   * 
227
+   */
228
+  
229
+  function soundcloud_create_player(ref_id, ref_url)
230
+  {
231
+    
232
+    // Variable dans lequelle on met l'index dela track lu précedamment
233
+    var index_track_previous = 0;
234
+     
235
+    if (!$('iframe#soundcloud_iframe_player').length)
236
+    {
237
+      $('div#autoplay_player_soundcloud').show();
238
+
239
+        // TODO: on garde ?
240
+        SC.initialize({
241
+          client_id: '39946ea18e3d78d64c0ac95a025794e1'
242
+        });
243
+
244
+      // Aucun lecteur soundcloud n'a été ouvert pour le moment
245
+      $('#autoplay_player_soundcloud').html(
246
+        '<iframe id="soundcloud_iframe_player" src="http://w.soundcloud.com/player/?url='
247
+          +ref_url+'&show_artwork=false&auto_play=true" width="100%" '
248
+          +'height="370" scrolling="no" frameborder="no"></iframe>'
249
+      );
250
+
251
+      //console.debug(document.getElementById('sc-widget_'+ref_id));
252
+      var widgetIframe = document.getElementById('soundcloud_iframe_player');
253
+      autoplay_player_soundcloud = SC.Widget(widgetIframe);
254
+
255
+      // Lorsque le lecteur est prêt on lance la lecture
256
+      autoplay_player_soundcloud.bind(SC.Widget.Events.READY, function ()
257
+      {
258
+        autoplay_player_soundcloud.play();
259
+        $('img#autoplay_loader').hide();
260
+
261
+      });
262
+
263
+      autoplay_player_soundcloud.bind(SC.Widget.Events.PLAY, function ()
264
+      {
265
+        // Lorsque le lecteur commence une lecture
266
+        // On garde en mémoire l'index de la lecture en cours
267
+        autoplay_player_soundcloud.getCurrentSoundIndex(function(value){
268
+            index_track_previous = value;
269
+        });
270
+      });
271
+
272
+      // Lorsque le lecteur a terminé sa lecture, on passe au suivant
273
+      autoplay_player_soundcloud.bind(SC.Widget.Events.FINISH, function ()
274
+      {
275
+
276
+        // Cette variable contient le nombre de pistes dans la liste de lecture
277
+        var track_count = 1;
278
+        autoplay_player_soundcloud.getSounds(function(value){
279
+          // On récupère le nomre de pistes
280
+          track_count = value.length;
281
+        });
282
+
283
+        autoplay_player_soundcloud.getCurrentSoundIndex(function(value){
284
+
285
+          // Si la index_track_previous est la même maintenant que la piste
286
+          // est terminé, c'est que l'on est arrivé en fin de liste.
287
+          // Cependant, si c'est une liste avec une piste unique, on passe 
288
+          // tout de suite a la suite
289
+          if (value == index_track_previous || track_count == 1)
290
+          {
291
+            autoplay_next();
292
+          }
293
+
294
+          // Sinon on prend al nouvelle valeur
295
+          index_track_previous = value;
296
+
297
+        });
298
+
299
+      });
300
+
301
+    }
302
+    else
303
+    {
304
+      // Le lecteur iframe existait déjà
305
+    $('div#autoplay_player_soundcloud').show();
306
+      autoplay_player_soundcloud.load(ref_url+'&show_artwork=false&auto_play=true');
307
+      //autoplay_player_soundcloud.play();
308
+    $('img#autoplay_loader').hide();
309
+    }
310
+         
311
+  }
312
+  
313
+});

+ 44 - 1
web/bundles/muzichcore/js/muzich.js View File

@@ -46,6 +46,21 @@ function findKeyWithValue(arrayt, value)
46 46
   return "";
47 47
 }
48 48
 
49
+function array_key_exists (key, search) {
50
+  // http://kevin.vanzonneveld.net
51
+  // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
52
+  // +   improved by: Felix Geisendoerfer (http://www.debuggable.com/felix)
53
+  // *     example 1: array_key_exists('kevin', {'kevin': 'van Zonneveld'});
54
+  // *     returns 1: true
55
+  // input sanitation
56
+  if (!search || (search.constructor !== Array && search.constructor !== Object)) {
57
+    return false;
58
+  }
59
+
60
+  return key in search;
61
+}
62
+
63
+
49 64
 function json_to_array(json_string)
50 65
 {
51 66
   if (json_string.length)
@@ -1480,6 +1495,9 @@ $(document).ready(function(){
1480 1495
     var a_more = $('a.elements_more');
1481 1496
     a_more.attr('href', $('input#more_elements_url').val()+'/'+array2json(tags_ids_for_filter));
1482 1497
     
1498
+    // On adapte aussi le lien de l'autoplay
1499
+    $('a#autoplay_launch').attr('href', $('input#autoplay_url').val()+'/'+array2json(tags_ids_for_filter));
1500
+    
1483 1501
     return check_timelaps_and_find_with_tags(link, new Date().getTime(), false);
1484 1502
   }
1485 1503
    
@@ -2359,5 +2377,30 @@ $(document).ready(function(){
2359 2377
     
2360 2378
   });
2361 2379
 
2380
+});
2381
+
2382
+
2362 2383
 
2363
-});
2384
+/*
2385
+ * Ouverture d'une boite avec effet fade et centré
2386
+ *   code origine: form_add_open_dialog_for_new_tag
2387
+ */
2388
+
2389
+  function open_popin_dialog(object_id)
2390
+  {
2391
+    
2392
+    // Effet fade-in du fond opaque
2393
+    $('body').append($('<div>').attr('id', 'fade')); 
2394
+    //Apparition du fond - .css({'filter' : 'alpha(opacity=80)'}) pour corriger les bogues de IE
2395
+    $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn();
2396
+    
2397
+    $('#'+object_id).css({
2398
+      position: 'absolute',
2399
+      left: ($(window).width() 
2400
+        - $('#'+object_id).width())/2,
2401
+//      top: ($(window).height() 
2402
+//        - $('#'+object_id).height())/2
2403
+        top: '20%'
2404
+      });
2405
+    $('#'+object_id).show();
2406
+  }

File diff suppressed because it is too large
+ 4 - 0
web/js/swfobject.js