├── .DS_Store
├── README
├── flash-fla
├── .DS_Store
├── AudioRecorderCS4-1.0.fla
├── AudioRecorderCS4.fla
├── AudioRecorderCS4.swf
├── Main.as
└── org
│ ├── .DS_Store
│ ├── .svn
│ ├── all-wcprops
│ └── entries
│ ├── as3wavsound
│ ├── WavSound.as
│ ├── WavSoundChannel.as
│ ├── WavSoundPlayer.as
│ └── sazameki
│ │ ├── core
│ │ ├── AudioSamples.as
│ │ └── AudioSetting.as
│ │ └── format
│ │ ├── riff
│ │ ├── Chunk.as
│ │ ├── LIST.as
│ │ └── RIFF.as
│ │ └── wav
│ │ ├── Wav.as
│ │ └── chunk
│ │ ├── WavdataChunk.as
│ │ └── WavfmtChunk.as
│ └── bytearray
│ ├── .DS_Store
│ ├── .svn
│ ├── all-wcprops
│ └── entries
│ └── micrecorder
│ ├── .DS_Store
│ ├── .svn
│ ├── all-wcprops
│ ├── entries
│ └── text-base
│ │ ├── IEncoder.as.svn-base
│ │ └── MicRecorder.as.svn-base
│ ├── IEncoder.as
│ ├── MicRecorder.as
│ ├── encoder
│ ├── .svn
│ │ ├── all-wcprops
│ │ ├── entries
│ │ └── text-base
│ │ │ └── WaveEncoder.as.svn-base
│ └── WaveEncoder.as
│ └── events
│ ├── .svn
│ ├── all-wcprops
│ ├── entries
│ └── text-base
│ │ └── RecordingEvent.as.svn-base
│ └── RecordingEvent.as
├── html
├── .DS_Store
├── acceptfile.php
├── example1.html
├── example2.html
├── jRecorder.js
├── jRecorder.swf
└── jquery.min.js
└── javascript
├── .DS_Store
├── jRecorder-1.0.js
├── jRecorder-1.1.js
├── jRecorder.js
└── jquery.min.js
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sythoos/jRecorder/8843f1fe7ac5d94550d56e3dfda398978fd9ca66/.DS_Store
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | Author: Sajith Amma
2 | Description: jRecorder is a jQuery plugin to enable a flash recorder in your webpages. You DON'T need to have a flash streaming server or RED5 server to do this recording.
3 |
4 | Project Documentation: http://www.sajithmr.me/jrecorder/
5 |
6 | Example Implementation: http://www.sajithmr.me/jrecorder/example1.html
7 |
8 | Author Domain: www.sajithmr.me
--------------------------------------------------------------------------------
/flash-fla/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sythoos/jRecorder/8843f1fe7ac5d94550d56e3dfda398978fd9ca66/flash-fla/.DS_Store
--------------------------------------------------------------------------------
/flash-fla/AudioRecorderCS4-1.0.fla:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sythoos/jRecorder/8843f1fe7ac5d94550d56e3dfda398978fd9ca66/flash-fla/AudioRecorderCS4-1.0.fla
--------------------------------------------------------------------------------
/flash-fla/AudioRecorderCS4.fla:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sythoos/jRecorder/8843f1fe7ac5d94550d56e3dfda398978fd9ca66/flash-fla/AudioRecorderCS4.fla
--------------------------------------------------------------------------------
/flash-fla/AudioRecorderCS4.swf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sythoos/jRecorder/8843f1fe7ac5d94550d56e3dfda398978fd9ca66/flash-fla/AudioRecorderCS4.swf
--------------------------------------------------------------------------------
/flash-fla/Main.as:
--------------------------------------------------------------------------------
1 | package
{
import flash.display.Sprite;
import flash.media.Microphone;
import flash.system.Security;
import org.bytearray.micrecorder.*;
import org.bytearray.micrecorder.events.RecordingEvent;
import org.bytearray.micrecorder.encoder.WaveEncoder;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.events.ActivityEvent;
import fl.transitions.Tween;
import fl.transitions.easing.Strong;
import flash.net.FileReference;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import flash.display.LoaderInfo;
import flash.external.ExternalInterface;
import flash.media.Sound;
import org.as3wavsound.WavSound;
import org.as3wavsound.WavSoundChannel;
public class Main extends Sprite
{
private var mic:Microphone;
private var waveEncoder:WaveEncoder = new WaveEncoder();
private var recorder:MicRecorder = new MicRecorder(waveEncoder);
private var recBar:RecBar = new RecBar();
private var maxTime:Number = 30;
private var tween:Tween;
private var fileReference:FileReference = new FileReference();
private var tts:WavSound;
public function Main():void
{
trace('recoding');
recButton.visible = false;
activity.visible = false ;
godText.visible = false;
recBar.visible = false;
mic = Microphone.getMicrophone();
mic.setSilenceLevel(5);
mic.gain = 50;
mic.setLoopBack(false);
mic.setUseEchoSuppression(true);
Security.showSettings("2");
addListeners();
}
private function addListeners():void
{
recorder.addEventListener(RecordingEvent.RECORDING, recording);
recorder.addEventListener(Event.COMPLETE, recordComplete);
activity.addEventListener(Event.ENTER_FRAME, updateMeter);
//accept call from javascript to start recording
ExternalInterface.addCallback("jStartRecording", jStartRecording);
ExternalInterface.addCallback("jStopRecording", jStopRecording);
ExternalInterface.addCallback("jSendFileToServer", jSendFileToServer);
}
//external java script function call to start record
public function jStartRecording(max_time):void
{
maxTime = max_time;
if (mic != null)
{
recorder.record();
ExternalInterface.call("$.jRecorder.callback_started_recording");
}
else
{
ExternalInterface.call("$.jRecorder.callback_error_recording", 0);
}
}
//external javascript function to trigger stop recording
public function jStopRecording():void
{
recorder.stop();
mic.setLoopBack(false);
ExternalInterface.call("$.jRecorder.callback_stopped_recording");
//finalize_recording();
}
public function jSendFileToServer():void
{
finalize_recording();
}
public function jStopPreview():void
{
//no function is currently available;
}
private function updateMeter(e:Event):void
{
ExternalInterface.call("$.jRecorder.callback_activityLevel", mic.activityLevel);
}
private function recording(e:RecordingEvent):void
{
var currentTime:int = Math.floor(e.time / 1000);
ExternalInterface.call("$.jRecorder.callback_activityTime", String(currentTime) );
if(currentTime == maxTime )
{
jStopRecording();
}
}
private function recordComplete(e:Event):void
{
//fileReference.save(recorder.output, "recording.wav");
//finalize_recording();
preview_recording();
}
private function preview_recording():void
{
tts = new WavSound(recorder.output);
tts.play();
ExternalInterface.call("$.jRecorder.callback_started_preview");
}
//functioon send data to server
private function finalize_recording():void
{
var _var1:String= '';
var globalParam = LoaderInfo(this.root.loaderInfo).parameters;
for (var element:String in globalParam) {
if (element == 'host'){
_var1 = globalParam[element];
}
}
ExternalInterface.call("$.jRecorder.callback_finished_recording");
if(_var1 != '')
{
var req:URLRequest = new URLRequest(_var1);
req.contentType = 'application/octet-stream';
req.method = URLRequestMethod.POST;
req.data = recorder.output;
var loader:URLLoader = new URLLoader(req);
ExternalInterface.call("$.jRecorder.callback_finished_sending");
}
}
private function getFlashVars():Object {
return Object( LoaderInfo( this.loaderInfo ).parameters );
}
}
}
--------------------------------------------------------------------------------
/flash-fla/org/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sythoos/jRecorder/8843f1fe7ac5d94550d56e3dfda398978fd9ca66/flash-fla/org/.DS_Store
--------------------------------------------------------------------------------
/flash-fla/org/.svn/all-wcprops:
--------------------------------------------------------------------------------
1 | K 25
2 | svn:wc:ra_dav:version-url
3 | V 59
4 | /muzicall/!svn/ver/20727/ringtagzfb/trunk/htdocs/images/org
5 | END
6 |
--------------------------------------------------------------------------------
/flash-fla/org/.svn/entries:
--------------------------------------------------------------------------------
1 | 10
2 |
3 | dir
4 | 20727
5 | http://sajith@10.2.30.40/muzicall/ringtagzfb/trunk/htdocs/images/org
6 | http://sajith@10.2.30.40/muzicall
7 |
8 |
9 |
10 | 2011-08-31T17:22:19.696868Z
11 | 20727
12 | sajith
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | 0013cf6a-2276-4056-9bbb-7e8f5601526d
28 |
29 | bytearray
30 | dir
31 |
32 |
--------------------------------------------------------------------------------
/flash-fla/org/as3wavsound/WavSound.as:
--------------------------------------------------------------------------------
1 | package org.as3wavsound {
2 | import flash.events.SampleDataEvent;
3 | import flash.media.Sound;
4 | import flash.media.SoundChannel;
5 | import flash.media.SoundLoaderContext;
6 | import flash.media.SoundTransform;
7 | import flash.net.URLRequest;
8 | import flash.utils.ByteArray;
9 | import org.as3wavsound.sazameki.core.AudioSamples;
10 | import org.as3wavsound.sazameki.core.AudioSetting;
11 | import org.as3wavsound.sazameki.format.wav.Wav;
12 |
13 | /*
14 | * --------------------------------------
15 | * b.bottema [Codemonkey] -- WavSound Sound adaption
16 | * http://blog.projectnibble.org/
17 | * --------------------------------------
18 | * sazameki -- audio manipulating library
19 | * http://sazameki.org/
20 | * --------------------------------------
21 | *
22 | * - developed by:
23 | * Benny Bottema (Codemonkey)
24 | * blog.projectnibble.org
25 | * hosted by:
26 | * Google Code (code.google.com)
27 | * code.google.com/p/as3wavsound/
28 | *
29 | * - audio library in its original state developed by:
30 | * Takaaki Yamazaki
31 | * www.zkdesign.jp
32 | * hosted by:
33 | * Spark project (www.libspark.org)
34 | * www.libspark.org/svn/as3/sazameki/branches/fp10/
35 | */
36 |
37 | /*
38 | * Licensed under the MIT License
39 | *
40 | * Copyright (c) 2008 Takaaki Yamazaki
41 | *
42 | * Permission is hereby granted, free of charge, to any person obtaining a copy
43 | * of this software and associated documentation files (the "Software"), to deal
44 | * in the Software without restriction, including without limitation the rights
45 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
46 | * copies of the Software, and to permit persons to whom the Software is
47 | * furnished to do so, subject to the following conditions:
48 | *
49 | * The above copyright notice and this permission notice shall be included in
50 | * all copies or substantial portions of the Software.
51 | *
52 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
53 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
54 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
55 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
56 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
57 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
58 | * THE SOFTWARE.
59 | */
60 |
61 | /**
62 | * Sound extension that directly plays WAVE data. Also backwards compatible with
63 | * MP3's played through the load() method.
64 | *
65 | * Simply embed .wav files as you would mp3's and play with this Sound class.
66 | * Make sure you provide mimetype 'application/octet-stream' when embedding to
67 | * ensure Flash embeds the data as ByteArray.
68 | *
69 | * Example:
70 | * [Embed(source = "drumloop.wav", mimeType = "application/octet-stream")]
71 | * public const DrumLoop:Class;
72 | * public const rain:Sound = new WavSound(new DrumLoop() as ByteArray);
73 | *
74 | *
75 | * @author b.bottema [Codemonkey]
76 | */
77 | public class WavSound {
78 |
79 | // the master Sound player, which mixes all playing WavSound samples on any given moment
80 | private static const player:WavSoundPlayer = new WavSoundPlayer();
81 |
82 | // length of the original encoded wav data
83 | private var _bytesTotal:Number;
84 | // extracted sound data for mixing
85 | private var _samples:AudioSamples;
86 | // each sound can be configured to be played mono/stereo using AudioSetting
87 | private var _playbackSettings:AudioSetting;
88 | // calculated length of the entire sound in milliseconds, made global to avoid recalculating all the time
89 | private var _length:Number;
90 |
91 | /**
92 | * Constructor: loads wavdata using loadWav().
93 | *
94 | * @param wavData A ByteArray containing uncmopressed wav data.
95 | * @param audioSettings An optional playback configuration (mono/stereo,
96 | * sample rate and bit rate).
97 | */
98 | public function WavSound(wavData:ByteArray, audioSettings:AudioSetting = null) {
99 | load(wavData, audioSettings);
100 | }
101 |
102 | /**
103 | * Loads WAVE data.
104 | *
105 | * Resets this WavSound and turns off legacy mode to act as a WavSound object.
106 | *
107 | * @param wavData
108 | * @param audioSettings
109 | */
110 | internal function load(wavData:ByteArray, audioSettings:AudioSetting = null): void {
111 | this._bytesTotal = wavData.length;
112 | this._samples = new Wav().decode(wavData);
113 | this._playbackSettings = (audioSettings != null) ? audioSettings : new AudioSetting();
114 | this._length = samples.length / samples.setting.sampleRate * 1000;
115 | }
116 |
117 | /**
118 | * Playback function that performs the following tasks:
119 | *
120 | * - calculates the startingPhase, bases on startTime in ms.
121 | * - initializes loopsLeft variable
122 | * - adds the playing channel in combination with its originating WavSound to the playingWavSounds
123 | *
124 | * @param startTime The starting time in milliseconds, applies to each loop (as with regular MP3 Sounds).
125 | * @param loops The number of loops to take in *addition* to the default playback (loops == 2 -> 3 playthroughs).
126 | * @param sndTransform An optional soundtransform to apply for playback that controls volume and panning.
127 | * @return The SoundChannel used for playing back the sound.
128 | */
129 | public function play(startTime:Number = 0, loops:int = 0, sndTransform:SoundTransform = null): WavSoundChannel {
130 | return player.play(this, startTime, loops, sndTransform);
131 | }
132 |
133 | /**
134 | * No idea if this works. Alpha state. Read up on Sound.extract():
135 | * http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Sound.html#extract()
136 | */
137 | public function extract(target:ByteArray, length:Number, startPosition:Number = -1): Number {
138 | var start:Number = Math.max(startPosition, 0);
139 | var end:Number = Math.min(length, samples.length);
140 |
141 | for (var i:Number = start; i < end; i++) {
142 | target.writeFloat(samples.left[i]);
143 | if (samples.setting.channels == 2) {
144 | target.writeFloat(samples.right[i]);
145 | } else {
146 | target.writeFloat(samples.left[i]);
147 | }
148 | }
149 |
150 | return samples.length;
151 | }
152 |
153 | /**
154 | * Returns the total bytes of the wavData the current WavSound was created with.
155 | */
156 | public function get bytesLoaded () : uint {
157 | return _bytesTotal;
158 | }
159 |
160 | /**
161 | * Returns the total bytes of the wavData the current WavSound was created with.
162 | */
163 | public function get bytesTotal () : int {
164 | return _bytesTotal;
165 | }
166 |
167 | /**
168 | * Returns the total length of the sound in milliseconds.
169 | */
170 | public function get length() : Number {
171 | return _length;
172 | }
173 |
174 | internal function get samples():AudioSamples {
175 | return _samples;
176 | }
177 |
178 | internal function get playbackSettings():AudioSetting {
179 | return _playbackSettings;
180 | }
181 | }
182 | }
--------------------------------------------------------------------------------
/flash-fla/org/as3wavsound/WavSoundChannel.as:
--------------------------------------------------------------------------------
1 | package org.as3wavsound {
2 | import flash.events.EventDispatcher;
3 | import flash.media.SoundChannel;
4 | import flash.events.Event;
5 | import flash.media.SoundTransform;
6 | import org.as3wavsound.sazameki.core.AudioSamples;
7 | import org.as3wavsound.WavSound;
8 |
9 | /**
10 | * Used to keep track of open channels during playback. Each channel represents
11 | * an 'instance' of a sound and so each channel is responsible for its own mixing.
12 | *
13 | * Also see buffer().
14 | *
15 | * @author b.bottema [Codemonkey]
16 | */
17 | public class WavSoundChannel extends EventDispatcher {
18 |
19 | /*
20 | * creation-time information
21 | */
22 |
23 | // the player to delegate play() stop() requests to
24 | private var player:WavSoundPlayer;
25 |
26 | // a WavSound currently playing back on one or several channels
27 | private var _wavSound:WavSound;
28 |
29 | // works the same as SoundChannel.soundTransform
30 | private var _soundTransform:SoundTransform = new SoundTransform();
31 |
32 | /*
33 | * play-time information *per WavSound*
34 | */
35 |
36 | // starting phase if not at the beginning, made global to avoid recalculating all the time
37 | private var startPhase:Number;
38 | // current phase of the sound, basically matches a single current sample frame for each WavSound
39 | private var phase:Number = 0;
40 | // the current avarage volume of samples buffered to the left audiochannel
41 | private var _leftPeak:Number = 0;
42 | // the current avarage volume of samples buffered to the right audiochannel
43 | private var _rightPeak:Number = 0;
44 | // how many loops we need to buffer
45 | private var loopsLeft:Number;
46 | // indicates if the phase has reached total sample count and no loops are left
47 | private var finished:Boolean;
48 |
49 | /**
50 | * Constructor: pre-calculates starting phase (and performs some validation for this).
51 | */
52 | public function WavSoundChannel(player:WavSoundPlayer, wavSound:WavSound, startTime:Number, loops:int, soundTransform:SoundTransform) {
53 | this.player = player;
54 | this._wavSound = wavSound;
55 | if (soundTransform != null) {
56 | this._soundTransform = soundTransform;
57 | }
58 | init(startTime, loops);
59 | }
60 |
61 | /**
62 | * Calculates and validates the starting time. Starting time in milliseconds is converted into
63 | * sample position and then marked as starting phase.
64 | */
65 | internal function init(startTime:Number, loops:int):void {
66 | var startPositionInMillis:Number = Math.floor(startTime);
67 | var maxPositionInMillis:Number = Math.floor(_wavSound.length);
68 | if (startPositionInMillis > maxPositionInMillis) {
69 | throw new Error("startTime greater than sound's length, max startTime is " + maxPositionInMillis);
70 | }
71 | phase = startPhase = Math.floor(startPositionInMillis * _wavSound.samples.length / _wavSound.length);
72 | finished = false;
73 | loopsLeft = loops;
74 | }
75 |
76 | public function stop():void {
77 | player.stop(this);
78 | }
79 |
80 | /**
81 | * Fills a target samplebuffer with optionally transformed samples from the current
82 | * WavSound instance (which is the current channel).
83 | *
84 | * Keeps filling the buffer for each loop the sound should be mixed in the target buffer.
85 | * When the buffer is full, phase and loopsLeft keep track of how which and many samples
86 | * still need to be buffered in the next buffering cycle (when this method is called again).
87 | *
88 | * @param sampleBuffer The target buffer to mix in the current (transformed) samples.
89 | * @param soundTransform The soundtransform that belongs to a single channel being played
90 | * (containing volume, panning etc.).
91 | */
92 | internal function buffer(sampleBuffer:AudioSamples):void {
93 | // calculate volume and panning
94 | var volume: Number = (_soundTransform.volume / 1);
95 | var volumeLeft: Number = volume * (1 - _soundTransform.pan) / 2;
96 | var volumeRight: Number = volume * (1 + _soundTransform.pan) / 2;
97 | // channel settings
98 | var needRightChannel:Boolean = _wavSound.playbackSettings.channels == 2;
99 | var hasRightChannel:Boolean = _wavSound.samples.setting.channels == 2;
100 |
101 | // extra references to avoid excessive getter calls in the following
102 | // for-loop (it appeares CPU is being hogged otherwise)
103 | var samplesLength:Number = _wavSound.samples.length;
104 | var samplesLeft:Vector. In this example, you add a flash recorder with some call back function. $.jRecorder function is called with all initial settings.
31 | If the second parameter for $.jRecorder is not there, plugin insert the flash recorder inside the body tag. You can specify where to insert
32 | the flash recorder with second parameter. See example2.html for this.
33 | Download the plugin: jRecorder.zip This Record button trigger the record event. See the javascript example in the bottom of the page. (View Source in your browser).
94 |
95 | This Stop button trigger the stop record event.
110 |
111 | This SendData button trigger the sendData event to flash to send the wav data to Server (configured in the host parameter).
120 |
121 |
122 |
143 | Time area is used to update the time. There is an event Listener which update the recording time dynamically.
144 |
23 | *
24 | * recorder.addEventListener ( RecordingEvent.RECORDING, onRecording );
25 | *
26 | *
39 | *
40 | * recorder.addEventListener ( Event.COMPLETE, onRecordComplete );
41 | *
42 | *
23 | *
24 | * recorder.addEventListener ( RecordingEvent.RECORDING, onRecording );
25 | *
26 | *
39 | *
40 | * recorder.addEventListener ( Event.COMPLETE, onRecordComplete );
41 | *
42 | * jRecorder Example 1 - Insert flash recorder inside the body tag
29 |
30 |
96 | $('#record').click(function(){
97 |
98 | $.jRecorder.record(30); //record up to 30 sec and stops automatically
99 |
100 | })
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
112 | Onclick of this button trigger $.jRecorder.sendData() which send the data to the Server
113 |
114 |
115 |
116 |
117 |
118 |
119 |
123 |
124 |
125 | $('#stop').click(function(){
126 |
127 | $.jRecorder.stop();
128 |
129 | })
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
145 |
146 | callback_activityTime: function(time){callback_activityTime(time); //see the initialisation
147 |
148 | //function callback
149 | function callback_activityTime(time)
150 | {
151 |
152 |
153 | $('#time').html(time);
154 |
155 | }
156 |
157 |
158 |
In this example, you add a flash recorder with some call back function. $.jRecorder function is called with all initial settings and a second parameter 28 | indicate where to insert this recorder. Call the $.jRecorder script only after the div. (Better to use javascript at the bottom always, or you can use $(document).ready function) See example1.html for inserting this inside body tag. 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 |This Record button trigger the record event. See the javascript example in the bottom of the page. (View Source in your browser). 99 | 100 |
101 | $('#record').click(function(){ 102 | 103 | $.jRecorder.record(30); //record up to 30 sec and stops automatically 104 | 105 | }) 106 |107 | 108 | 109 | 110 |
This Stop button trigger the stop record event. 115 | 116 |
117 | $('#stop').click(function(){ 118 | 119 | $.jRecorder.stop(); 120 | 121 | }) 122 |123 | 124 | 125 | 126 |
135 | Time area is used to update the time. There is an event Listener which update the recording time dynamically. 136 |
137 | 138 | callback_activityTime: function(time){callback_activityTime(time); //see the initialisation 139 | 140 | //function callback 141 | function callback_activityTime(time) 142 | { 143 | 144 | 145 | $('#time').html(time); 146 | 147 | } 148 | 149 |150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 267 | 268 | -------------------------------------------------------------------------------- /html/jRecorder.js: -------------------------------------------------------------------------------- 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 | 91 | if($.browser.msie && Number($.browser.version) <= 8) { 92 | var objStr = ''; 93 | 94 | var paramStr = [ 95 | '', 96 | 97 | '', 98 | '', 99 | '' 100 | ]; 101 | 102 | htmlObj = document.createElement(objStr); 103 | for(var i=0; i < paramStr.length; i++) { 104 | htmlObj.appendChild(document.createElement(paramStr[i])); 105 | } 106 | 107 | 108 | //var divStr = ' '; 109 | //var divObj = document.createElement(divStr); 110 | 111 | 112 | } else { 113 | var createParam = function(el, n, v) { 114 | var p = document.createElement("param"); 115 | p.setAttribute("name", n); 116 | p.setAttribute("value", v); 117 | el.appendChild(p); 118 | }; 119 | 120 | htmlObj = document.createElement("object"); 121 | htmlObj.setAttribute("id", settings['recorder_id'] ); 122 | htmlObj.setAttribute("name", settings['recorder_name'] ); 123 | htmlObj.setAttribute("data", settings['swf_path'] + '?host=' + settings['host'] ); 124 | htmlObj.setAttribute("type", "application/x-shockwave-flash"); 125 | htmlObj.setAttribute("width", settings['rec_width']); // Non-zero 126 | htmlObj.setAttribute("height", settings['rec_height']); // Non-zero 127 | 128 | createParam(htmlObj, "allowscriptaccess", "always"); 129 | createParam(htmlObj, "bgcolor", settings['bgcolor']); 130 | createParam(htmlObj, "wmode", settings['wmode'] ); 131 | 132 | 133 | 134 | 135 | } 136 | 137 | 138 | var divObj = document.createElement("div"); 139 | 140 | divObj.setAttribute("id", settings['recorderlayout_id']); 141 | divObj.setAttribute("style", "position:absolute;top:"+ settings['rec_top'] +";left:"+ settings['rec_left'] +";z-index:-1"); 142 | 143 | divObj.appendChild(htmlObj); 144 | 145 | 146 | element.append(divObj); 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | }; 156 | 157 | //function call to start a recording 158 | $.jRecorder.record = function(max_time){ 159 | 160 | 161 | //change z-index to make it top 162 | $( '#' + jRecorderSettings['recorderlayout_id'] ).css('z-index', 1000); 163 | getFlashMovie(jRecorderSettings['recorder_name']).jStartRecording(max_time); 164 | 165 | 166 | 167 | } 168 | 169 | //function call to stop recording 170 | $.jRecorder.stop = function(){ 171 | 172 | getFlashMovie(jRecorderSettings['recorder_name']).jStopRecording(); 173 | 174 | } 175 | 176 | //function call to send wav data to server url from the init configuration 177 | $.jRecorder.sendData = function(){ 178 | 179 | getFlashMovie(jRecorderSettings['recorder_name']).jSendFileToServer(); 180 | 181 | } 182 | 183 | $.jRecorder.callback_started_recording = function(){ 184 | 185 | 186 | jRecorderSettings['callback_started_recording'](); 187 | 188 | } 189 | 190 | 191 | $.jRecorder.callback_finished_recording = function(){ 192 | 193 | jRecorderSettings['callback_finished_recording'](); 194 | 195 | } 196 | 197 | $.jRecorder.callback_error_recording = function(){ 198 | 199 | jRecorderSettings['callback_error_recording'](); 200 | 201 | } 202 | 203 | $.jRecorder.callback_stopped_recording = function(){ 204 | 205 | jRecorderSettings['callback_stopped_recording'](); 206 | } 207 | 208 | 209 | $.jRecorder.callback_finished_sending = function(){ 210 | 211 | jRecorderSettings['callback_finished_sending'](); 212 | 213 | } 214 | 215 | $.jRecorder.callback_activityLevel = function(level){ 216 | 217 | jRecorderSettings['callback_activityLevel'](level); 218 | 219 | } 220 | 221 | $.jRecorder.callback_activityTime = function(time){ 222 | 223 | //put back flash while recording 224 | $( '#' + jRecorderSettings['recorderlayout_id'] ).css('z-index', -1); 225 | 226 | jRecorderSettings['callback_activityTime'](time); 227 | 228 | } 229 | 230 | 231 | 232 | 233 | //function to return flash object from name 234 | function getFlashMovie(movieName) { 235 | var isIE = navigator.appName.indexOf("Microsoft") != -1; 236 | return (isIE) ? window[movieName] : document[movieName]; 237 | } 238 | 239 | 240 | 241 | })(jQuery); 242 | 243 | 244 | 245 | -------------------------------------------------------------------------------- /html/jRecorder.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sythoos/jRecorder/8843f1fe7ac5d94550d56e3dfda398978fd9ca66/html/jRecorder.swf -------------------------------------------------------------------------------- /javascript/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sythoos/jRecorder/8843f1fe7ac5d94550d56e3dfda398978fd9ca66/javascript/.DS_Store -------------------------------------------------------------------------------- /javascript/jRecorder-1.0.js: -------------------------------------------------------------------------------- 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.0 12 | * Date: 26 October 2011 13 | */ 14 | 15 | /* Code is not verified using http://www.jshint.com/ */ 16 | 17 | 18 | 19 | 20 | (function ($){ 21 | 22 | 23 | var methods = { 24 | play : function( options ) { 25 | 26 | alert(options); 27 | 28 | }, 29 | pause : function( ) { } 30 | 31 | }; 32 | 33 | 34 | var jRecorderSettings = {} ; 35 | 36 | $.jRecorder = function( options, element ) { 37 | // allow instantiation without initializing for simple inheritance 38 | 39 | 40 | if(typeof(options) == "string") 41 | { 42 | if ( methods[options] ) 43 | { 44 | return methods[ options ].apply( this, Array.prototype.slice.call( arguments, 1 )); 45 | 46 | } 47 | return false; 48 | } 49 | 50 | //if the element to be appended is not defind, append to body 51 | if(element == undefined) 52 | { 53 | element = $("body"); 54 | } 55 | 56 | //default settings 57 | var settings = { 58 | 59 | 'rec_width': '300', 60 | 'rec_height': '200', 61 | 'rec_top': '0px', 62 | 'rec_left': '0px', 63 | 'recorderlayout_id' : 'flashrecarea', 64 | 'recorder_id' : 'audiorecorder', 65 | 'recorder_name': 'audiorecorder', 66 | 'wmode' : 'transparent', 67 | 'bgcolor': '#ff0000', 68 | 'swf_path': 'jRecorder.swf', 69 | 'host': 'acceptfile.php?filename=hello.wav', 70 | 'callback_started_recording' : function(){}, 71 | 'callback_finished_recording' : function(){}, 72 | 'callback_stopped_recording': function(){}, 73 | 'callback_error_recording' : function(){}, 74 | 'callback_activityTime': function(time){}, 75 | 'callback_activityLevel' : function(level){} 76 | 77 | 78 | 79 | 80 | 81 | }; 82 | 83 | 84 | //if option array is passed, merget the values 85 | if ( options ) { 86 | $.extend( settings, options ); 87 | } 88 | 89 | jRecorderSettings = settings; 90 | 91 | 92 | 93 | if($.browser.msie && Number($.browser.version) <= 8) { 94 | var objStr = ''; 95 | 96 | var paramStr = [ 97 | '', 98 | 99 | '', 100 | '', 101 | '' 102 | ]; 103 | 104 | htmlObj = document.createElement(objStr); 105 | for(var i=0; i < paramStr.length; i++) { 106 | htmlObj.appendChild(document.createElement(paramStr[i])); 107 | } 108 | 109 | 110 | //var divStr = ' '; 111 | //var divObj = document.createElement(divStr); 112 | 113 | 114 | } else { 115 | var createParam = function(el, n, v) { 116 | var p = document.createElement("param"); 117 | p.setAttribute("name", n); 118 | p.setAttribute("value", v); 119 | el.appendChild(p); 120 | }; 121 | 122 | htmlObj = document.createElement("object"); 123 | htmlObj.setAttribute("id", settings['recorder_id'] ); 124 | htmlObj.setAttribute("name", settings['recorder_name'] ); 125 | htmlObj.setAttribute("data", settings['swf_path'] + '?host=' + settings['host'] ); 126 | htmlObj.setAttribute("type", "application/x-shockwave-flash"); 127 | htmlObj.setAttribute("width", settings['rec_width']); // Non-zero 128 | htmlObj.setAttribute("height", settings['rec_height']); // Non-zero 129 | 130 | createParam(htmlObj, "allowscriptaccess", "always"); 131 | createParam(htmlObj, "bgcolor", settings['bgcolor']); 132 | createParam(htmlObj, "wmode", settings['wmode'] ); 133 | 134 | 135 | 136 | 137 | } 138 | 139 | 140 | var divObj = document.createElement("div"); 141 | 142 | divObj.setAttribute("id", settings['recorderlayout_id']); 143 | divObj.setAttribute("style", "position:absolute;top:"+ settings['rec_top'] +";left:"+ settings['rec_left'] +";z-index:-1"); 144 | 145 | divObj.appendChild(htmlObj); 146 | 147 | 148 | 149 | element.append(divObj); 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | }; 159 | 160 | //function call to start a recording 161 | $.jRecorder.record = function(max_time){ 162 | 163 | 164 | //change z-index to make it top 165 | $( '#' + jRecorderSettings['recorderlayout_id'] ).css('z-index', 1000); 166 | getFlashMovie(jRecorderSettings['recorder_name']).jStartRecording(max_time); 167 | 168 | 169 | 170 | } 171 | 172 | //function call to stop recording 173 | $.jRecorder.stop = function(){ 174 | 175 | getFlashMovie(jRecorderSettings['recorder_name']).jStopRecording(); 176 | 177 | } 178 | 179 | 180 | $.jRecorder.callback_started_recording = function(){ 181 | 182 | 183 | jRecorderSettings['callback_started_recording'](); 184 | 185 | } 186 | 187 | 188 | $.jRecorder.callback_finished_recording = function(){ 189 | 190 | jRecorderSettings['callback_finished_recording'](); 191 | 192 | } 193 | 194 | $.jRecorder.callback_error_recording = function(){ 195 | 196 | jRecorderSettings['callback_error_recording'](); 197 | 198 | } 199 | 200 | $.jRecorder.callback_stopped_recording = function(){ 201 | 202 | jRecorderSettings['callback_stopped_recording'](); 203 | } 204 | 205 | 206 | $.jRecorder.callback_finished_sending = function(){ 207 | 208 | jRecorderSettings['callback_finished_sending'](); 209 | 210 | } 211 | 212 | $.jRecorder.callback_activityLevel = function(level){ 213 | 214 | jRecorderSettings['callback_activityLevel'](level); 215 | 216 | } 217 | 218 | $.jRecorder.callback_activityTime = function(time){ 219 | 220 | //put back flash while recording 221 | $( '#' + jRecorderSettings['recorderlayout_id'] ).css('z-index', -1); 222 | 223 | jRecorderSettings['callback_activityTime'](time); 224 | 225 | } 226 | 227 | 228 | 229 | 230 | //function to return flash object from name 231 | function getFlashMovie(movieName) { 232 | var isIE = navigator.appName.indexOf("Microsoft") != -1; 233 | return (isIE) ? window[movieName] : document[movieName]; 234 | } 235 | 236 | 237 | 238 | })(jQuery); 239 | 240 | 241 | 242 | -------------------------------------------------------------------------------- /javascript/jRecorder-1.1.js: -------------------------------------------------------------------------------- 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 | 91 | if($.browser.msie && Number($.browser.version) <= 8) { 92 | var objStr = ''; 93 | 94 | var paramStr = [ 95 | '', 96 | 97 | '', 98 | '', 99 | '' 100 | ]; 101 | 102 | htmlObj = document.createElement(objStr); 103 | for(var i=0; i < paramStr.length; i++) { 104 | htmlObj.appendChild(document.createElement(paramStr[i])); 105 | } 106 | 107 | 108 | //var divStr = ' '; 109 | //var divObj = document.createElement(divStr); 110 | 111 | 112 | } else { 113 | var createParam = function(el, n, v) { 114 | var p = document.createElement("param"); 115 | p.setAttribute("name", n); 116 | p.setAttribute("value", v); 117 | el.appendChild(p); 118 | }; 119 | 120 | htmlObj = document.createElement("object"); 121 | htmlObj.setAttribute("id", settings['recorder_id'] ); 122 | htmlObj.setAttribute("name", settings['recorder_name'] ); 123 | htmlObj.setAttribute("data", settings['swf_path'] + '?host=' + settings['host'] ); 124 | htmlObj.setAttribute("type", "application/x-shockwave-flash"); 125 | htmlObj.setAttribute("width", settings['rec_width']); // Non-zero 126 | htmlObj.setAttribute("height", settings['rec_height']); // Non-zero 127 | 128 | createParam(htmlObj, "allowscriptaccess", "always"); 129 | createParam(htmlObj, "bgcolor", settings['bgcolor']); 130 | createParam(htmlObj, "wmode", settings['wmode'] ); 131 | 132 | 133 | 134 | 135 | } 136 | 137 | 138 | var divObj = document.createElement("div"); 139 | 140 | divObj.setAttribute("id", settings['recorderlayout_id']); 141 | divObj.setAttribute("style", "position:absolute;top:"+ settings['rec_top'] +";left:"+ settings['rec_left'] +";z-index:-1"); 142 | 143 | divObj.appendChild(htmlObj); 144 | 145 | 146 | element.append(divObj); 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | }; 156 | 157 | //function call to start a recording 158 | $.jRecorder.record = function(max_time){ 159 | 160 | 161 | //change z-index to make it top 162 | $( '#' + jRecorderSettings['recorderlayout_id'] ).css('z-index', 1000); 163 | getFlashMovie(jRecorderSettings['recorder_name']).jStartRecording(max_time); 164 | 165 | 166 | 167 | } 168 | 169 | //function call to stop recording 170 | $.jRecorder.stop = function(){ 171 | 172 | getFlashMovie(jRecorderSettings['recorder_name']).jStopRecording(); 173 | 174 | } 175 | 176 | //function call to send wav data to server url from the init configuration 177 | $.jRecorder.sendData = function(){ 178 | 179 | getFlashMovie(jRecorderSettings['recorder_name']).jSendFileToServer(); 180 | 181 | } 182 | 183 | $.jRecorder.callback_started_recording = function(){ 184 | 185 | 186 | jRecorderSettings['callback_started_recording'](); 187 | 188 | } 189 | 190 | 191 | $.jRecorder.callback_finished_recording = function(){ 192 | 193 | jRecorderSettings['callback_finished_recording'](); 194 | 195 | } 196 | 197 | $.jRecorder.callback_error_recording = function(){ 198 | 199 | jRecorderSettings['callback_error_recording'](); 200 | 201 | } 202 | 203 | $.jRecorder.callback_stopped_recording = function(){ 204 | 205 | jRecorderSettings['callback_stopped_recording'](); 206 | } 207 | 208 | 209 | $.jRecorder.callback_finished_sending = function(){ 210 | 211 | jRecorderSettings['callback_finished_sending'](); 212 | 213 | } 214 | 215 | $.jRecorder.callback_activityLevel = function(level){ 216 | 217 | jRecorderSettings['callback_activityLevel'](level); 218 | 219 | } 220 | 221 | $.jRecorder.callback_activityTime = function(time){ 222 | 223 | //put back flash while recording 224 | $( '#' + jRecorderSettings['recorderlayout_id'] ).css('z-index', -1); 225 | 226 | jRecorderSettings['callback_activityTime'](time); 227 | 228 | } 229 | 230 | 231 | 232 | 233 | //function to return flash object from name 234 | function getFlashMovie(movieName) { 235 | var isIE = navigator.appName.indexOf("Microsoft") != -1; 236 | return (isIE) ? window[movieName] : document[movieName]; 237 | } 238 | 239 | 240 | 241 | })(jQuery); 242 | 243 | 244 | 245 | -------------------------------------------------------------------------------- /javascript/jRecorder.js: -------------------------------------------------------------------------------- 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 | Version changes 15 | 16 | Added preview option right after recording. 17 | Added seperate function sendData to trigger to send data to server (it won't send automcatically to server) 18 | 19 | 20 | */ 21 | 22 | /* Code is not verified using http://www.jshint.com/ */ 23 | 24 | 25 | (function ($){ 26 | 27 | 28 | var methods = { 29 | play : function( options ) { 30 | 31 | alert(options); 32 | 33 | }, 34 | pause : function( ) { } 35 | 36 | }; 37 | 38 | 39 | var jRecorderSettings = {} ; 40 | 41 | $.jRecorder = function( options, element ) { 42 | // allow instantiation without initializing for simple inheritance 43 | 44 | 45 | if(typeof(options) == "string") 46 | { 47 | if ( methods[options] ) 48 | { 49 | return methods[ options ].apply( this, Array.prototype.slice.call( arguments, 1 )); 50 | 51 | } 52 | return false; 53 | } 54 | 55 | //if the element to be appended is not defind, append to body 56 | if(element == undefined) 57 | { 58 | element = $("body"); 59 | } 60 | 61 | //default settings 62 | var settings = { 63 | 64 | 'rec_width': '300', 65 | 'rec_height': '200', 66 | 'rec_top': '0px', 67 | 'rec_left': '0px', 68 | 'recorderlayout_id' : 'flashrecarea', 69 | 'recorder_id' : 'audiorecorder', 70 | 'recorder_name': 'audiorecorder', 71 | 'wmode' : 'transparent', 72 | 'bgcolor': '#ff0000', 73 | 'swf_path': 'jRecorder.swf', 74 | 'host': 'acceptfile.php?filename=hello.wav', 75 | 'callback_started_recording' : function(){}, 76 | 'callback_finished_recording' : function(){}, 77 | 'callback_stopped_recording': function(){}, 78 | 'callback_error_recording' : function(){}, 79 | 'callback_activityTime': function(time){}, 80 | 'callback_activityLevel' : function(level){} 81 | 82 | 83 | 84 | 85 | 86 | }; 87 | 88 | 89 | //if option array is passed, merget the values 90 | if ( options ) { 91 | $.extend( settings, options ); 92 | } 93 | 94 | jRecorderSettings = settings; 95 | 96 | 97 | 98 | if($.browser.msie && Number($.browser.version) <= 8) { 99 | var objStr = ''; 100 | 101 | var paramStr = [ 102 | '', 103 | 104 | '', 105 | '', 106 | '' 107 | ]; 108 | 109 | htmlObj = document.createElement(objStr); 110 | for(var i=0; i < paramStr.length; i++) { 111 | htmlObj.appendChild(document.createElement(paramStr[i])); 112 | } 113 | 114 | 115 | //var divStr = ' '; 116 | //var divObj = document.createElement(divStr); 117 | 118 | 119 | } else { 120 | var createParam = function(el, n, v) { 121 | var p = document.createElement("param"); 122 | p.setAttribute("name", n); 123 | p.setAttribute("value", v); 124 | el.appendChild(p); 125 | }; 126 | 127 | htmlObj = document.createElement("object"); 128 | htmlObj.setAttribute("id", settings['recorder_id'] ); 129 | htmlObj.setAttribute("name", settings['recorder_name'] ); 130 | htmlObj.setAttribute("data", settings['swf_path'] + '?host=' + settings['host'] ); 131 | htmlObj.setAttribute("type", "application/x-shockwave-flash"); 132 | htmlObj.setAttribute("width", settings['rec_width']); // Non-zero 133 | htmlObj.setAttribute("height", settings['rec_height']); // Non-zero 134 | 135 | createParam(htmlObj, "allowscriptaccess", "always"); 136 | createParam(htmlObj, "bgcolor", settings['bgcolor']); 137 | createParam(htmlObj, "wmode", settings['wmode'] ); 138 | 139 | 140 | 141 | 142 | } 143 | 144 | 145 | var divObj = document.createElement("div"); 146 | 147 | divObj.setAttribute("id", settings['recorderlayout_id']); 148 | divObj.setAttribute("style", "position:absolute;top:"+ settings['rec_top'] +";left:"+ settings['rec_left'] +";z-index:-1"); 149 | 150 | divObj.appendChild(htmlObj); 151 | 152 | 153 | element.append(divObj); 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | }; 163 | 164 | //function call to start a recording 165 | $.jRecorder.record = function(max_time){ 166 | 167 | 168 | //change z-index to make it top 169 | $( '#' + jRecorderSettings['recorderlayout_id'] ).css('z-index', 1000); 170 | getFlashMovie(jRecorderSettings['recorder_name']).jStartRecording(max_time); 171 | 172 | 173 | 174 | } 175 | 176 | //function call to stop recording 177 | $.jRecorder.stop = function(){ 178 | 179 | getFlashMovie(jRecorderSettings['recorder_name']).jStopRecording(); 180 | 181 | } 182 | 183 | //function call to send wav data to server url from the init configuration 184 | $.jRecorder.sendData = function(){ 185 | 186 | getFlashMovie(jRecorderSettings['recorder_name']).jSendFileToServer(); 187 | 188 | } 189 | 190 | $.jRecorder.callback_started_recording = function(){ 191 | 192 | 193 | jRecorderSettings['callback_started_recording'](); 194 | 195 | } 196 | 197 | 198 | $.jRecorder.callback_finished_recording = function(){ 199 | 200 | jRecorderSettings['callback_finished_recording'](); 201 | 202 | } 203 | 204 | $.jRecorder.callback_error_recording = function(){ 205 | 206 | jRecorderSettings['callback_error_recording'](); 207 | 208 | } 209 | 210 | $.jRecorder.callback_stopped_recording = function(){ 211 | 212 | jRecorderSettings['callback_stopped_recording'](); 213 | } 214 | 215 | 216 | $.jRecorder.callback_finished_sending = function(){ 217 | 218 | jRecorderSettings['callback_finished_sending'](); 219 | 220 | } 221 | 222 | $.jRecorder.callback_activityLevel = function(level){ 223 | 224 | jRecorderSettings['callback_activityLevel'](level); 225 | 226 | } 227 | 228 | $.jRecorder.callback_activityTime = function(time){ 229 | 230 | //put back flash while recording 231 | $( '#' + jRecorderSettings['recorderlayout_id'] ).css('z-index', -1); 232 | 233 | jRecorderSettings['callback_activityTime'](time); 234 | 235 | } 236 | 237 | 238 | 239 | 240 | //function to return flash object from name 241 | function getFlashMovie(movieName) { 242 | var isIE = navigator.appName.indexOf("Microsoft") != -1; 243 | return (isIE) ? window[movieName] : document[movieName]; 244 | } 245 | 246 | 247 | 248 | })(jQuery); 249 | 250 | 251 | 252 | --------------------------------------------------------------------------------