glimmer-cw-video 0.1.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +33 -0
- data/README.md +168 -24
- data/VERSION +1 -0
- data/glimmer-cw-video.gemspec +72 -0
- data/lib/glimmer-cw-video.rb +3 -2
- data/lib/views/glimmer/video.rb +67 -11
- data/samples/launch +6 -0
- data/samples/video/hello_looped_video_with_black_background.rb +12 -0
- data/samples/video/hello_video.rb +12 -0
- data/samples/video/hello_video_observers.rb +52 -0
- data/samples/video/videos/Ants.mp4 +0 -0
- data/samples/video/videos/Blackpool_Timelapse.mp4 +0 -0
- data/samples/video/videos/Clouds_passing_by_CCBY_NatureClip.mp4 +0 -0
- metadata +137 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 655e60f1fa57d7e979736526bef4fa82bc02dd8d4a27150cf95260a8ca3c3535
|
4
|
+
data.tar.gz: a5bde3ad86d5f038ef0e8ff0203cab3f9f0a2b8e5e0c1eb01dec919024635047
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c60316f38689fbdd8a1e23f1b00c91cafedf2960b01df96347c15d71f28fc383125e2c12b9c83e4ddfeeb27779ce058e00318b3943c69dff16ea1ac73c1ae63
|
7
|
+
data.tar.gz: a6b3c6e1f83335fe0404f36ce142634a00887d5b0908a8213f4f3fd4935ed0c7d074cb03841c691c1f06248f58e30fa8a7c63ae2c2db70d80b7be6498acef1b8
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## 1.1.0
|
4
|
+
|
5
|
+
- Upgraded glimmer-dsl-swt, glimmer-dsl-xml, and glimmer-dsl-css
|
6
|
+
- Fix issue with failing to configure samples for glimmer-dsl-swt since it does not support sample configuration anymore because it became automatic
|
7
|
+
|
8
|
+
## 1.0.0
|
9
|
+
|
10
|
+
- Upgraded to Glimmer DSL for SWT 4.17.0.0
|
11
|
+
- Made samples available via the `glimmer` command (e.g. glimmer sample:run[hello_video])
|
12
|
+
- `#toggle` method for video play/pause action (plays if paused and pauses if playing)
|
13
|
+
- Handle non-absolute files
|
14
|
+
- Validate video file and raise error if invalid
|
15
|
+
- Fast-Forward & Rewind
|
16
|
+
- Volume get, set, up, and down
|
17
|
+
- mute, unmute, muted?, and toggle_muted
|
18
|
+
|
19
|
+
## 0.1.3
|
20
|
+
|
21
|
+
- Fixed an issue with hooking widget observers via symbol instead of a string
|
22
|
+
|
23
|
+
## 0.1.2
|
24
|
+
|
25
|
+
- Upgraded to the glimmer-dsl-swt 0.4.1, glimmer-dsl-xml 0.1.0, and glimmer-dsl-css 0.1.0
|
26
|
+
|
27
|
+
## 0.1.1
|
28
|
+
|
29
|
+
- Upgraded to Glimmer 0.8.0 with a relaxed version requirement
|
30
|
+
|
31
|
+
## 0.1.0
|
32
|
+
|
33
|
+
- Initial version
|
data/README.md
CHANGED
@@ -1,21 +1,35 @@
|
|
1
|
-
# Video
|
1
|
+
# Video 1.1.0
|
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
|
+
[![Gem Version](https://badge.fury.io/rb/glimmer-cw-video.svg)](http://badge.fury.io/rb/glimmer-cw-video)
|
4
|
+
[![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-cw-video.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-cw-video)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/glimmer-cw-video/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/glimmer-cw-video?branch=master)
|
6
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/b46ff4b09463b86aa7aa/maintainability)](https://codeclimate.com/github/AndyObtiva/glimmer-cw-video/maintainability)
|
7
|
+
[![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
2
8
|
|
3
9
|
![Video Widget](images/glimmer-video-widget.png)
|
4
10
|
|
5
|
-
Glimmer custom
|
11
|
+
Video is a [Glimmer Custom Widget](https://github.com/AndyObtiva/glimmer#custom-widget-gem) for playing videos via the `video` [Glimmer DSL](https://github.com/AndyObtiva/glimmer#glimmer-dsl-syntax) keyword.
|
12
|
+
|
13
|
+
## Platforms
|
14
|
+
|
15
|
+
This has been tested and confirmed to be working on:
|
16
|
+
- Mac
|
17
|
+
- Windows
|
6
18
|
|
7
19
|
## Pre-requisites
|
8
20
|
|
9
|
-
- [Glimmer](https://github.com/AndyObtiva/glimmer) application
|
21
|
+
- [Glimmer](https://github.com/AndyObtiva/glimmer) application, [Glimmer](https://github.com/AndyObtiva/glimmer) custom shell, or another [Glimmer](https://github.com/AndyObtiva/glimmer) custom widget
|
10
22
|
- JRuby version required by Glimmer
|
11
23
|
- Java version required by Glimmer
|
12
24
|
|
13
25
|
## Setup
|
14
26
|
|
27
|
+
### Glimmer Application
|
28
|
+
|
15
29
|
Add the following to a Glimmer application `Gemfile`:
|
16
30
|
|
17
31
|
```ruby
|
18
|
-
gem 'glimmer-cw-video', '
|
32
|
+
gem 'glimmer-cw-video', '1.1.0'
|
19
33
|
```
|
20
34
|
|
21
35
|
Run:
|
@@ -26,9 +40,18 @@ jruby -S bundle
|
|
26
40
|
|
27
41
|
(or just `bundle` if using RVM)
|
28
42
|
|
29
|
-
|
43
|
+
### Glimmer Custom Shell or Glimmer Custom Widget
|
44
|
+
|
45
|
+
When reusing video custom widget in a Glimmer custom shell or custom widget, you can follow the same steps for Glimmer application, and then add a require statement to your library file:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
require 'glimmer-cw-video'
|
49
|
+
# ... more require statements follow
|
50
|
+
```
|
51
|
+
|
52
|
+
## API Options
|
30
53
|
|
31
|
-
|
54
|
+
Here are the options to pass in as hash arguments to the `video` widget keyword (see in [Samples](#samples)):
|
32
55
|
- `autoplay` (true [default] or false): plays video automatically as soon as loaded
|
33
56
|
- `controls` (true [default] or false): displays controls
|
34
57
|
- `looped` (true or false [default]): plays video in looped mode
|
@@ -38,10 +61,11 @@ Passed in an options hash as arguments to `video` widget:
|
|
38
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.
|
39
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.
|
40
63
|
|
41
|
-
## Methods
|
64
|
+
## API Methods
|
42
65
|
|
43
66
|
- `#play`: plays video
|
44
67
|
- `#pause`: pauses video
|
68
|
+
- `#toggle`: toggles video playback, playing if paused, and pausing if playing.
|
45
69
|
- `#reload`: reloads video restarting from beginning
|
46
70
|
- `#position`: position in seconds (and fractions)
|
47
71
|
- `#position=`: seeks a new position in video
|
@@ -50,57 +74,148 @@ Passed in an options hash as arguments to `video` widget:
|
|
50
74
|
- `#playing?`: returns true when video is actively playing
|
51
75
|
- `#paused?`: returns true when video is not playing
|
52
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
|
53
85
|
|
54
|
-
|
86
|
+
|
87
|
+
## API Observer Events
|
88
|
+
|
89
|
+
(see in [Samples](#samples))
|
55
90
|
|
56
91
|
- `on_loaded`: invoked when video `#loaded?` becomes true
|
57
92
|
- `on_ended`: invoked when video `#ended?` becomes true
|
58
93
|
- `on_playing`: invoked when video `#playing?` becomes true
|
59
94
|
- `on_paused`: invoked when video `#paused?` becomes true
|
60
95
|
|
61
|
-
##
|
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
|
+
```
|
62
111
|
|
63
|
-
|
112
|
+
Glimmer Code (from [samples/video/hello_video.rb](samples/video/hello_video.rb)):
|
64
113
|
|
65
114
|
```ruby
|
66
|
-
|
115
|
+
require_relative '../../lib/glimmer-cw-video'
|
116
|
+
|
117
|
+
include Glimmer
|
118
|
+
|
119
|
+
video_file = File.expand_path('../videos/Clouds_passing_by_CCBY_NatureClip.mp4', __FILE__)
|
120
|
+
|
67
121
|
shell {
|
122
|
+
text 'Hello, Video!'
|
123
|
+
minimum_size 384, 240
|
124
|
+
|
68
125
|
video(file: video_file)
|
69
126
|
}.open
|
70
127
|
```
|
71
128
|
|
72
|
-
|
129
|
+
Glimmer App:
|
130
|
+
|
131
|
+
![glimmer cw video hello video](images/glimmer-cw-video-hello-video.png)
|
132
|
+
|
133
|
+
### Hello, Looped Video with Black Background!
|
134
|
+
|
135
|
+
Run:
|
136
|
+
|
137
|
+
```
|
138
|
+
glimmer sample:run[hello_looped_video_with_black_background]
|
139
|
+
```
|
140
|
+
|
141
|
+
Glimmer Code (from [samples/video/hello_looped_video_with_black_background.rb](samples/video/hello_looped_video_with_black_background.rb)):
|
73
142
|
|
74
143
|
```ruby
|
75
|
-
|
144
|
+
require_relative '../../lib/glimmer-cw-video'
|
145
|
+
|
146
|
+
include Glimmer
|
147
|
+
|
148
|
+
video_file = File.expand_path('../videos/Blackpool_Timelapse.mp4', __FILE__)
|
149
|
+
|
76
150
|
shell {
|
151
|
+
text 'Hello, Looped Video with Black Background!'
|
77
152
|
minimum_size 1024, 640
|
153
|
+
|
78
154
|
video(file: video_file, looped: true, background: :black)
|
79
155
|
}.open
|
80
156
|
```
|
81
157
|
|
82
|
-
|
158
|
+
Glimmer App:
|
159
|
+
|
160
|
+
![glimmer cw video hello video](images/glimmer-cw-video-hello-looped-video-with-black-background.png)
|
161
|
+
|
162
|
+
### Hello, Video Observers!
|
163
|
+
|
164
|
+
Run:
|
165
|
+
|
166
|
+
```
|
167
|
+
glimmer sample:run[hello_video_observers]
|
168
|
+
```
|
169
|
+
|
170
|
+
Glimmer Code (from [samples/video/hello_video_observers.rb](samples/video/hello_video_observers.rb)):
|
83
171
|
|
84
172
|
```ruby
|
85
|
-
|
173
|
+
require_relative '../../lib/glimmer-cw-video'
|
174
|
+
|
175
|
+
include Glimmer
|
176
|
+
|
177
|
+
video_file = File.expand_path('../videos/Ants.mp4', __FILE__)
|
178
|
+
|
86
179
|
def display_video_status(video, status)
|
87
|
-
message_box
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
message_box.setMessage(message)
|
92
|
-
message_box.open
|
180
|
+
message_box {
|
181
|
+
text status
|
182
|
+
message "#{video.position.round(2)}/#{video.duration.round(2)} seconds have elapsed."
|
183
|
+
}.open
|
93
184
|
end
|
94
185
|
|
95
186
|
@shell = shell {
|
187
|
+
text 'Hello, Video Observers!'
|
96
188
|
minimum_size 800, 500
|
189
|
+
|
97
190
|
@video = video(file: video_file, background: :black) {
|
191
|
+
on_swt_show { |event|
|
192
|
+
# set focus as soon as the SWT widget is shown to grab keyboard events below
|
193
|
+
@video.set_focus
|
194
|
+
}
|
195
|
+
|
196
|
+
on_key_pressed { |event|
|
197
|
+
case event.keyCode
|
198
|
+
when swt(:space), swt(:cr)
|
199
|
+
@video.toggle
|
200
|
+
when swt(:arrow_left)
|
201
|
+
@video.rewind
|
202
|
+
when swt(:arrow_right)
|
203
|
+
@video.fast_forward
|
204
|
+
when swt(:arrow_up)
|
205
|
+
@video.volume_up
|
206
|
+
when swt(:arrow_down)
|
207
|
+
@video.volume_down
|
208
|
+
end
|
209
|
+
}
|
210
|
+
|
98
211
|
on_playing {
|
99
212
|
display_video_status(@video, 'Playing')
|
100
213
|
}
|
214
|
+
|
101
215
|
on_paused {
|
102
216
|
display_video_status(@video, 'Paused')
|
103
217
|
}
|
218
|
+
|
104
219
|
on_ended {
|
105
220
|
display_video_status(@video, 'Ended')
|
106
221
|
}
|
@@ -109,6 +224,30 @@ end
|
|
109
224
|
@shell.open
|
110
225
|
```
|
111
226
|
|
227
|
+
Glimmer App:
|
228
|
+
|
229
|
+
![glimmer cw video hello video observers](images/glimmer-cw-video-hello-video-observers.png)
|
230
|
+
|
231
|
+
Dialog for video playing event:
|
232
|
+
|
233
|
+
![glimmer cw video hello video observers](images/glimmer-cw-video-hello-video-observers-playing-event.png)
|
234
|
+
|
235
|
+
Dialog for video paused event:
|
236
|
+
|
237
|
+
![glimmer cw video hello video observers](images/glimmer-cw-video-hello-video-observers-paused-event.png)
|
238
|
+
|
239
|
+
Dialog for video ended event:
|
240
|
+
|
241
|
+
![glimmer cw video hello video observers](images/glimmer-cw-video-hello-video-observers-ended-event.png)
|
242
|
+
|
243
|
+
## TODO
|
244
|
+
|
245
|
+
[TODO.md](TODO.md)
|
246
|
+
|
247
|
+
## Change Log
|
248
|
+
|
249
|
+
[CHANGELOG.md](CHANGELOG.md)
|
250
|
+
|
112
251
|
## Contributing to glimmer-cw-video
|
113
252
|
|
114
253
|
- Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
@@ -119,7 +258,12 @@ end
|
|
119
258
|
- Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
120
259
|
- Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
121
260
|
|
122
|
-
##
|
261
|
+
## License
|
262
|
+
|
263
|
+
[MIT](LICENSE.txt)
|
264
|
+
|
265
|
+
Copyright (c) 2020 - Andy Maleh.
|
266
|
+
|
267
|
+
--
|
123
268
|
|
124
|
-
|
125
|
-
further details.
|
269
|
+
[<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=40 />](https://github.com/AndyObtiva/glimmer) Built for [Glimmer](https://github.com/AndyObtiva/glimmer) (Ruby Desktop Development GUI Library).
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.1.0
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# Generated by juwelier
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: glimmer-cw-video 1.1.0 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "glimmer-cw-video".freeze
|
9
|
+
s.version = "1.1.0"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib".freeze]
|
13
|
+
s.authors = ["Andy Maleh".freeze]
|
14
|
+
s.date = "2020-10-22"
|
15
|
+
s.description = "Glimmer video widget with basic functionality like play, pause, loop, and reload. Support mp4, webm, and ogg. Works with both local files and web URLs.".freeze
|
16
|
+
s.email = "andy.am@gmail.com".freeze
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.md"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
"CHANGELOG.md",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.md",
|
25
|
+
"VERSION",
|
26
|
+
"glimmer-cw-video.gemspec",
|
27
|
+
"lib/glimmer-cw-video.rb",
|
28
|
+
"lib/views/glimmer/video.rb",
|
29
|
+
"samples/launch",
|
30
|
+
"samples/video/hello_looped_video_with_black_background.rb",
|
31
|
+
"samples/video/hello_video.rb",
|
32
|
+
"samples/video/hello_video_observers.rb",
|
33
|
+
"samples/video/videos/Ants.mp4",
|
34
|
+
"samples/video/videos/Blackpool_Timelapse.mp4",
|
35
|
+
"samples/video/videos/Clouds_passing_by_CCBY_NatureClip.mp4"
|
36
|
+
]
|
37
|
+
s.homepage = "http://github.com/AndyObtiva/glimmer-cw-video".freeze
|
38
|
+
s.licenses = ["MIT".freeze]
|
39
|
+
s.rubygems_version = "3.1.4".freeze
|
40
|
+
s.summary = "Glimmer Custom Widget - Video".freeze
|
41
|
+
|
42
|
+
if s.respond_to? :specification_version then
|
43
|
+
s.specification_version = 4
|
44
|
+
end
|
45
|
+
|
46
|
+
if s.respond_to? :add_runtime_dependency then
|
47
|
+
s.add_runtime_dependency(%q<glimmer-dsl-swt>.freeze, [">= 4.17.4.1", "< 5.0.0.0"])
|
48
|
+
s.add_runtime_dependency(%q<glimmer-dsl-xml>.freeze, [">= 1.1.0", "< 2.0.0"])
|
49
|
+
s.add_runtime_dependency(%q<glimmer-dsl-css>.freeze, [">= 1.1.0", "< 2.0.0"])
|
50
|
+
s.add_development_dependency(%q<juwelier>.freeze, ["~> 2.4.9"])
|
51
|
+
s.add_development_dependency(%q<glimmer-cs-gladiator>.freeze, [">= 0"])
|
52
|
+
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
53
|
+
s.add_development_dependency(%q<jeweler>.freeze, ["= 2.3.9"])
|
54
|
+
s.add_development_dependency(%q<coveralls>.freeze, ["= 0.8.23"])
|
55
|
+
s.add_development_dependency(%q<simplecov>.freeze, ["~> 0.16.1"])
|
56
|
+
s.add_development_dependency(%q<simplecov-lcov>.freeze, ["~> 0.7.0"])
|
57
|
+
s.add_development_dependency(%q<glimmer-cw-video>.freeze, [">= 0"])
|
58
|
+
else
|
59
|
+
s.add_dependency(%q<glimmer-dsl-swt>.freeze, [">= 4.17.4.1", "< 5.0.0.0"])
|
60
|
+
s.add_dependency(%q<glimmer-dsl-xml>.freeze, [">= 1.1.0", "< 2.0.0"])
|
61
|
+
s.add_dependency(%q<glimmer-dsl-css>.freeze, [">= 1.1.0", "< 2.0.0"])
|
62
|
+
s.add_dependency(%q<juwelier>.freeze, ["~> 2.4.9"])
|
63
|
+
s.add_dependency(%q<glimmer-cs-gladiator>.freeze, [">= 0"])
|
64
|
+
s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
65
|
+
s.add_dependency(%q<jeweler>.freeze, ["= 2.3.9"])
|
66
|
+
s.add_dependency(%q<coveralls>.freeze, ["= 0.8.23"])
|
67
|
+
s.add_dependency(%q<simplecov>.freeze, ["~> 0.16.1"])
|
68
|
+
s.add_dependency(%q<simplecov-lcov>.freeze, ["~> 0.7.0"])
|
69
|
+
s.add_dependency(%q<glimmer-cw-video>.freeze, [">= 0"])
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
data/lib/glimmer-cw-video.rb
CHANGED
data/lib/views/glimmer/video.rb
CHANGED
@@ -6,21 +6,26 @@ module Glimmer
|
|
6
6
|
include_package 'org.eclipse.swt.browser'
|
7
7
|
|
8
8
|
options :file, :url
|
9
|
-
option :autoplay, true
|
10
|
-
option :controls, true
|
11
|
-
option :looped, false
|
12
|
-
option :background, :white
|
13
|
-
option :fit_to_width, true
|
14
|
-
option :fit_to_height, true
|
15
|
-
option :offset_x, 0
|
16
|
-
option :offset_y, 0
|
9
|
+
option :autoplay, default: true
|
10
|
+
option :controls, default: true
|
11
|
+
option :looped, default: false
|
12
|
+
option :background, default: :white
|
13
|
+
option :fit_to_width, default: true
|
14
|
+
option :fit_to_height, default: true
|
15
|
+
option :offset_x, default: 0
|
16
|
+
option :offset_y, default: 0
|
17
17
|
|
18
18
|
alias autoplay? autoplay
|
19
19
|
alias controls? controls
|
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,15 +142,60 @@ 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
|
198
|
+
observation_request = observation_request.to_s
|
144
199
|
if observation_request.start_with?('on_')
|
145
200
|
attribute = observation_request.sub(/^on_/, '')
|
146
201
|
result = OBSERVED_ATTRIBUTE_TO_PROPERTY_MAPPING.keys.include?(attribute)
|
@@ -149,6 +204,7 @@ module Glimmer
|
|
149
204
|
end
|
150
205
|
|
151
206
|
def handle_observation_request(observation_request, &block)
|
207
|
+
observation_request = observation_request.to_s
|
152
208
|
if observation_request.start_with?('on_')
|
153
209
|
attribute = observation_request.sub(/^on_/, '')
|
154
210
|
if attribute == 'loaded' && !@completed
|
@@ -160,7 +216,7 @@ module Glimmer
|
|
160
216
|
end
|
161
217
|
end
|
162
218
|
end
|
163
|
-
|
219
|
+
|
164
220
|
private
|
165
221
|
|
166
222
|
class VideoObserverBrowserFunction < BrowserFunction
|
data/samples/launch
ADDED
@@ -0,0 +1,12 @@
|
|
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
|
+
text 'Hello, Looped Video with Black Background!'
|
9
|
+
minimum_size 1024, 640
|
10
|
+
|
11
|
+
video(file: video_file, looped: true, background: :black)
|
12
|
+
}.open
|
@@ -0,0 +1,12 @@
|
|
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
|
+
text 'Hello, Video!'
|
9
|
+
minimum_size 384, 240
|
10
|
+
|
11
|
+
video(file: video_file)
|
12
|
+
}.open
|
@@ -0,0 +1,52 @@
|
|
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
|
+
text 'Hello, Video Observers!'
|
16
|
+
minimum_size 800, 500
|
17
|
+
|
18
|
+
@video = video(file: video_file, background: :black) {
|
19
|
+
on_swt_show { |event|
|
20
|
+
# set focus as soon as the SWT widget is shown to grab keyboard events below
|
21
|
+
@video.set_focus
|
22
|
+
}
|
23
|
+
|
24
|
+
on_key_pressed { |event|
|
25
|
+
case event.keyCode
|
26
|
+
when swt(:space), swt(:cr)
|
27
|
+
@video.toggle
|
28
|
+
when swt(:arrow_left)
|
29
|
+
@video.rewind
|
30
|
+
when swt(:arrow_right)
|
31
|
+
@video.fast_forward
|
32
|
+
when swt(:arrow_up)
|
33
|
+
@video.volume_up
|
34
|
+
when swt(:arrow_down)
|
35
|
+
@video.volume_down
|
36
|
+
end
|
37
|
+
}
|
38
|
+
|
39
|
+
on_playing {
|
40
|
+
display_video_status(@video, 'Playing')
|
41
|
+
}
|
42
|
+
|
43
|
+
on_paused {
|
44
|
+
display_video_status(@video, 'Paused')
|
45
|
+
}
|
46
|
+
|
47
|
+
on_ended {
|
48
|
+
display_video_status(@video, 'Ended')
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
@shell.open
|
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,29 +1,103 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-cw-video
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.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-
|
11
|
+
date: 2020-10-22 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:
|
19
|
-
|
18
|
+
version: 4.17.4.1
|
19
|
+
- - "<"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 5.0.0.0
|
22
|
+
name: glimmer-dsl-swt
|
23
|
+
prerelease: false
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 4.17.4.1
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 5.0.0.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 1.1.0
|
39
|
+
- - "<"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 2.0.0
|
42
|
+
name: glimmer-dsl-xml
|
43
|
+
prerelease: false
|
44
|
+
type: :runtime
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 1.1.0
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 2.0.0
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: 1.1.0
|
59
|
+
- - "<"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.0.0
|
62
|
+
name: glimmer-dsl-css
|
63
|
+
prerelease: false
|
20
64
|
type: :runtime
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.1.0
|
70
|
+
- - "<"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 2.0.0
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
requirement: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - "~>"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 2.4.9
|
79
|
+
name: juwelier
|
21
80
|
prerelease: false
|
81
|
+
type: :development
|
22
82
|
version_requirements: !ruby/object:Gem::Requirement
|
23
83
|
requirements:
|
24
84
|
- - "~>"
|
25
85
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
86
|
+
version: 2.4.9
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
requirement: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
name: glimmer-cs-gladiator
|
94
|
+
prerelease: false
|
95
|
+
type: :development
|
96
|
+
version_requirements: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
27
101
|
- !ruby/object:Gem::Dependency
|
28
102
|
requirement: !ruby/object:Gem::Requirement
|
29
103
|
requirements:
|
@@ -31,8 +105,8 @@ dependencies:
|
|
31
105
|
- !ruby/object:Gem::Version
|
32
106
|
version: 3.5.0
|
33
107
|
name: rspec
|
34
|
-
type: :development
|
35
108
|
prerelease: false
|
109
|
+
type: :development
|
36
110
|
version_requirements: !ruby/object:Gem::Requirement
|
37
111
|
requirements:
|
38
112
|
- - "~>"
|
@@ -45,8 +119,8 @@ dependencies:
|
|
45
119
|
- !ruby/object:Gem::Version
|
46
120
|
version: 2.3.9
|
47
121
|
name: jeweler
|
48
|
-
type: :development
|
49
122
|
prerelease: false
|
123
|
+
type: :development
|
50
124
|
version_requirements: !ruby/object:Gem::Requirement
|
51
125
|
requirements:
|
52
126
|
- - '='
|
@@ -55,12 +129,54 @@ dependencies:
|
|
55
129
|
- !ruby/object:Gem::Dependency
|
56
130
|
requirement: !ruby/object:Gem::Requirement
|
57
131
|
requirements:
|
58
|
-
- -
|
132
|
+
- - '='
|
59
133
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
134
|
+
version: 0.8.23
|
135
|
+
name: coveralls
|
136
|
+
prerelease: false
|
137
|
+
type: :development
|
138
|
+
version_requirements: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - '='
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: 0.8.23
|
143
|
+
- !ruby/object:Gem::Dependency
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - "~>"
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: 0.16.1
|
61
149
|
name: simplecov
|
150
|
+
prerelease: false
|
62
151
|
type: :development
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - "~>"
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: 0.16.1
|
157
|
+
- !ruby/object:Gem::Dependency
|
158
|
+
requirement: !ruby/object:Gem::Requirement
|
159
|
+
requirements:
|
160
|
+
- - "~>"
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: 0.7.0
|
163
|
+
name: simplecov-lcov
|
164
|
+
prerelease: false
|
165
|
+
type: :development
|
166
|
+
version_requirements: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - "~>"
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: 0.7.0
|
171
|
+
- !ruby/object:Gem::Dependency
|
172
|
+
requirement: !ruby/object:Gem::Requirement
|
173
|
+
requirements:
|
174
|
+
- - ">="
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
version: '0'
|
177
|
+
name: glimmer-cw-video
|
63
178
|
prerelease: false
|
179
|
+
type: :development
|
64
180
|
version_requirements: !ruby/object:Gem::Requirement
|
65
181
|
requirements:
|
66
182
|
- - ">="
|
@@ -75,10 +191,20 @@ extra_rdoc_files:
|
|
75
191
|
- LICENSE.txt
|
76
192
|
- README.md
|
77
193
|
files:
|
194
|
+
- CHANGELOG.md
|
78
195
|
- LICENSE.txt
|
79
196
|
- README.md
|
197
|
+
- VERSION
|
198
|
+
- glimmer-cw-video.gemspec
|
80
199
|
- lib/glimmer-cw-video.rb
|
81
200
|
- lib/views/glimmer/video.rb
|
201
|
+
- samples/launch
|
202
|
+
- samples/video/hello_looped_video_with_black_background.rb
|
203
|
+
- samples/video/hello_video.rb
|
204
|
+
- samples/video/hello_video_observers.rb
|
205
|
+
- samples/video/videos/Ants.mp4
|
206
|
+
- samples/video/videos/Blackpool_Timelapse.mp4
|
207
|
+
- samples/video/videos/Clouds_passing_by_CCBY_NatureClip.mp4
|
82
208
|
homepage: http://github.com/AndyObtiva/glimmer-cw-video
|
83
209
|
licenses:
|
84
210
|
- MIT
|
@@ -98,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
224
|
- !ruby/object:Gem::Version
|
99
225
|
version: '0'
|
100
226
|
requirements: []
|
101
|
-
rubygems_version: 3.
|
227
|
+
rubygems_version: 3.1.4
|
102
228
|
signing_key:
|
103
229
|
specification_version: 4
|
104
230
|
summary: Glimmer Custom Widget - Video
|