soundmanager2-rails 2.97.20131201 → 2.97.20140901

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,10 +8,10 @@
8
8
  * Code provided under the BSD License:
9
9
  * http://schillmania.com/projects/soundmanager2/license.txt
10
10
  *
11
- * V2.97a.20131201
11
+ * V2.97a.20140901
12
12
  */
13
13
 
14
- /*global window, SM2_DEFER, sm2Debugger, console, document, navigator, setTimeout, setInterval, clearInterval, Audio, opera */
14
+ /*global window, SM2_DEFER, sm2Debugger, console, document, navigator, setTimeout, setInterval, clearInterval, Audio, opera, module, define */
15
15
  /*jslint regexp: true, sloppy: true, white: true, nomen: true, plusplus: true, todo: true */
16
16
 
17
17
  /**
@@ -34,6 +34,15 @@
34
34
 
35
35
  "use strict";
36
36
 
37
+ if (!window || !window.document) {
38
+
39
+ // Don't cross the [environment] streams. SM2 expects to be running in a browser, not under node.js etc.
40
+ // Additionally, if a browser somehow manages to fail this test, as Egon said: "It would be bad."
41
+
42
+ throw new Error('SoundManager requires a browser with window and document objects.');
43
+
44
+ }
45
+
37
46
  var soundManager = null;
38
47
 
39
48
  /**
@@ -189,7 +198,7 @@ function SoundManager(smURL, smID) {
189
198
 
190
199
  // dynamic attributes
191
200
 
192
- this.versionNumber = 'V2.97a.20131201';
201
+ this.versionNumber = 'V2.97a.20140901';
193
202
  this.version = null;
194
203
  this.movieURL = null;
195
204
  this.altURL = null;
@@ -1635,6 +1644,11 @@ function SoundManager(smURL, smID) {
1635
1644
  try {
1636
1645
  s.isHTML5 = false;
1637
1646
  s._iO = policyFix(loopFix(instanceOptions));
1647
+ // if we have "position", disable auto-play as we'll be seeking to that position at onload().
1648
+ if (s._iO.autoPlay && (s._iO.position || s._iO.from)) {
1649
+ sm2._wD(s.id + ': Disabling autoPlay because of non-zero offset case');
1650
+ s._iO.autoPlay = false;
1651
+ }
1638
1652
  // re-assign local shortcut
1639
1653
  instanceOptions = s._iO;
1640
1654
  if (fV === 8) {
@@ -1909,12 +1923,15 @@ function SoundManager(smURL, smID) {
1909
1923
 
1910
1924
  s._iO = mixin(oOptions, s._iO);
1911
1925
 
1912
- // apply from/to parameters, if they exist (and not using RTMP)
1913
- if (s._iO.from !== null && s._iO.to !== null && s.instanceCount === 0 && s.playState === 0 && !s._iO.serverURL) {
1926
+ /**
1927
+ * Preload in the event of play() with position under Flash,
1928
+ * or from/to parameters and non-RTMP case
1929
+ */
1930
+ if (((!s.isHTML5 && s._iO.position !== null && s._iO.position > 0) || (s._iO.from !== null && s._iO.from > 0) || s._iO.to !== null) && s.instanceCount === 0 && s.playState === 0 && !s._iO.serverURL) {
1914
1931
 
1915
1932
  onready = function() {
1916
1933
  // sound "canplay" or onload()
1917
- // re-apply from/to to instance options, and start playback
1934
+ // re-apply position/from/to to instance options, and start playback
1918
1935
  s._iO = mixin(oOptions, s._iO);
1919
1936
  s.play(s._iO);
1920
1937
  };
@@ -1923,7 +1940,7 @@ function SoundManager(smURL, smID) {
1923
1940
  if (s.isHTML5 && !s._html5_canplay) {
1924
1941
 
1925
1942
  // this hasn't been loaded yet. load it first, and then do this again.
1926
- sm2._wD(fN + 'Beginning load for from/to case');
1943
+ sm2._wD(fN + 'Beginning load for non-zero offset case');
1927
1944
 
1928
1945
  s.load({
1929
1946
  // note: custom HTML5-only event added for from/to implementation.
@@ -1936,7 +1953,7 @@ function SoundManager(smURL, smID) {
1936
1953
 
1937
1954
  // to be safe, preload the whole thing in Flash.
1938
1955
 
1939
- sm2._wD(fN + 'Preloading for from/to case');
1956
+ sm2._wD(fN + 'Preloading for non-zero offset case');
1940
1957
 
1941
1958
  s.load({
1942
1959
  onload: onready
@@ -3097,7 +3114,7 @@ function SoundManager(smURL, smID) {
3097
3114
  s.isBuffering = (nIsBuffering === 1);
3098
3115
  if (s._iO.onbufferchange) {
3099
3116
  sm2._wD(s.id + ': Buffer state change: ' + nIsBuffering);
3100
- s._iO.onbufferchange.apply(s);
3117
+ s._iO.onbufferchange.apply(s, [nIsBuffering]);
3101
3118
  }
3102
3119
 
3103
3120
  return true;
@@ -3128,16 +3145,29 @@ function SoundManager(smURL, smID) {
3128
3145
  this._onfailure = function(msg, level, code) {
3129
3146
 
3130
3147
  s.failures++;
3131
- sm2._wD(s.id + ': Failures = ' + s.failures);
3148
+ sm2._wD(s.id + ': Failure (' + s.failures + '): ' + msg);
3132
3149
 
3133
3150
  if (s._iO.onfailure && s.failures === 1) {
3134
- s._iO.onfailure(s, msg, level, code);
3151
+ s._iO.onfailure(msg, level, code);
3135
3152
  } else {
3136
3153
  sm2._wD(s.id + ': Ignoring failure');
3137
3154
  }
3138
3155
 
3139
3156
  };
3140
3157
 
3158
+ /**
3159
+ * flash 9/movieStar + RTMP-only method for unhandled warnings/exceptions from Flash
3160
+ * e.g., RTMP "method missing" warning (non-fatal) for getStreamLength on server
3161
+ */
3162
+
3163
+ this._onwarning = function(msg, level, code) {
3164
+
3165
+ if (s._iO.onwarning) {
3166
+ s._iO.onwarning(msg, level, code);
3167
+ }
3168
+
3169
+ };
3170
+
3141
3171
  this._onfinish = function() {
3142
3172
 
3143
3173
  // store local copy before it gets trashed...
@@ -3323,8 +3353,10 @@ function SoundManager(smURL, smID) {
3323
3353
  }
3324
3354
  s.metadata = oData;
3325
3355
 
3356
+ console.log('updated metadata', s.metadata);
3357
+
3326
3358
  if (s._iO.onmetadata) {
3327
- s._iO.onmetadata.apply(s);
3359
+ s._iO.onmetadata.call(s, s.metadata);
3328
3360
  }
3329
3361
 
3330
3362
  };
@@ -3752,10 +3784,10 @@ function SoundManager(smURL, smID) {
3752
3784
  s._onbufferchange(0);
3753
3785
 
3754
3786
  // position according to instance options
3755
- position1K = (s._iO.position !== _undefined && !isNaN(s._iO.position)?s._iO.position/msecScale:null);
3787
+ position1K = (s._iO.position !== _undefined && !isNaN(s._iO.position) ? s._iO.position/msecScale : null);
3756
3788
 
3757
- // set the position if position was set before the sound loaded
3758
- if (s.position && this.currentTime !== position1K) {
3789
+ // set the position if position was provided before the sound loaded
3790
+ if (this.currentTime !== position1K) {
3759
3791
  sm2._wD(s.id + ': canplay: Setting position to ' + position1K);
3760
3792
  try {
3761
3793
  this.currentTime = position1K;
@@ -3783,6 +3815,25 @@ function SoundManager(smURL, smID) {
3783
3815
 
3784
3816
  }),
3785
3817
 
3818
+ durationchange: html5_event(function() {
3819
+
3820
+ // durationchange may fire at various times, probably the safest way to capture accurate/final duration.
3821
+
3822
+ var s = this._s,
3823
+ duration;
3824
+
3825
+ duration = s._get_html5_duration();
3826
+
3827
+ if (!isNaN(duration) && duration !== s.duration) {
3828
+
3829
+ sm2._wD(this._s.id + ': durationchange (' + duration + ')' + (s.duration ? ', previously ' + s.duration : ''));
3830
+
3831
+ s.durationEstimate = s.duration = duration;
3832
+
3833
+ }
3834
+
3835
+ }),
3836
+
3786
3837
  // TODO: Reserved for potential use
3787
3838
  /*
3788
3839
  emptied: html5_event(function() {
@@ -3855,7 +3906,7 @@ function SoundManager(smURL, smID) {
3855
3906
 
3856
3907
  playing: html5_event(function() {
3857
3908
 
3858
- sm2._wD(this._s.id + ': playing');
3909
+ sm2._wD(this._s.id + ': playing ' + String.fromCharCode(9835));
3859
3910
  // once play starts, no buffering
3860
3911
  this._s._onbufferchange(0);
3861
3912
 
@@ -3915,8 +3966,6 @@ function SoundManager(smURL, smID) {
3915
3966
 
3916
3967
  if (!isNaN(loaded)) {
3917
3968
 
3918
- // if progress, likely not buffering
3919
- s._onbufferchange(0);
3920
3969
  // TODO: prevent calls with duplicate values.
3921
3970
  s._whileloading(loaded, total, s._get_html5_duration());
3922
3971
  if (loaded && total && loaded === total) {
@@ -4259,7 +4308,7 @@ function SoundManager(smURL, smID) {
4259
4308
  setupUndef: sm + '.setup(): Could not find option "%s"',
4260
4309
  setupLate: sm + '.setup(): url, flashVersion and html5Test property changes will not take effect until reboot().',
4261
4310
  noURL: smc + 'Flash URL required. Call soundManager.setup({url:...}) to get started.',
4262
- sm2Loaded: 'SoundManager 2: Ready.',
4311
+ sm2Loaded: 'SoundManager 2: Ready. ' + String.fromCharCode(10003),
4263
4312
  reset: sm + '.reset(): Removing event callbacks',
4264
4313
  mobileUA: 'Mobile UA detected, preferring HTML5 by default.',
4265
4314
  globalHTML5: 'Using singleton HTML5 Audio() pattern for this device.'
@@ -4771,13 +4820,13 @@ function SoundManager(smURL, smID) {
4771
4820
 
4772
4821
  };
4773
4822
 
4774
- featureCheck = function() {
4823
+ featureCheck = function() {
4775
4824
 
4776
4825
  var flashNeeded,
4777
4826
  item,
4778
4827
  formats = sm2.audioFormats,
4779
4828
  // iPhone <= 3.1 has broken HTML5 audio(), but firmware 3.2 (original iPad) + iOS4 works.
4780
- isSpecial = (is_iDevice && !!(ua.match(/os (1|2|3_0|3_1)/i)));
4829
+ isSpecial = (is_iDevice && !!(ua.match(/os (1|2|3_0|3_1)\s/i)));
4781
4830
 
4782
4831
  if (isSpecial) {
4783
4832
 
@@ -5215,7 +5264,7 @@ function SoundManager(smURL, smID) {
5215
5264
  * does not apply when using high performance (position:fixed means on-screen), OR infinite flash load timeout
5216
5265
  * wmode breaks IE 8 on Vista + Win7 too in some cases, as of January 2011 (?)
5217
5266
  */
5218
- messages.push(strings.spcWmode);
5267
+ messages.push(strings.spcWmode);
5219
5268
  sm2.wmode = null;
5220
5269
  }
5221
5270
 
@@ -5655,7 +5704,7 @@ function SoundManager(smURL, smID) {
5655
5704
 
5656
5705
  if (sm2.html5Only) {
5657
5706
  // all good.
5658
- _wDS('sm2Loaded');
5707
+ _wDS('sm2Loaded', 1);
5659
5708
  didInit = true;
5660
5709
  initUserOnload();
5661
5710
  debugTS('onload', true);
@@ -5672,7 +5721,7 @@ function SoundManager(smURL, smID) {
5672
5721
 
5673
5722
  error = {type: (!hasFlash && needsFlash ? 'NO_FLASH' : 'INIT_TIMEOUT')};
5674
5723
 
5675
- sm2._wD('SoundManager 2 ' + (disabled ? 'failed to load' : 'loaded') + ' (' + (disabled ? 'Flash security/load error' : 'OK') + ')', disabled ? 2: 1);
5724
+ sm2._wD('SoundManager 2 ' + (disabled ? 'failed to load' : 'loaded') + ' (' + (disabled ? 'Flash security/load error' : 'OK') + ') ' + String.fromCharCode(disabled ? 10006 : 10003), disabled ? 2: 1);
5676
5725
 
5677
5726
  if (disabled || bNoDisable) {
5678
5727
  if (sm2.useFlashBlock && sm2.oMC) {
@@ -5904,6 +5953,10 @@ function SoundManager(smURL, smID) {
5904
5953
 
5905
5954
  // catch edge case of initComplete() firing after window.load()
5906
5955
  windowLoaded = true;
5956
+
5957
+ // catch case where DOMContentLoaded has been sent, but we're still in doc.readyState = 'interactive'
5958
+ domContentLoaded();
5959
+
5907
5960
  event.remove(window, 'load', winOnLoad);
5908
5961
 
5909
5962
  };
@@ -5983,7 +6036,37 @@ if (window.SM2_DEFER === undefined || !SM2_DEFER) {
5983
6036
  * ------------------------------
5984
6037
  */
5985
6038
 
5986
- window.SoundManager = SoundManager; // constructor
5987
- window.soundManager = soundManager; // public API, flash callbacks etc.
6039
+ if (typeof module === 'object' && module && typeof module.exports === 'object') {
6040
+
6041
+ /**
6042
+ * commonJS module
6043
+ * note: SM2 requires a window global due to Flash, which makes calls to window.soundManager.
6044
+ * flash may not always be needed, but this is not known until async init and SM2 may even "reboot" into Flash mode.
6045
+ */
6046
+
6047
+ window.soundManager = soundManager;
6048
+
6049
+ module.exports.SoundManager = SoundManager;
6050
+ module.exports.soundManager = soundManager;
6051
+
6052
+ } else if (typeof define === 'function' && define.amd) {
6053
+
6054
+ // AMD - requireJS
6055
+
6056
+ define('SoundManager', [], function() {
6057
+ return {
6058
+ SoundManager: SoundManager,
6059
+ soundManager: soundManager
6060
+ };
6061
+ });
6062
+
6063
+ } else {
6064
+
6065
+ // standard browser case
6066
+
6067
+ window.SoundManager = SoundManager; // constructor
6068
+ window.soundManager = soundManager; // public API, flash callbacks etc.
6069
+
6070
+ }
5988
6071
 
5989
6072
  }(window));
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soundmanager2-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.97.20131201
4
+ version: 2.97.20140901
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sudara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-19 00:00:00.000000000 Z
11
+ date: 2014-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: jeweler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: 'Exposes soundmanager2 as a vendored js lib in rails 3 '
@@ -45,7 +45,7 @@ extensions: []
45
45
  extra_rdoc_files:
46
46
  - README.md
47
47
  files:
48
- - .document
48
+ - ".document"
49
49
  - Gemfile
50
50
  - Gemfile.lock
51
51
  - README.md
@@ -71,17 +71,17 @@ require_paths:
71
71
  - lib
72
72
  required_ruby_version: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - '>='
74
+ - - ">="
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - '>='
79
+ - - ">="
80
80
  - !ruby/object:Gem::Version
81
81
  version: '0'
82
82
  requirements: []
83
83
  rubyforge_project:
84
- rubygems_version: 2.2.1
84
+ rubygems_version: 2.2.2
85
85
  signing_key:
86
86
  specification_version: 4
87
87
  summary: Exposes soundmanager2 as a vendored js lib in rails 3