record_me 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +89 -0
- data/Rakefile +1 -0
- data/config/initializer/record_me.rb +23 -0
- data/config/record_me.yml +27 -0
- data/lib/assets/javascripts/jRecorder.js +245 -0
- data/lib/assets/swfs/jRecorder.swf +0 -0
- data/lib/generators/initialize_generator.rb +16 -0
- data/lib/generators/install_generator.rb +15 -0
- data/lib/generators/templates/initializer.rb +4 -0
- data/lib/record_me.rb +13 -0
- data/lib/record_me/controller.rb +20 -0
- data/lib/record_me/helpers.rb +77 -0
- data/lib/record_me/version.rb +3 -0
- data/record_me.gemspec +23 -0
- metadata +103 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Marco Gallardo
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
# RecordMe
|
2
|
+
|
3
|
+
record_me gem is a very simple gem that allows you to record user's audio input by using a simple javascript interface and an already built flash object. If you have questions about why I opted using flash and other info, you might want to take a look to my post [What? Rails can't hear you? Use Flash!](http://www.tangosource.com/blog/What-rails-cant-hear-you-use-flash/)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'record_me'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install record_me
|
18
|
+
|
19
|
+
Run generators:
|
20
|
+
|
21
|
+
$ rails generate record_me:install
|
22
|
+
$ rails generate record_me:initialize
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
## Configuration file
|
27
|
+
|
28
|
+
Specify default settings:
|
29
|
+
|
30
|
+
* __top__: sets top absolute position of flash object window. Default is 40%.
|
31
|
+
* __left__: sets left absolute position of flash object window. Default is 40%.
|
32
|
+
* __time__: sets recording limit of seconds; maximum available are 180 seconds (3 minutes). Default is 30 seconds.
|
33
|
+
* __name__: sets name of the record. Default is record.wav.
|
34
|
+
* __destination__: the folder where all your records will be placed. Default is public/records.
|
35
|
+
|
36
|
+
__top__, __left__, __time__, and __name__ can be overridden in your views as you will see next.
|
37
|
+
|
38
|
+
### In your view
|
39
|
+
|
40
|
+
Add next CSS class selectors to your HTML elements:
|
41
|
+
|
42
|
+
* __.record\_me\_timer__: attaches a counter in seconds to the element
|
43
|
+
* __.record\_me\_start__: when element with this selector is clicked, it triggers recording action
|
44
|
+
* __.record\_me\_stop__: when element with this selector is clicked, recording stops
|
45
|
+
* __.record\_me\_reproduce__: when element with this selector is clicked, recorded audio is reproduced
|
46
|
+
* __.record\_me\_save__: when element with this selector is clicked, recorded audio is sent to server
|
47
|
+
|
48
|
+
Then add next function to your view (since it will embed js code in your view you may want to add it at the bottom of your view/layout):
|
49
|
+
|
50
|
+
__record\_me\_js({save\_path: some\_path})__
|
51
|
+
|
52
|
+
where __save\_path__ is the path of the action where the recorded audio will be sent once element with .record\_me\_save class is clicked.
|
53
|
+
|
54
|
+
Also, you can pass *time, name, top, and left* values to override config/record_me.yml settings.
|
55
|
+
|
56
|
+
Example of how the code would look:
|
57
|
+
|
58
|
+
`<%= link_to 'Save', '#', :class => 'record_me_save'%>`
|
59
|
+
`<div class='record_me_timer'></div>`
|
60
|
+
`<div class='record_me_start'>Start</div>`
|
61
|
+
`<div class='record_me_stop'>Stop</div>`
|
62
|
+
`<div class='record_me_reproduce'>Reproduce</div>`
|
63
|
+
`<%= record_me_js({save_path: audios_save_path, time: 3, name:'my_record.wav'}) %>`
|
64
|
+
|
65
|
+
### In your controller
|
66
|
+
|
67
|
+
Go to the action defined for __save\_path__ and add just add __record\_me\_save__. 'true' will be returned if file was successfully created.
|
68
|
+
|
69
|
+
### Flash warning message
|
70
|
+
|
71
|
+
Additionally you can display a message asking to install Flash if it is not installed, just call .flash\_warning\_message method and pass it the class of the html element you want to display the message:
|
72
|
+
|
73
|
+
`<div class='flash_warning'></div>`
|
74
|
+
`<%= flash_warning_message('flash_warning') %>`
|
75
|
+
|
76
|
+
That's it!
|
77
|
+
|
78
|
+
## Wish list
|
79
|
+
|
80
|
+
* Add tests
|
81
|
+
* Ensure Rails 4.x compatibility
|
82
|
+
|
83
|
+
## Contributing
|
84
|
+
|
85
|
+
1. Fork it
|
86
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
87
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
88
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
89
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module RecordMe
|
2
|
+
|
3
|
+
# the Authorization configuration file path
|
4
|
+
@file = Dir.pwd + '/config/record_me.yml'
|
5
|
+
|
6
|
+
# Configure
|
7
|
+
def self.configure
|
8
|
+
if @file
|
9
|
+
# interpret it using YAML using the current environment to extract the configuration
|
10
|
+
@config = YAML.load( File.read(@file) )[ Rails.env ]
|
11
|
+
end
|
12
|
+
|
13
|
+
# creates directory where all records will be saved
|
14
|
+
directory = Dir.pwd + "/#{@config['destination']}"
|
15
|
+
Dir.mkdir(directory) unless File.directory?(directory)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.configuration
|
19
|
+
@config
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
RecordMe.configure
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# set custom configuration for record_me
|
2
|
+
# top => sets absolute top position
|
3
|
+
# left => sets absolute top position
|
4
|
+
# time => sets the time to record expressed in seconds; max 3 minutes (180 sec.)
|
5
|
+
# destination => the directory where records will be saved
|
6
|
+
|
7
|
+
development:
|
8
|
+
top: 40%
|
9
|
+
left: 40%
|
10
|
+
time: 30
|
11
|
+
name: record.wav
|
12
|
+
destination: public/records
|
13
|
+
|
14
|
+
#staging:
|
15
|
+
# top: 40%
|
16
|
+
# left: 40%
|
17
|
+
# time: 30
|
18
|
+
# name: record.wav
|
19
|
+
# destination: public/records
|
20
|
+
|
21
|
+
#production:
|
22
|
+
# top: 40%
|
23
|
+
# left: 40%
|
24
|
+
# time: 30
|
25
|
+
# name: record.wav
|
26
|
+
# destination: public/records
|
27
|
+
|
@@ -0,0 +1,245 @@
|
|
1
|
+
/*
|
2
|
+
* jRecorder Plugin for jQuery JavaScript Library (Alpha)
|
3
|
+
* http://www.sajithmr.me/jrecorder
|
4
|
+
*
|
5
|
+
* Copyright (c) 2011 - 2013 Sajithmr.ME
|
6
|
+
* Dual licensed under the MIT and GPL licenses.
|
7
|
+
* - http://www.opensource.org/licenses/mit-license.php
|
8
|
+
* - http://www.gnu.org/copyleft/gpl.html
|
9
|
+
*
|
10
|
+
* Author: Sajith Amma
|
11
|
+
* Version: 1.1
|
12
|
+
* Date: 14 December 2011
|
13
|
+
*/
|
14
|
+
|
15
|
+
/* Code is not verified using http://www.jshint.com/ */
|
16
|
+
|
17
|
+
|
18
|
+
(function ($){
|
19
|
+
|
20
|
+
|
21
|
+
var methods = {
|
22
|
+
play : function( options ) {
|
23
|
+
|
24
|
+
alert(options);
|
25
|
+
|
26
|
+
},
|
27
|
+
pause : function( ) { }
|
28
|
+
|
29
|
+
};
|
30
|
+
|
31
|
+
|
32
|
+
var jRecorderSettings = {} ;
|
33
|
+
|
34
|
+
$.jRecorder = function( options, element ) {
|
35
|
+
// allow instantiation without initializing for simple inheritance
|
36
|
+
|
37
|
+
|
38
|
+
if(typeof(options) == "string")
|
39
|
+
{
|
40
|
+
if ( methods[options] )
|
41
|
+
{
|
42
|
+
return methods[ options ].apply( this, Array.prototype.slice.call( arguments, 1 ));
|
43
|
+
|
44
|
+
}
|
45
|
+
return false;
|
46
|
+
}
|
47
|
+
|
48
|
+
//if the element to be appended is not defind, append to body
|
49
|
+
if(element == undefined)
|
50
|
+
{
|
51
|
+
element = $("body");
|
52
|
+
}
|
53
|
+
|
54
|
+
//default settings
|
55
|
+
var settings = {
|
56
|
+
|
57
|
+
'rec_width': '300',
|
58
|
+
'rec_height': '200',
|
59
|
+
'rec_top': '0px',
|
60
|
+
'rec_left': '0px',
|
61
|
+
'recorderlayout_id' : 'flashrecarea',
|
62
|
+
'recorder_id' : 'audiorecorder',
|
63
|
+
'recorder_name': 'audiorecorder',
|
64
|
+
'wmode' : 'transparent',
|
65
|
+
'bgcolor': '#ff0000',
|
66
|
+
'swf_path': 'jRecorder.swf',
|
67
|
+
'host': 'acceptfile.php?filename=hello.wav',
|
68
|
+
'callback_started_recording' : function(){},
|
69
|
+
'callback_finished_recording' : function(){},
|
70
|
+
'callback_stopped_recording': function(){},
|
71
|
+
'callback_error_recording' : function(){},
|
72
|
+
'callback_activityTime': function(time){},
|
73
|
+
'callback_activityLevel' : function(level){}
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
};
|
80
|
+
|
81
|
+
|
82
|
+
//if option array is passed, merget the values
|
83
|
+
if ( options ) {
|
84
|
+
$.extend( settings, options );
|
85
|
+
}
|
86
|
+
|
87
|
+
jRecorderSettings = settings;
|
88
|
+
|
89
|
+
|
90
|
+
var myNav = navigator.userAgent.toLowerCase();
|
91
|
+
var ie = (myNav.indexOf('msie') != -1) ? true : false;
|
92
|
+
if(ie && parseInt(myNav.split('msie')[1]) <= 8) {
|
93
|
+
var objStr = '<object name="'+ settings['recorder_name'] +'" id="' + settings['recorder_id'] + '" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="'+ settings['rec_width'] +'" height="'+ settings['rec_height']+'"></object>';
|
94
|
+
|
95
|
+
var paramStr = [
|
96
|
+
'<param name="movie" value="'+ settings['swf_path'] + '?host=' + settings['host'] + '" />',
|
97
|
+
|
98
|
+
'<param name="allowScriptAccess" value="always" />',
|
99
|
+
'<param name="bgcolor" value="' + settings['bgcolor'] + '" />',
|
100
|
+
'<param name="wmode" value="' + settings['wmode'] + '" />'
|
101
|
+
];
|
102
|
+
|
103
|
+
htmlObj = document.createElement(objStr);
|
104
|
+
for(var i=0; i < paramStr.length; i++) {
|
105
|
+
htmlObj.appendChild(document.createElement(paramStr[i]));
|
106
|
+
}
|
107
|
+
|
108
|
+
|
109
|
+
//var divStr = ' <div id="'+ settings['recorderlayout_id'] +'" style="position:absolute;top:0px;left:0px;z-index:-1" ></div>';
|
110
|
+
//var divObj = document.createElement(divStr);
|
111
|
+
|
112
|
+
|
113
|
+
} else {
|
114
|
+
var createParam = function(el, n, v) {
|
115
|
+
var p = document.createElement("param");
|
116
|
+
p.setAttribute("name", n);
|
117
|
+
p.setAttribute("value", v);
|
118
|
+
el.appendChild(p);
|
119
|
+
};
|
120
|
+
|
121
|
+
htmlObj = document.createElement("object");
|
122
|
+
htmlObj.setAttribute("id", settings['recorder_id'] );
|
123
|
+
htmlObj.setAttribute("name", settings['recorder_name'] );
|
124
|
+
htmlObj.setAttribute("data", settings['swf_path'] + '?host=' + settings['host'] );
|
125
|
+
htmlObj.setAttribute("type", "application/x-shockwave-flash");
|
126
|
+
htmlObj.setAttribute("width", settings['rec_width']); // Non-zero
|
127
|
+
htmlObj.setAttribute("height", settings['rec_height']); // Non-zero
|
128
|
+
|
129
|
+
createParam(htmlObj, "allowscriptaccess", "always");
|
130
|
+
createParam(htmlObj, "bgcolor", settings['bgcolor']);
|
131
|
+
createParam(htmlObj, "wmode", settings['wmode'] );
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
}
|
137
|
+
|
138
|
+
|
139
|
+
var divObj = document.createElement("div");
|
140
|
+
|
141
|
+
divObj.setAttribute("id", settings['recorderlayout_id']);
|
142
|
+
divObj.setAttribute("style", "position:absolute;top:"+ settings['rec_top'] +";left:"+ settings['rec_left'] +";z-index:-1");
|
143
|
+
|
144
|
+
divObj.appendChild(htmlObj);
|
145
|
+
|
146
|
+
|
147
|
+
element.append(divObj);
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
};
|
157
|
+
|
158
|
+
//function call to start a recording
|
159
|
+
$.jRecorder.record = function(max_time){
|
160
|
+
|
161
|
+
|
162
|
+
//change z-index to make it top
|
163
|
+
$( '#' + jRecorderSettings['recorderlayout_id'] ).css('z-index', 1000);
|
164
|
+
getFlashMovie(jRecorderSettings['recorder_name']).jStartRecording(max_time);
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
}
|
169
|
+
|
170
|
+
//function call to stop recording
|
171
|
+
$.jRecorder.stop = function(){
|
172
|
+
|
173
|
+
getFlashMovie(jRecorderSettings['recorder_name']).jStopRecording();
|
174
|
+
|
175
|
+
}
|
176
|
+
|
177
|
+
//function call to send wav data to server url from the init configuration
|
178
|
+
$.jRecorder.sendData = function(){
|
179
|
+
|
180
|
+
getFlashMovie(jRecorderSettings['recorder_name']).jSendFileToServer();
|
181
|
+
|
182
|
+
}
|
183
|
+
|
184
|
+
$.jRecorder.callback_started_recording = function(){
|
185
|
+
|
186
|
+
|
187
|
+
jRecorderSettings['callback_started_recording']();
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
|
192
|
+
$.jRecorder.callback_finished_recording = function(){
|
193
|
+
|
194
|
+
jRecorderSettings['callback_finished_recording']();
|
195
|
+
|
196
|
+
}
|
197
|
+
|
198
|
+
$.jRecorder.callback_error_recording = function(){
|
199
|
+
|
200
|
+
jRecorderSettings['callback_error_recording']();
|
201
|
+
|
202
|
+
}
|
203
|
+
|
204
|
+
$.jRecorder.callback_stopped_recording = function(){
|
205
|
+
|
206
|
+
jRecorderSettings['callback_stopped_recording']();
|
207
|
+
}
|
208
|
+
|
209
|
+
|
210
|
+
$.jRecorder.callback_finished_sending = function(){
|
211
|
+
|
212
|
+
jRecorderSettings['callback_finished_sending']();
|
213
|
+
|
214
|
+
}
|
215
|
+
|
216
|
+
$.jRecorder.callback_activityLevel = function(level){
|
217
|
+
|
218
|
+
jRecorderSettings['callback_activityLevel'](level);
|
219
|
+
|
220
|
+
}
|
221
|
+
|
222
|
+
$.jRecorder.callback_activityTime = function(time){
|
223
|
+
|
224
|
+
//put back flash while recording
|
225
|
+
$( '#' + jRecorderSettings['recorderlayout_id'] ).css('z-index', -1);
|
226
|
+
|
227
|
+
jRecorderSettings['callback_activityTime'](time);
|
228
|
+
|
229
|
+
}
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
//function to return flash object from name
|
235
|
+
function getFlashMovie(movieName) {
|
236
|
+
var isIE = navigator.appName.indexOf("Microsoft") != -1;
|
237
|
+
return (isIE) ? window[movieName] : document[movieName];
|
238
|
+
}
|
239
|
+
|
240
|
+
|
241
|
+
|
242
|
+
})(jQuery);
|
243
|
+
|
244
|
+
|
245
|
+
|
Binary file
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module RecordMe
|
4
|
+
class InitializeGenerator < ::Rails::Generators::Base
|
5
|
+
source_root File.expand_path('..', __FILE__)
|
6
|
+
|
7
|
+
desc "This generator adds all RecordMe configuration files to your app"
|
8
|
+
|
9
|
+
# copy config files
|
10
|
+
def copy_initializer_file
|
11
|
+
|
12
|
+
copy_file "../../config/initializer/record_me.rb", "config/initializers/record_me.rb"
|
13
|
+
copy_file "../../config/record_me.yml", "config/record_me.yml"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module RecordMe
|
4
|
+
class InstallGenerator < ::Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../assets', __FILE__)
|
6
|
+
|
7
|
+
desc "This generator adds all RecordMe required files to your assets"
|
8
|
+
|
9
|
+
# all public methods in here will be run in order
|
10
|
+
def copy_assets
|
11
|
+
copy_file "../../assets/javascripts/jRecorder.js", "app/assets/javascripts/jRecorder.js"
|
12
|
+
copy_file "../../assets/swfs/jRecorder.swf", "app/assets/swfs/jRecorder.swf"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/record_me.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "record_me/controller.rb"
|
2
|
+
require "record_me/helpers.rb"
|
3
|
+
require "generators/install_generator.rb"
|
4
|
+
require "generators/initialize_generator.rb"
|
5
|
+
|
6
|
+
ActiveSupport.on_load(:action_controller) do
|
7
|
+
include RecordMe::Controller
|
8
|
+
end
|
9
|
+
|
10
|
+
ActiveSupport.on_load(:action_view) do
|
11
|
+
include RecordMe::Helpers
|
12
|
+
end
|
13
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module RecordMe
|
2
|
+
module Controller
|
3
|
+
def record_me_save(filename = params[:filename])
|
4
|
+
audio = request.raw_post
|
5
|
+
file_with_path = RecordMe.configuration["destination"] + "/" + filename
|
6
|
+
|
7
|
+
return save_file(file_with_path, audio)
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def save_file(file_with_path, audio)
|
13
|
+
File.open(file_with_path, 'w+b'){|file| file.puts audio}
|
14
|
+
|
15
|
+
File.exist?(file_with_path) ? true : false
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module RecordMe
|
2
|
+
module Helpers
|
3
|
+
|
4
|
+
def flash_warning_message(html_element)
|
5
|
+
javascript_tag do
|
6
|
+
("
|
7
|
+
$(function() {\n\
|
8
|
+
var flash_supported = (typeof navigator.plugins != \"undefined\" && typeof navigator.plugins[\"Shockwave Flash\"] == \"object\");\n\
|
9
|
+
if(!flash_supported){\n\
|
10
|
+
var append_message = \".#{html_element || '.flash_warning_message'}\";\n\
|
11
|
+
$(append_message).append(\"Please install <a href='https://get.adobe.com/flashplayer/' target='_blank'>Adobe Flash Player</a> to use RecordMe.\");\n\
|
12
|
+
}\n\
|
13
|
+
})\n\
|
14
|
+
").html_safe
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def record_me_js(options = {})
|
19
|
+
javascript_tag do
|
20
|
+
("\n\
|
21
|
+
$(function(){\n\
|
22
|
+
$('body').prepend('<div id=record_me_location></div>');\n\
|
23
|
+
var recorderLocation = $('#record_me_location')[0];\n\
|
24
|
+
var recorderStart = $('.record_me_start')[0];\n\
|
25
|
+
var recorderStop = $('.record_me_stop')[0];\n\
|
26
|
+
var recorderSendData = $('.record_me_save')[0];\n\
|
27
|
+
var recorderReproduce = $('.record_me_reproduce')[0];\n\
|
28
|
+
$.jRecorder(\n\
|
29
|
+
{\n\
|
30
|
+
rec_top: \"#{options[:top] || RecordMe.configuration['top']}\",\n\
|
31
|
+
rec_left: \"#{options[:left] || RecordMe.configuration['left']}\",\n\
|
32
|
+
host: \"#{options[:save_path] || ''}?filename=#{options[:name] || RecordMe.configuration['name']}\",\n\
|
33
|
+
callback_started_recording: function(){callback_started(); },\n\
|
34
|
+
callback_stopped_recording: function(){callback_stopped(); },\n\
|
35
|
+
callback_activityLevel: function(level){callback_activityLevel(level); },\n\
|
36
|
+
callback_activityTime: function(time){callback_activityTime(time);},\n\
|
37
|
+
callback_finished_sending: function(time){ callback_finished_sending() },\n\
|
38
|
+
swf_path : \"/assets/jRecorder.swf\",\n\
|
39
|
+
}, $(recorderLocation));\n\
|
40
|
+
|
41
|
+
$(recorderStart).click(function(){\n\
|
42
|
+
$.jRecorder.record(#{options[:time] || 30});\n\
|
43
|
+
});\n\
|
44
|
+
|
45
|
+
$(recorderStop).click(function(){\n\
|
46
|
+
$.jRecorder.stop();\n\
|
47
|
+
});\n\
|
48
|
+
|
49
|
+
$(recorderReproduce).click(function(){\n\
|
50
|
+
//jRecorder doesn't have an option to reproduce the clip, by stopping it we can accomplish that\n\
|
51
|
+
$.jRecorder.stop();\n\
|
52
|
+
});\n\
|
53
|
+
|
54
|
+
$(recorderSendData).click(function(){\n\
|
55
|
+
$.jRecorder.sendData();
|
56
|
+
});\n\
|
57
|
+
|
58
|
+
function callback_activityTime(time)\n\
|
59
|
+
{\n\
|
60
|
+
var time = parseInt(time);\n\
|
61
|
+
var minutes = Math.floor(time/60);\n\
|
62
|
+
var seconds = time % 60;\n\
|
63
|
+
timer(time, minutes, seconds);\n\
|
64
|
+
};\n\
|
65
|
+
|
66
|
+
function timer(time, minutes, seconds){\n\
|
67
|
+
seconds = ((time % 60) < 10) ? ('0' + seconds.toString()) : seconds.toString();\n\
|
68
|
+
$('.record_me_timer').html(minutes.toString() + ':' + seconds.toString());\n\
|
69
|
+
};\n\
|
70
|
+
})\n\
|
71
|
+
|
72
|
+
").html_safe
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
data/record_me.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'record_me/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "record_me"
|
8
|
+
spec.version = RecordMe::VERSION
|
9
|
+
spec.authors = ["Marco Gallardo"]
|
10
|
+
spec.email = ["marco.gallardo@tangosource.com"]
|
11
|
+
spec.description = %q{Record sounds}
|
12
|
+
spec.summary = %q{Record sounds}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: record_me
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Marco Gallardo
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2015-01-22 00:00:00 -06:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: bundler
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 3
|
30
|
+
version: "1.3"
|
31
|
+
type: :development
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rake
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
segments:
|
41
|
+
- 0
|
42
|
+
version: "0"
|
43
|
+
type: :development
|
44
|
+
version_requirements: *id002
|
45
|
+
description: Record sounds
|
46
|
+
email:
|
47
|
+
- marco.gallardo@tangosource.com
|
48
|
+
executables: []
|
49
|
+
|
50
|
+
extensions: []
|
51
|
+
|
52
|
+
extra_rdoc_files: []
|
53
|
+
|
54
|
+
files:
|
55
|
+
- .gitignore
|
56
|
+
- Gemfile
|
57
|
+
- LICENSE.txt
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
60
|
+
- config/initializer/record_me.rb
|
61
|
+
- config/record_me.yml
|
62
|
+
- lib/assets/javascripts/jRecorder.js
|
63
|
+
- lib/assets/swfs/jRecorder.swf
|
64
|
+
- lib/generators/initialize_generator.rb
|
65
|
+
- lib/generators/install_generator.rb
|
66
|
+
- lib/generators/templates/initializer.rb
|
67
|
+
- lib/record_me.rb
|
68
|
+
- lib/record_me/controller.rb
|
69
|
+
- lib/record_me/helpers.rb
|
70
|
+
- lib/record_me/version.rb
|
71
|
+
- record_me.gemspec
|
72
|
+
has_rdoc: true
|
73
|
+
homepage: ""
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
segments:
|
86
|
+
- 0
|
87
|
+
version: "0"
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
segments:
|
93
|
+
- 0
|
94
|
+
version: "0"
|
95
|
+
requirements: []
|
96
|
+
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 1.3.6
|
99
|
+
signing_key:
|
100
|
+
specification_version: 3
|
101
|
+
summary: Record sounds
|
102
|
+
test_files: []
|
103
|
+
|