You can also view
You are viewing documentation for version 11. This is the most recent stable release!

How do I call methods on a microphone instance?

You can get your microphone's JS instance by accessing it in the CameraTag microphones array once the microphone has initialized:
CameraTag.observe(YOUR_MICROPHONE_ID, "initialized", function(){
myMicrophone = CameraTag.microphones["YOUR_MICROPHONE_ID"];
}) 
Note that the MICROPHONE_ID listed above should match the 'id' attribute of the <microphone> tag and not the 'data-app-id' attribute.

Once you have the instance calling methods is as simple as

myMicrophone.record();

record()

Starts the recording process (preroll + recording). You should make sure that the microphone is in the readyToRecord state before calling record.

pauseRecording()

Pauses recording.

resumeRecording()

Started recording after a pause (will not work after recording is stopped)

play()

Starts playback of recorded video

stopPlayback()

Stops playback

stopRecording()

Starts the recording process (preroll + recording)

publish()

published the currently recorded video. You should make sure the microphone is in the readyToPublish state before calling publish.

getState()

gets the current state of the recorder- returns one of:
  • initialized
  • recording
  • readyToPublish
  • publishing
  • published
  • processed

getVideo()

Returns a JS Object containing information about the video to be recorded. This object will contain the video UUID, recording formats, and (once the microphone is in the published state) video and thumbnail URLs
{
  "id": "00017b40-164d-0130-b327-12313b093125",
  "camera_id": "51d36a00-7a03-0130-3e48-1231390fcc11",
  "user_id": "543cbeb0-7944-0130-3e26-1231390fcc11",
  "uuid": "00017b40-164d-0130-b327-12313b093125",
  "file": null,
  "size": null,
  "params": null,
  "state": "processed",
  "origin": "Framey Import",
  "created_at": "2012-11-21T21:04:45.000Z",
  "updated_at": "2013-03-29T16:55:11.000Z",
  "form_data": null,
  "short_code": null,
  "browser": null,
  "ip": null,
  "publish_type": null,
  "published_at": null,
  "media_type": null,
  "notified_at": null,
  "queue_name": null,
  "queue_id": null,
  "client_version": null,
  "host": "assets.cameratag.com",
  "media_accesses_count": 0,
  "name": null,
  "description": null,
  "moderation_state": null,
  "video_file_file_name": null,
  "video_file_content_type": null,
  "video_file_file_size": null,
  "video_file_updated_at": null,
  "asset_file_file_name": null,
  "asset_file_content_type": null,
  "asset_file_file_size": null,
  "asset_file_updated_at": null,
  "transcription_job_id": null
}

setMetadata( js_object )

Allows you to pass arbitrary data to be stored with your video on our server. This data will be returned as part of the video object in the REST API and server callbacks.

reset()

re-initializes the player to record a new video to the server. Once you call this method you must wait for the "cameraReset" event before attempting to use <microphone> or JS API again.

destroy()

removes the camera and it's associated assets / references from the DOM

connect()

opens connection to the server and starts microphone. Unless you're doing something fancy custom you should probably be using the record() method which will connect automatically for you.

record_without_countdown()

starts recording immediatly (make sure you're connected). Unless you're doing something fancy custom you should probably be using the record() method. You should make sure the microphone is in the readyToRecord state before calling record_without_countdown.

showRecorder()

displays the microphone stream in the swf. Unless you're doing something fancy custom you should probably be using the record() method.

showPlayer()

displays the playback stream in the swf. Unless you're doing something fancy custom you should probably be using the play() method.

setMaxLength( seconds )

sets the maximum recording length. Helpful if you need to change recording lengths after calling reset()

setSignature( signature_string )

This can be used to set (or change) the <microphone>'s signaure when "require signature for publishing" security setting is truned on.

setSignatureExpiration( expiration_integer )

This can be used to set (or change) the <microphone>'s signaure expiration when "require signature for publishing" security setting is truned on.

setMinLength( seconds )

sets the minimum recording length. Helpful if you need to change recording lengths after calling reset()

startUpload()

manually triggers the selected file to start uploading (used in conjunction with data-upload-on-seekect).

restartUpload()

restarts a file upload. can be used in the case of a stalled upload due to network issues.