Class: OpenTok::Archives
- Inherits:
-
Object
- Object
- OpenTok::Archives
- Defined in:
- lib/opentok/archives.rb
Overview
A class for working with OpenTok archives.
Instance Method Summary (collapse)
-
- (ArchiveList) all(options = {})
Returns an ArchiveList, which is an array of archives that are completed and in-progress, for your API key.
-
- (Archive) create(session_id, options = {})
Starts archiving an OpenTok session.
-
- (Object) delete_by_id(archive_id)
Deletes an OpenTok archive.
-
- (Archive) find(archive_id)
Gets an Archive object for the given archive ID.
-
- (Archive) stop_by_id(archive_id)
Stops an OpenTok archive that is being recorded.
Instance Method Details
- (ArchiveList) all(options = {})
Returns an ArchiveList, which is an array of archives that are completed and in-progress, for your API key.
101 102 103 104 105 |
# File 'lib/opentok/archives.rb', line 101 def all( = {}) raise ArgumentError, "Limit is invalid" unless [:count].nil? or (0..100).include? [:count] archive_list_json = @client.list_archives([:offset], [:count]) ArchiveList.new self, archive_list_json end |
- (Archive) create(session_id, options = {})
Starts archiving an OpenTok session.
Clients must be actively connected to the OpenTok session for you to successfully start recording an archive.
You can only record one archive at a time for a given session. You can only record archives of sessions that use the OpenTok Media Router (sessions with the media mode set to routed); you cannot archive sessions with the media mode set to relayed.
For more information on archiving, see the OpenTok archiving programming guide.
:name.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/opentok/archives.rb', line 59 def create(session_id, = {}) raise ArgumentError, "session_id not provided" if session_id.to_s.empty? # normalize opts so all keys are symbols and only include valid_opts valid_opts = [ :name, :has_audio, :has_video, :output_mode ] opts = .inject({}) do |m,(k,v)| if valid_opts.include? k.to_sym m[k.to_sym] = v end m end archive_json = @client.start_archive(session_id, opts) Archive.new self, archive_json end |
- (Object) delete_by_id(archive_id)
Deletes an OpenTok archive.
You can only delete an archive which has a status of "available", "uploaded", or "deleted". Deleting an archive removes its record from the list of archives. For an "available" archive, it also removes the archive file, making it unavailable for download. For a "deleted" archive, the archive remains deleted.
141 142 143 144 145 |
# File 'lib/opentok/archives.rb', line 141 def delete_by_id(archive_id) raise ArgumentError, "archive_id not provided" if archive_id.to_s.empty? response = @client.delete_archive(archive_id) (200..300).include? response.code end |
- (Archive) find(archive_id)
Gets an Archive object for the given archive ID.
84 85 86 87 88 |
# File 'lib/opentok/archives.rb', line 84 def find(archive_id) raise ArgumentError, "archive_id not provided" if archive_id.to_s.empty? archive_json = @client.get_archive(archive_id.to_s) Archive.new self, archive_json end |
- (Archive) stop_by_id(archive_id)
Stops an OpenTok archive that is being recorded.
Archives automatically stop recording after 90 minutes or when all clients have disconnected from the session being archived.
122 123 124 125 126 |
# File 'lib/opentok/archives.rb', line 122 def stop_by_id(archive_id) raise ArgumentError, "archive_id not provided" if archive_id.to_s.empty? archive_json = @client.stop_archive(archive_id) Archive.new self, archive_json end |