Class: Helix::Video

Inherits:
Media show all
Includes:
Durationed
Defined in:
lib/helix/video.rb

Constant Summary

Constants inherited from Base

Base::METHODS_DELEGATED_TO_CLASS

Instance Attribute Summary

Attributes inherited from Base

#attributes, #config

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Durationed

included

Methods included from RESTful

#destroy, #update

Methods included from Uploadable

included

Methods inherited from Base

all, config, #custom_field, #custom_fields, find_all, get_data_sets, #guid, guid_name, #initialize, #load, #method_missing, plural_resource_label, #raw_response, #to_json, #to_xml, where

Constructor Details

This class inherits a constructor from Helix::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Helix::Base

Class Method Details

.resource_label_symSymbol

The class name, to be used by supporting classes. Such as Config which uses this method as a way to build URLs.

Examples:

Helix::Video.resource_label_sym #=> :video

17
# File 'lib/helix/video.rb', line 17

def self.resource_label_sym; :video; end

.slice(attrs = {}) ⇒ String

Used to create a slice video from an existing video. API doc reference: /doc/api/video/slice

Reference Twistage API documentation to see valid xml to pass. xml_string = "" Helix::Video.slice({ guid: "239c59483d346", use_raw_xml: xml_string })


32
33
34
# File 'lib/helix/video.rb', line 32

def self.slice(attrs={})
  rest_post(:slice, attrs)
end

.stillframe_for(guid, original_opts = {}) ⇒ String

Used to retrieve a stillframe for a video by using the video guid. API doc reference: /doc/api/video/still_frames

Examples:

sf_data = Helix::Video.stillframe_for("239c59483d346") #=> xDC\xF1?\xE9*?\xFF\xD9
File.open("original.jpg", "w") { |f| f.puts sf_data }

47
48
49
50
51
52
# File 'lib/helix/video.rb', line 47

def self.stillframe_for(guid, original_opts={})
  opts            = original_opts.clone
  RestClient.log  = 'helix.log' if opts.delete(:log)
  url             = stillframe_url(guid, opts)
  RestClient.get(url)
end

Instance Method Details

#download(opts = {}) ⇒ String

Used to download data for the given Video.

Examples:

video      = Helix::Video.find("239c59483d346")
video_data = video.download #=> xDC\xF1?\xE9*?\xFF\xD9
File.open("my_video.mp4", "w") { |f| f.puts video_data }

63
64
65
# File 'lib/helix/video.rb', line 63

def download(opts={})
  generic_download(opts.merge(action: :file))
end

#play(opts = {}) ⇒ String

Used to play the given Video.

Examples:

video      = Helix::Video.find("239c59483d346")
video_data = video.play #=> xDC\xF1?\xE9*?\xFF\xD9

75
76
77
# File 'lib/helix/video.rb', line 75

def play(opts={})
  generic_download(opts.merge(action: :play))
end

#stillframe(opts = {}) ⇒ String

Used to retrieve a stillframe data for a video by using the video guid.

Examples:

video   = Helix::Video.find("239c59483d346")
sf_data = video.stillframe #=> xDC\xF1?\xE9*?\xFF\xD9
File.open("original.jpg", "w") { |f| f.puts sf_data }

89
90
91
# File 'lib/helix/video.rb', line 89

def stillframe(opts={})
  self.class.stillframe_for(self.guid, opts)
end