Module: MultimediaParadise::GUI::Gtk::VideoPlayerModule

Includes:
Gtk::BaseModule
Included in:
VideoPlayer
Defined in:
lib/multimedia_paradise/gui/shared_code/video_player/video_player_module.rb

Constant Summary collapse

NAMESPACE =
#

NAMESPACE

#
inspect
TITLE =
#

TITLE

#
'Video Player'
WIDTH =
#

WIDTH

#
'80%'
HEIGHT =
#

HEIGHT

#
500

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.run(i = ARGV) ⇒ Object

#

MultimediaParadise::GUI::Gtk::VideoPlayerModule.run

#


172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/multimedia_paradise/gui/shared_code/video_player/video_player_module.rb', line 172

def self.run(
    i = ARGV
  )
  require 'gtk_paradise/run'
  r = ::Gtk.run
  r.realize # At this point the widget will also receive an X11 XID value.
  xid_value = r.window.xid.to_s
  _ = ::MultimediaParadise::GUI::Gtk::VideoPlayer.new({ xid: xid_value })
  r << _
  r.automatic
  r.top_left_then_run
end

Instance Method Details

#border_size?Boolean

#

border_size?

#

Returns:

  • (Boolean)


109
110
111
# File 'lib/multimedia_paradise/gui/shared_code/video_player/video_player_module.rb', line 109

def border_size?
  2
end

#connect_skeletonObject

#

connect_skeleton (connect tag)

#


122
123
124
# File 'lib/multimedia_paradise/gui/shared_code/video_player/video_player_module.rb', line 122

def connect_skeleton
  abort_on_exception
end

#create_skeletonObject

#

create_skeleton (create tag)

#


116
117
# File 'lib/multimedia_paradise/gui/shared_code/video_player/video_player_module.rb', line 116

def create_skeleton
end

#do_play_a_random_videoObject

#

do_play_a_random_video

#


129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/multimedia_paradise/gui/shared_code/video_player/video_player_module.rb', line 129

def do_play_a_random_video
  # ======================================================================= #
  # The -wid option tells mpv to connect to the window represented by the
  # ID $WINDOW_XID.
  #
  # Note that a simpler alternative to obtaining the xid value would be:
  #
  #   drawing_area.window.xid
  #
  # For now I retain the approach I chosen specified at the end of this
  # file, though.
  # ======================================================================= #
  _ = 'mpv --wid='+@xid_value.to_s+
      ' --start=280 '+
      return_random_video
  esystem _
end

#initialize(commandline_arguments = ARGV, run_already = true) ⇒ Object

#

initialize

#


49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/multimedia_paradise/gui/shared_code/video_player/video_player_module.rb', line 49

def initialize(
    commandline_arguments = ARGV,
    run_already           = true
  )
  super(:vertical)
  reset
  _ = commandline_arguments
  # ======================================================================= #
  # === Handle Hashes first
  # ======================================================================= #
  if _.is_a? Hash
    if _.has_key? :xid_value
      @xid_value = _.delete(:xid_value)
    elsif _.has_key? :xid
      @xid_value = _.delete(:xid)
    end
  end
  run if run_already
end

#padding?Boolean

#

padding?

#

Returns:

  • (Boolean)


102
103
104
# File 'lib/multimedia_paradise/gui/shared_code/video_player/video_player_module.rb', line 102

def padding?
  0
end

#resetObject

#

reset (reset tag)

#


72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/multimedia_paradise/gui/shared_code/video_player/video_player_module.rb', line 72

def reset
  reset_the_internal_variables
  # ======================================================================= #
  # === @configuration
  # ======================================================================= #
  @configuration = [true, __dir__, NAMESPACE]
  # ======================================================================= #
  # === @title
  # ======================================================================= #
  @title  = TITLE
  # ======================================================================= #
  # === @width
  # ======================================================================= #
  set_width(WIDTH)
  # ======================================================================= #
  # === @height
  # ======================================================================= #
  set_height(HEIGHT)
  # ======================================================================= #
  # === @xid_value
  # ======================================================================= #
  @xid_value = nil
  set_use_this_font(:dejavu_condensed_22)
  append_project_css_file
  infer_the_size_automatically
end

#runObject

#

run (run tag)

#


150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/multimedia_paradise/gui/shared_code/video_player/video_player_module.rb', line 150

def run
  create_skeleton_then_connect_skeleton
  drawing_area = gtk_drawing_area
  drawing_area.set_size_request(640, 180)
  drawing_area.modify_background(:normal, :black)
  drawing_area.bblack2
  button = button('Play a <b>random</b> video')
  button.do_markify
  button.bblack2
  button.on_clicked {
    do_play_a_random_video
  }
  add_horizontal_spacer
  add(drawing_area)
  add_horizontal_spacer
  add(button)
  add_horizontal_spacer
end