Browse Source

Merge pull request #380 from fancycode/sprite_json

Load sprite1 definition from external JSON file.
pull/386/head
Joachim Bauch 9 years ago committed by GitHub
parent
commit
542e1b4148
  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"):
# Open output file # Open output file
output = wave.open(outfile, 'wb') output = wave.open(outfile, 'wb')
# Loop through files in folder and append to outfile # Loop through files in folder and append to outfile
for i, infile in enumerate(sorted(glob.glob(os.path.join(folder, '*.wav')))): for i, infile in enumerate(sorted(glob.glob(os.path.join(folder, '*.wav')))):
# Open file and get info # Open file and get info
w = wave.open(infile, 'rb') w = wave.open(infile, 'rb')
soundDuration = w.getnframes() / float(w.getframerate()) soundDuration = w.getnframes() / float(w.getframerate())
@ -57,7 +57,9 @@ def main(folder="./files"):
output.close() output.close()
# Output howler sprite data # 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__": if __name__ == "__main__":
main() main()

2
src/audio/_encode.sh

@ -7,4 +7,4 @@ avconv -y -i .tmp-sprite1.wav -aq 2 -acodec libvorbis sprite1.ogg
rm -f .tmp-sprite1.wav 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 @@
{
"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 @@
*/ */
"use strict"; "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) { 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
}; };
if (typeof(sprite1Definition) === "string") {
sprite1Definition = JSON.parse(sprite1Definition);
}
// Load default sounds. // Load default sounds.
playSound.initialize({ playSound.initialize({
urls: ['sounds/sprite1.ogg', 'sounds/sprite1.mp3'], urls: ['sounds/sprite1.ogg', 'sounds/sprite1.mp3'],
sprite: { sprite: sprite1Definition
"connect1": [
0,
5179
],
"end1": [
5228,
6199
],
"entry1": [
11476,
3000
],
"leaving1": [
14526,
2126
],
"message1": [
16701,
816
],
"question1": [
17567,
3313
],
"ringtone1": [
20929,
935
],
"whistle1": [
21913,
1405
]
}
}, null, { }, null, {
"ring": "whistle1", "ring": "whistle1",
"joined": "entry1", "joined": "entry1",

34
static/sounds/sprite1.json

@ -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