glimmer-cw-video 0.1.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a029ae8b1eb4a79e6b3309549f3b9bba275cb63111f2c07f35cbf809b63465d9
4
- data.tar.gz: 80a94bd9c7e16f942c7274692b0eea2a0cefc6bc0d288d8576d63901dd32efb8
3
+ metadata.gz: 12ba9b4c7e64db7a363ab1d05166ae8d9ff916726f44a691f44dd3107fb1c839
4
+ data.tar.gz: ede349878b4b018aaef0c56718800884a79efe4ee7c4cecbf3045f10d6ee36f8
5
5
  SHA512:
6
- metadata.gz: 63c34b59eb60fa8ce1c1219f5828cb7fa4704bec5034b8f9270fc38c10d5a6eb4edd23ff3a0615a35c54f66bca85fdc12b1298a71c213a94383cd21109f66546
7
- data.tar.gz: 91dc10dc49b09faa432528f0cd19449300152e806ba710c04a3e64c6e9a8cc5083ed919d41801da511f26a73b0bad036d65e3261dbe40bcaddd5f6f1a6cf9c99
6
+ metadata.gz: 798c5b9f4089204b473902de74ad83d3434a8f6817dc5d36bcfab1364ae2b046b05668005cef6d02558f29f4b99e39a8722c91b3d7812f59df8d5bfb80bda35c
7
+ data.tar.gz: 103dd4980a6779c63e545837752eb593e3c2507854413bcddcac32c8cb9000669afaed8e2a5ee369f141836d0afc4f092221482cb880cdba89727fe24be4c8b1
@@ -0,0 +1,28 @@
1
+ # Change Log
2
+
3
+ ## 1.0.0
4
+
5
+ - Upgraded to Glimmer DSL for SWT 4.17.0.0
6
+ - Made samples available via the `glimmer` command (e.g. glimmer sample:run[hello_video])
7
+ - `#toggle` method for video play/pause action (plays if paused and pauses if playing)
8
+ - Handle non-absolute files
9
+ - Validate video file and raise error if invalid
10
+ - Fast-Forward & Rewind
11
+ - Volume get, set, up, and down
12
+ - mute, unmute, muted?, and toggle_muted
13
+
14
+ ## 0.1.3
15
+
16
+ - Fixed an issue with hooking widget observers via symbol instead of a string
17
+
18
+ ## 0.1.2
19
+
20
+ - Upgraded to the glimmer-dsl-swt 0.4.1, glimmer-dsl-xml 0.1.0, and glimmer-dsl-css 0.1.0
21
+
22
+ ## 0.1.1
23
+
24
+ - Upgraded to Glimmer 0.8.0 with a relaxed version requirement
25
+
26
+ ## 0.1.0
27
+
28
+ - Initial version
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Video 0.1.3
1
+ # Video 1.0.0
2
2
  ## [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=40 /> Glimmer Custom Widget](https://github.com/AndyObtiva/glimmer#custom-widget-gem)
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-cw-video.svg)](http://badge.fury.io/rb/glimmer-cw-video)
4
4
  [![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-cw-video.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-cw-video)
@@ -29,7 +29,7 @@ This has been tested and confirmed to be working on:
29
29
  Add the following to a Glimmer application `Gemfile`:
30
30
 
31
31
  ```ruby
32
- gem 'glimmer-cw-video', '0.1.3'
32
+ gem 'glimmer-cw-video', '1.0.0'
33
33
  ```
34
34
 
35
35
  Run:
@@ -49,9 +49,9 @@ require 'glimmer-cw-video'
49
49
  # ... more require statements follow
50
50
  ```
51
51
 
52
- ## Options
52
+ ## API Options
53
53
 
54
- Here are the options to pass in as hash arguments to the `video` widget keyword (see in [Examples](#examples)):
54
+ Here are the options to pass in as hash arguments to the `video` widget keyword (see in [Samples](#samples)):
55
55
  - `autoplay` (true [default] or false): plays video automatically as soon as loaded
56
56
  - `controls` (true [default] or false): displays controls
57
57
  - `looped` (true or false [default]): plays video in looped mode
@@ -61,10 +61,11 @@ Here are the options to pass in as hash arguments to the `video` widget keyword
61
61
  - `offset_x` (integer [default: 0]): offset from left border. Could be a negative number if you want to show only an area of the video. Useful when fit_to_width is false to pick an area of the video to display.
62
62
  - `offset_y` (integer [default: 0]): offset from top border. Could be a negative number if you want to show only an area of the video. Useful when fit_to_height is false to pick an area of the video to display.
63
63
 
64
- ## Methods
64
+ ## API Methods
65
65
 
66
66
  - `#play`: plays video
67
67
  - `#pause`: pauses video
68
+ - `#toggle`: toggles video playback, playing if paused, and pausing if playing.
68
69
  - `#reload`: reloads video restarting from beginning
69
70
  - `#position`: position in seconds (and fractions)
70
71
  - `#position=`: seeks a new position in video
@@ -73,17 +74,42 @@ Here are the options to pass in as hash arguments to the `video` widget keyword
73
74
  - `#playing?`: returns true when video is actively playing
74
75
  - `#paused?`: returns true when video is not playing
75
76
  - `#ended?`: returns true when video has reached the end (position == duration)
77
+ - `#volume`: returns video volume (0.0 - 1.0 float value)
78
+ - `#volume=`: sets video volume (0.0 - 1.0 float value)
79
+ - `#volume_up(value=0.05)`: bumps video volume up by a specified value or default
80
+ - `#volume_down(value=0.05)`: bumps video volume down by a specified value or default
81
+ - `#mute`: mutes video
82
+ - `#unmute`: unmutes video
83
+ - `#muted?`: returns true if video is muted
84
+ - `#toggle_muted`: mutes/unmutes video depending on `muted?` attribute
76
85
 
77
- ## Observer Events (see in [Examples](#examples)):
86
+
87
+ ## API Observer Events
88
+
89
+ (see in [Samples](#samples))
78
90
 
79
91
  - `on_loaded`: invoked when video `#loaded?` becomes true
80
92
  - `on_ended`: invoked when video `#ended?` becomes true
81
93
  - `on_playing`: invoked when video `#playing?` becomes true
82
94
  - `on_paused`: invoked when video `#paused?` becomes true
83
95
 
84
- ## Examples:
96
+ ## Samples
97
+
98
+ Run this command to list available Video samples:
99
+
100
+ ```
101
+ glimmer sample:list
102
+ ```
103
+
104
+ ### Hello, Video!
105
+
106
+ Run:
107
+
108
+ ```
109
+ glimmer sample:run[hello_video]
110
+ ```
85
111
 
86
- Example ([samples/hello_video.rb](samples/video/hello_video.rb)):
112
+ Glimmer Code (from [samples/video/hello_video.rb](samples/video/hello_video.rb)):
87
113
 
88
114
  ```ruby
89
115
  # ...
@@ -92,7 +118,19 @@ shell {
92
118
  }.open
93
119
  ```
94
120
 
95
- Example ([samples/hello_looped_video_with_black_background.rb](samples/video/hello_looped_video_with_black_background.rb)):
121
+ Glimmer App:
122
+
123
+ ![glimmer cw video hello video](images/glimmer-cw-video-hello-video.png)
124
+
125
+ ### Hello, Looped Video with Black Background!
126
+
127
+ Run:
128
+
129
+ ```
130
+ glimmer sample:run[hello_looped_video_with_black_background]
131
+ ```
132
+
133
+ Glimmer Code (from [samples/video/hello_looped_video_with_black_background.rb](samples/video/hello_looped_video_with_black_background.rb)):
96
134
 
97
135
  ```ruby
98
136
  # ...
@@ -102,28 +140,66 @@ shell {
102
140
  }.open
103
141
  ```
104
142
 
105
- Example ([samples/hello_video_observers.rb](samples/video/hello_video_observers.rb)):
143
+ Glimmer App:
144
+
145
+ ![glimmer cw video hello video](images/glimmer-cw-video-hello-looped-video-with-black-background.png)
146
+
147
+ ### Hello, Video Observers!
148
+
149
+ Run:
150
+
151
+ ```
152
+ glimmer sample:run[hello_video_observers]
153
+ ```
154
+
155
+ Glimmer Code (from [samples/video/hello_video_observers.rb](samples/video/hello_video_observers.rb)):
106
156
 
107
157
  ```ruby
108
158
  # ...
159
+ require_relative '../../lib/glimmer-cw-video'
160
+
161
+ include Glimmer
162
+
163
+ video_file = File.expand_path('../videos/Ants.mp4', __FILE__)
164
+
109
165
  def display_video_status(video, status)
110
- message_box = MessageBox.new(video.swt_widget.getShell)
111
- message_box.setText(status)
112
- message = "Video Position: #{video.position} seconds\n"
113
- message += "Video Duration: #{video.duration} seconds"
114
- message_box.setMessage(message)
115
- message_box.open
166
+ message_box {
167
+ text status
168
+ message "#{video.position.round(2)}/#{video.duration.round(2)} seconds have elapsed."
169
+ }.open
116
170
  end
117
171
 
118
172
  @shell = shell {
119
173
  minimum_size 800, 500
120
174
  @video = video(file: video_file, background: :black) {
175
+ on_swt_show { |event|
176
+ # set focus as soon as the SWT widget is shown to grab keyboard events below
177
+ @video.set_focus
178
+ }
179
+
180
+ on_key_pressed { |event|
181
+ case event.keyCode
182
+ when swt(:space), swt(:cr)
183
+ @video.toggle
184
+ when swt(:arrow_left)
185
+ @video.rewind
186
+ when swt(:arrow_right)
187
+ @video.fast_forward
188
+ when swt(:arrow_up)
189
+ @video.volume_up
190
+ when swt(:arrow_down)
191
+ @video.volume_down
192
+ end
193
+ }
194
+
121
195
  on_playing {
122
196
  display_video_status(@video, 'Playing')
123
197
  }
198
+
124
199
  on_paused {
125
200
  display_video_status(@video, 'Paused')
126
201
  }
202
+
127
203
  on_ended {
128
204
  display_video_status(@video, 'Ended')
129
205
  }
@@ -132,12 +208,17 @@ end
132
208
  @shell.open
133
209
  ```
134
210
 
211
+ Glimmer App:
212
+
213
+ ![glimmer cw video hello video observers](images/glimmer-cw-video-hello-video-observers.png)
214
+
215
+ ## TODO
216
+
217
+ [TODO.md](TODO.md)
218
+
135
219
  ## Change Log
136
220
 
137
- - 0.1.3: Fixed an issue with hooking widget observers via symbol instead of a string
138
- - 0.1.2: Upgraded to the glimmer-dsl-swt 0.4.1, glimmer-dsl-xml 0.1.0, and glimmer-dsl-css 0.1.0
139
- - 0.1.1: Upgraded to Glimmer 0.8.0 with a relaxed version requirement
140
- - 0.1.0: Initial version
221
+ [CHANGELOG.md](CHANGELOG.md)
141
222
 
142
223
  ## Contributing to glimmer-cw-video
143
224
 
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -4,3 +4,5 @@ require 'glimmer-dsl-swt'
4
4
  require 'glimmer-dsl-xml'
5
5
  require 'glimmer-dsl-css'
6
6
  require 'views/glimmer/video'
7
+
8
+ Glimmer::Config::SAMPLE_DIRECTORIES << File.expand_path('../../samples/video', __FILE__)
@@ -20,7 +20,12 @@ module Glimmer
20
20
  alias looped? looped
21
21
  alias fit_to_width? fit_to_width
22
22
  alias fit_to_height? fit_to_height
23
-
23
+
24
+ before_body {
25
+ file_source = file
26
+ raise "Video file does not exist: #{file_source}" if file_source && !file_source.start_with?('uri:classloader') && !File.exist?(File.expand_path(file_source))
27
+ }
28
+
24
29
  body {
25
30
  browser(:no_scroll) {
26
31
  text html {
@@ -66,7 +71,7 @@ module Glimmer
66
71
  }
67
72
  }
68
73
 
69
- def source
74
+ def source
70
75
  file_source = file
71
76
  if file_source
72
77
  if file_source.start_with?('uri:classloader')
@@ -81,6 +86,7 @@ module Glimmer
81
86
  File.binwrite(tmp_file, file_content)
82
87
  "file://#{tmp_file}"
83
88
  else
89
+ file_source = File.expand_path(file_source)
84
90
  "file://#{file_source}"
85
91
  end
86
92
  else
@@ -105,6 +111,10 @@ module Glimmer
105
111
  def pause
106
112
  video_action('pause')
107
113
  end
114
+
115
+ def toggle
116
+ paused? ? play : pause
117
+ end
108
118
 
109
119
  def reload
110
120
  video_action('load')
@@ -132,12 +142,56 @@ module Glimmer
132
142
  end
133
143
 
134
144
  def position=(new_position)
145
+ new_position = [new_position, 0].max
146
+ new_position = [new_position, duration].min
135
147
  video_attribute_set('currentTime', new_position)
136
148
  end
149
+
150
+ def fast_forward(seconds=15)
151
+ self.position += seconds
152
+ end
153
+
154
+ def rewind(seconds=15)
155
+ self.position -= seconds
156
+ end
137
157
 
138
158
  def duration
139
159
  video_attribute('duration')
140
160
  end
161
+
162
+ def volume
163
+ video_attribute('volume')
164
+ end
165
+
166
+ def volume=(value)
167
+ value = [value, 0].max
168
+ value = [value, 1].min
169
+ video_attribute_set('volume', value)
170
+ end
171
+
172
+ def volume_up(value=0.05)
173
+ self.volume += value
174
+ end
175
+
176
+ def volume_down(value=0.05)
177
+ self.volume -= value
178
+ end
179
+
180
+ def mute
181
+ video_attribute_set('muted', true)
182
+ end
183
+
184
+ def unmute
185
+ video_attribute_set('muted', false)
186
+ end
187
+
188
+ def muted?
189
+ video_attribute('muted')
190
+ end
191
+
192
+ def toggle_muted
193
+ muted? ? unmute : mute
194
+ end
141
195
 
142
196
  def can_handle_observation_request?(observation_request)
143
197
  result = false
@@ -162,7 +216,7 @@ module Glimmer
162
216
  end
163
217
  end
164
218
  end
165
-
219
+
166
220
  private
167
221
 
168
222
  class VideoObserverBrowserFunction < BrowserFunction
@@ -0,0 +1,6 @@
1
+ # Launches all samples
2
+ export DIR=`echo $0 | sed "s/launch//"`
3
+ glimmer \
4
+ "${DIR}hello_looped_video_with_black_background.rb" \
5
+ "${DIR}hello_video.rb" \
6
+ "${DIR}hello_video_observers.rb" \
@@ -0,0 +1,10 @@
1
+ require_relative '../../lib/glimmer-cw-video'
2
+
3
+ include Glimmer
4
+
5
+ video_file = File.expand_path('../videos/Blackpool_Timelapse.mp4', __FILE__)
6
+
7
+ shell {
8
+ minimum_size 1024, 640
9
+ video(file: video_file, looped: true, background: :black)
10
+ }.open
@@ -0,0 +1,9 @@
1
+ require_relative '../../lib/glimmer-cw-video'
2
+
3
+ include Glimmer
4
+
5
+ video_file = File.expand_path('../videos/Clouds_passing_by_CCBY_NatureClip.mp4', __FILE__)
6
+
7
+ shell {
8
+ video(file: video_file)
9
+ }.open
@@ -0,0 +1,50 @@
1
+ require_relative '../../lib/glimmer-cw-video'
2
+
3
+ include Glimmer
4
+
5
+ video_file = File.expand_path('../videos/Ants.mp4', __FILE__)
6
+
7
+ def display_video_status(video, status)
8
+ message_box {
9
+ text status
10
+ message "#{video.position.round(2)}/#{video.duration.round(2)} seconds have elapsed."
11
+ }.open
12
+ end
13
+
14
+ @shell = shell {
15
+ minimum_size 800, 500
16
+ @video = video(file: video_file, background: :black) {
17
+ on_swt_show { |event|
18
+ # set focus as soon as the SWT widget is shown to grab keyboard events below
19
+ @video.set_focus
20
+ }
21
+
22
+ on_key_pressed { |event|
23
+ case event.keyCode
24
+ when swt(:space), swt(:cr)
25
+ @video.toggle
26
+ when swt(:arrow_left)
27
+ @video.rewind
28
+ when swt(:arrow_right)
29
+ @video.fast_forward
30
+ when swt(:arrow_up)
31
+ @video.volume_up
32
+ when swt(:arrow_down)
33
+ @video.volume_down
34
+ end
35
+ }
36
+
37
+ on_playing {
38
+ display_video_status(@video, 'Playing')
39
+ }
40
+
41
+ on_paused {
42
+ display_video_status(@video, 'Paused')
43
+ }
44
+
45
+ on_ended {
46
+ display_video_status(@video, 'Ended')
47
+ }
48
+ }
49
+ }
50
+ @shell.open
metadata CHANGED
@@ -1,24 +1,24 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-cw-video
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-28 00:00:00.000000000 Z
11
+ date: 2020-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 0.4.1
18
+ version: 4.17.0.0
19
19
  - - "<"
20
20
  - !ruby/object:Gem::Version
21
- version: 2.0.0
21
+ version: 5.0.0.0
22
22
  name: glimmer-dsl-swt
23
23
  type: :runtime
24
24
  prerelease: false
@@ -26,16 +26,16 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 0.4.1
29
+ version: 4.17.0.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 2.0.0
32
+ version: 5.0.0.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  requirement: !ruby/object:Gem::Requirement
35
35
  requirements:
36
36
  - - ">="
37
37
  - !ruby/object:Gem::Version
38
- version: 0.1.0
38
+ version: 1.0.0
39
39
  - - "<"
40
40
  - !ruby/object:Gem::Version
41
41
  version: 2.0.0
@@ -46,7 +46,7 @@ dependencies:
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 0.1.0
49
+ version: 1.0.0
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
52
  version: 2.0.0
@@ -55,7 +55,7 @@ dependencies:
55
55
  requirements:
56
56
  - - ">="
57
57
  - !ruby/object:Gem::Version
58
- version: 0.1.0
58
+ version: 1.0.0
59
59
  - - "<"
60
60
  - !ruby/object:Gem::Version
61
61
  version: 2.0.0
@@ -66,7 +66,7 @@ dependencies:
66
66
  requirements:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: 0.1.0
69
+ version: 1.0.0
70
70
  - - "<"
71
71
  - !ruby/object:Gem::Version
72
72
  version: 2.0.0
@@ -98,20 +98,6 @@ dependencies:
98
98
  - - '='
99
99
  - !ruby/object:Gem::Version
100
100
  version: 2.3.9
101
- - !ruby/object:Gem::Dependency
102
- requirement: !ruby/object:Gem::Requirement
103
- requirements:
104
- - - ">="
105
- - !ruby/object:Gem::Version
106
- version: '0'
107
- name: glimmer-cs-gladiator
108
- type: :development
109
- prerelease: false
110
- version_requirements: !ruby/object:Gem::Requirement
111
- requirements:
112
- - - ">="
113
- - !ruby/object:Gem::Version
114
- version: '0'
115
101
  - !ruby/object:Gem::Dependency
116
102
  requirement: !ruby/object:Gem::Requirement
117
103
  requirements:
@@ -154,6 +140,20 @@ dependencies:
154
140
  - - "~>"
155
141
  - !ruby/object:Gem::Version
156
142
  version: 0.7.0
143
+ - !ruby/object:Gem::Dependency
144
+ requirement: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ name: glimmer-cw-video
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
157
  description: Glimmer video widget with basic functionality like play, pause, loop,
158
158
  and reload. Support mp4, webm, and ogg. Works with both local files and web URLs.
159
159
  email: andy.am@gmail.com
@@ -163,10 +163,19 @@ extra_rdoc_files:
163
163
  - LICENSE.txt
164
164
  - README.md
165
165
  files:
166
+ - CHANGELOG.md
166
167
  - LICENSE.txt
167
168
  - README.md
169
+ - VERSION
168
170
  - lib/glimmer-cw-video.rb
169
171
  - lib/views/glimmer/video.rb
172
+ - samples/launch
173
+ - samples/video/hello_looped_video_with_black_background.rb
174
+ - samples/video/hello_video.rb
175
+ - samples/video/hello_video_observers.rb
176
+ - samples/video/videos/Ants.mp4
177
+ - samples/video/videos/Blackpool_Timelapse.mp4
178
+ - samples/video/videos/Clouds_passing_by_CCBY_NatureClip.mp4
170
179
  homepage: http://github.com/AndyObtiva/glimmer-cw-video
171
180
  licenses:
172
181
  - MIT