Class: RVideoController

Inherits:
Object
  • Object
show all
Defined in:
datavyu_api.rb

Overview

Provide access to Datavyu's video controllers.

Class Method Summary collapse

Class Method Details

.mixer_controllerObject

Returns Datavyu's mixer controller

Returns:

  • Datavyu's mixer controller



2755
2756
2757
# File 'datavyu_api.rb', line 2755

def self.mixer_controller
  video_controller.get_mixer_controller
end

.new_video(filepath, plugin, onset = 0, timeout = 5) ⇒ True, False

Add a video to the current spreadsheet/controller.

Parameters:

  • filepath (String)

    path to the file

  • plugin (String)

    id of the plugin to use; either UUID or short name: ffmpeg, nativeosx, mpv

  • onset (Integer) (defaults to: 0)

    start point of video in milliseconds

  • timeout (Integer) (defaults to: 5)

    seconds to wait for the video to load up

Returns:

  • (True, False)

    true if filepath and plugin are valid, false otherwise

Since:

  • 1.4.2



2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
# File 'datavyu_api.rb', line 2788

def self.new_video(filepath, plugin, onset=0, timeout=5)
  if plugin_uuids.key?(plugin)
    plugin_id = plugin_uuids[plugin]
  elsif plugin_uuids.value?(plugin)
    plugin_id = plugin
  else
    raise "Warning: invalid plugin \"#{plugin}\""
  end

  uuid = java.util.UUID.from_string(plugin_id)
  id = video_controller.open_video(filepath, uuid)
  return false if id.nil?
  p id
  success = set_video_onset(id, onset, timeout)
  puts "WARNING: added video but timed out trying to set start point." unless success
end

.plugin_of(video) ⇒ String

Get the name of the plugin a video is using

Parameters:

  • video

    video stream

Returns:

  • (String)

    short name of plugin used to open the video



2822
2823
2824
2825
# File 'datavyu_api.rb', line 2822

def self.plugin_of(video)
  uuid = plugin_uuid_of(video)
  plugin_uuids.key(uuid)
end

.plugin_uuid_of(video) ⇒ UUID

Get the uuid of the plugin a video is using

Parameters:

  • video

    video stream

Returns:

  • (UUID)

    plugin uuid of video



2813
2814
2815
2816
2817
# File 'datavyu_api.rb', line 2813

def self.plugin_uuid_of(video)
  org.datavyu.plugins.PluginManager.get_instance
     .get_associated_plugin(video.get_class.get_name)
     .get_plugin_uuid.to_s
end

.plugin_uuidsHash

Returns mapping from plugin names to UUID.

Returns:

  • (Hash)

    mapping from plugin names to UUID.



2742
2743
2744
2745
2746
2747
# File 'datavyu_api.rb', line 2742

def self.plugin_uuids
  {
    'ffmpeg' => 'f13f226e-df7e-31dc-8bba-f35c71e53479',
    'nativeosx' => 'db3fc496-58a7-3706-8538-3f61278b5bec'
  }
end

.set_video_onset(stream_id, onset, timeout = 5) ⇒ Object

Set the start point of a video

Parameters:

  • stream_id

    stream identifier

  • onset (Long)

    start time

  • timeout (Integer) (defaults to: 5)

    seconds to wait for video repositioning to finish



2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
# File 'datavyu_api.rb', line 2768

def self.set_video_onset(stream_id, onset, timeout = 5)
  success = false
  t = Time.now
  while (Time.now - t).to_f < timeout
    success = tracks_controller.set_track_offset(stream_id, onset)
    break if success

    sleep(0.5)
  end
  video_controller.repaint
  success
end

.tracks_controllerObject

Returns Datavyu's video tracks controller

Returns:

  • Datavyu's video tracks controller



2760
2761
2762
# File 'datavyu_api.rb', line 2760

def self.tracks_controller
  mixer_controller.get_tracks_editor_controller
end

.video_controllerObject

Returns Datavyu's video controller

Returns:

  • Datavyu's video controller



2750
2751
2752
# File 'datavyu_api.rb', line 2750

def self.video_controller
  Datavyu.get_video_controller
end

.videosObject

Returns video streams

Returns:

  • video streams



2806
2807
2808
# File 'datavyu_api.rb', line 2806

def self.videos
  video_controller.get_stream_viewers
end