Pachelbel 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/project/Pachelbel.rb +27 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1db4add5dbc5c87afe3f908be78189e4cb7119d
|
4
|
+
data.tar.gz: 3a4d363014c9299837d9d5962dd746e64ae01fc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 049cffb1cba4b97f6f378fa4623cda461688a8e5f0e73a71f51a0e6f24685426ab6e31b98bd16a4ed8db9785fb3abe434af38e8adad7cfac1ee2817d38d3b8fe
|
7
|
+
data.tar.gz: c18a5b399c16eedde445fb24104cabeba6bb7a4008ecd900ad0390ae0ca552d24f8a5a2145d3dcc7f1a295a43c42d36ff87b60f034dc3979c815d892e201dfd1
|
data/lib/project/Pachelbel.rb
CHANGED
@@ -1,15 +1,22 @@
|
|
1
1
|
module Pachelbel
|
2
2
|
class AudioContext
|
3
3
|
attr_reader :webview
|
4
|
+
attr_reader :locked
|
4
5
|
|
5
6
|
HTML = '<script>' + 'window.AudioContext = window.AudioContext || window.webkitAudioContext;' +
|
6
7
|
'var audio_context = new AudioContext();' + 'var audio_nodes = [audio_context.destination];' + '</script>'
|
7
8
|
|
9
|
+
def on_ready(&block)
|
10
|
+
@on_ready.push block
|
11
|
+
end
|
12
|
+
|
8
13
|
def run_js(script)
|
9
14
|
@webview.stringByEvaluatingJavaScriptFromString script
|
10
15
|
end
|
11
16
|
|
12
17
|
def initialize
|
18
|
+
@locked = true
|
19
|
+
@on_ready = []
|
13
20
|
@webview = UIWebView.new
|
14
21
|
@webview.delegate = self
|
15
22
|
@webview.loadHTMLString HTML, baseURL: nil
|
@@ -17,6 +24,26 @@ module Pachelbel
|
|
17
24
|
|
18
25
|
def webViewDidFinishLoad(_)
|
19
26
|
run_js 'audio_context.createOscillator();' # workaround to start timer
|
27
|
+
|
28
|
+
run_js 'var unlock_iframe = document.createElement("IFRAME");
|
29
|
+
unlock_iframe.setAttribute("src", "let://freedom.ring");'
|
30
|
+
|
31
|
+
run_js 'unlock_function = function() { document.documentElement.appendChild(unlock_iframe); }'
|
32
|
+
|
33
|
+
run_js 'pollster = function() { if (audio_context.currentTime === 0) { setTimeout(pollster, 0); } else { unlock_function(); } }'
|
34
|
+
run_js 'setTimeout(pollster, 0);'
|
35
|
+
end
|
36
|
+
|
37
|
+
def webView(_, shouldStartLoadWithRequest: request, navigationType: _)
|
38
|
+
case request.URL.absoluteString
|
39
|
+
when "let://freedom.ring"
|
40
|
+
@locked = false
|
41
|
+
@on_ready.each(&:call)
|
42
|
+
@on_ready.clear
|
43
|
+
return false
|
44
|
+
else
|
45
|
+
return true
|
46
|
+
end
|
20
47
|
end
|
21
48
|
|
22
49
|
# API Attributes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Pachelbel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Drew Carey Buglione
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|