Browse Source

Load sprite1 definition from external JSON file.

This avoids having to update the `uicontroller.js` manually each time the
sprite changes. The JSON file is automatically copied by the `_encode.sh`
script.
pull/380/head
Joachim Bauch 9 years ago
parent
commit
b39f6e765c
  1. 10
      src/audio/_build.py
  2. 2
      src/audio/_encode.sh
  3. 34
      src/audio/sprite1.json
  4. 41
      static/js/controllers/uicontroller.js
  5. 34
      static/sounds/sprite1.json

10
src/audio/_build.py

@ -22,10 +22,10 @@ def main(folder="./files"): @@ -22,10 +22,10 @@ def main(folder="./files"):
# Open output file
output = wave.open(outfile, 'wb')
# Loop through files in folder and append to outfile
for i, infile in enumerate(sorted(glob.glob(os.path.join(folder, '*.wav')))):
# Open file and get info
w = wave.open(infile, 'rb')
soundDuration = w.getnframes() / float(w.getframerate())
@ -57,7 +57,9 @@ def main(folder="./files"): @@ -57,7 +57,9 @@ def main(folder="./files"):
output.close()
# Output howler sprite data
print json.dumps(sprite, sort_keys=True, indent=4, separators=(',', ': '))
sprites = json.dumps(sprite, sort_keys=True, indent=4, separators=(',', ': '))
sprites = '\n'.join([x.rstrip() for x in sprites.split('\n')]) + '\n'
file('sprite1.json', 'wb').write(sprites)
if __name__ == "__main__":
main()

2
src/audio/_encode.sh

@ -7,4 +7,4 @@ avconv -y -i .tmp-sprite1.wav -aq 2 -acodec libvorbis sprite1.ogg @@ -7,4 +7,4 @@ avconv -y -i .tmp-sprite1.wav -aq 2 -acodec libvorbis sprite1.ogg
rm -f .tmp-sprite1.wav
cp -fv sprite1.{mp3,ogg} ../../static/sounds
cp -fv sprite1.{json,mp3,ogg} ../../static/sounds

34
src/audio/sprite1.json

@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
{
"connect1": [
0,
5179
],
"end1": [
5228,
6199
],
"entry1": [
11476,
3000
],
"leaving1": [
14526,
2126
],
"message1": [
16701,
816
],
"question1": [
17567,
3313
],
"ringtone1": [
20929,
935
],
"whistle1": [
21913,
1405
]
}

41
static/js/controllers/uicontroller.js

@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
*/
"use strict";
define(['jquery', 'underscore', 'bigscreen', 'moment', 'sjcl', 'modernizr', 'webrtc.adapter'], function($, _, BigScreen, moment, sjcl, Modernizr) {
define(['jquery', 'underscore', 'bigscreen', 'moment', 'sjcl', 'modernizr', 'text!sounds/sprite1.json', 'webrtc.adapter'], function($, _, BigScreen, moment, sjcl, Modernizr, sprite1Definition) {
return ["$scope", "$rootScope", "$element", "$window", "$timeout", "safeDisplayName", "safeApply", "mediaStream", "appData", "playSound", "desktopNotify", "alertify", "toastr", "translation", "fileDownload", "localStorage", "screensharing", "localStatus", "dialogs", "rooms", "constraints", "turnData", function($scope, $rootScope, $element, $window, $timeout, safeDisplayName, safeApply, mediaStream, appData, playSound, desktopNotify, alertify, toastr, translation, fileDownload, localStorage, screensharing, localStatus, dialogs, rooms, constraints, turnData) {
@ -98,43 +98,14 @@ define(['jquery', 'underscore', 'bigscreen', 'moment', 'sjcl', 'modernizr', 'web @@ -98,43 +98,14 @@ define(['jquery', 'underscore', 'bigscreen', 'moment', 'sjcl', 'modernizr', 'web
};
if (typeof(sprite1Definition) === "string") {
sprite1Definition = JSON.parse(sprite1Definition);
}
// Load default sounds.
playSound.initialize({
urls: ['sounds/sprite1.ogg', 'sounds/sprite1.mp3'],
sprite: {
"connect1": [
0,
5179
],
"end1": [
5228,
6199
],
"entry1": [
11476,
3000
],
"leaving1": [
14526,
2126
],
"message1": [
16701,
816
],
"question1": [
17567,
3313
],
"ringtone1": [
20929,
935
],
"whistle1": [
21913,
1405
]
}
sprite: sprite1Definition
}, null, {
"ring": "whistle1",
"joined": "entry1",

34
static/sounds/sprite1.json

@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
{
"connect1": [
0,
5179
],
"end1": [
5228,
6199
],
"entry1": [
11476,
3000
],
"leaving1": [
14526,
2126
],
"message1": [
16701,
816
],
"question1": [
17567,
3313
],
"ringtone1": [
20929,
935
],
"whistle1": [
21913,
1405
]
}
Loading…
Cancel
Save