phildini / cards-against-django

CAH done as a Django web app.
Other
8 stars 4 forks source link

Audio/Sound support #58

Open clach04 opened 10 years ago

clach04 commented 10 years ago

Possible enhancement, play a (subtle) audio file when a form is displayed and user input is required.

Experimental prototype to see how they works using https://bitbucket.org/illume/shitsound

diff --git a/cards/templates/game_view.html b/cards/templates/game_view.html
index 6a6e885..b55ec77 100644
--- a/cards/templates/game_view.html
+++ b/cards/templates/game_view.html
@@ -35,6 +35,13 @@
             {% endfor %}
         <input type="submit" class="btn btn-primary" value="Submit" />
         </form>
+    
+    <!--  I can't get document ready to work (possibly due to long poll from socket.io) so just have a script entry here! :-) -->
+    <script>
+        $.snd.init({}, function () {
+            $.snd.play('hello');
+        });
+    </script>
     {% endif %}

     {% if game.game_state == 'selection' %}
diff --git a/templates/base.html b/templates/base.html
index 5b3fbfc..cbf3688 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -20,6 +20,11 @@
         ga('send', 'pageview');

     </script>
+    
+    <script type="text/javascript" src="{{ STATIC_URL }}swfobject.js"></script>
+    <!-- Note jquery-1.js is imported much later... -->
+    <script type="text/javascript" src="{{ STATIC_URL }}jquery.min.js"></script>
+    <script type="text/javascript" src="{{ STATIC_URL }}jquery.shitsound.js"></script>
   </head>
   <body>
     <div class="container">
phildini commented 10 years ago

I like the idea, not certain on the implementation. I would say, since you already have the code ready, do a pull request so we can explore the code around it a little more. I think we can add js triggers rather than having to drop a script tag into the html.