quicktime-player-mac 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +13 -0
- data/README.rdoc +56 -0
- data/Rakefile +25 -0
- data/lib/quicktime-player-mac.rb +10 -0
- data/lib/quicktime-player-mac/quicktime.rb +101 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/mac-quicktime-player_spec.rb +11 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- data/tasks/rspec.rake +21 -0
- metadata +127 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.rdoc
|
4
|
+
Rakefile
|
5
|
+
lib/quicktime-player-mac.rb
|
6
|
+
lib/quicktime-player-mac/quicktime.rb
|
7
|
+
script/console
|
8
|
+
script/destroy
|
9
|
+
script/generate
|
10
|
+
spec/mac-quicktime-player_spec.rb
|
11
|
+
spec/spec.opts
|
12
|
+
spec/spec_helper.rb
|
13
|
+
tasks/rspec.rake
|
data/README.rdoc
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
= quicktime-player-mac
|
2
|
+
|
3
|
+
* http://github.com/shokai/quicktime-player-mac
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
control QuickTime Player on Mac.
|
8
|
+
|
9
|
+
|
10
|
+
== SYNOPSIS:
|
11
|
+
|
12
|
+
require 'rubygems'
|
13
|
+
require 'quicktime-player-mac'
|
14
|
+
q = QuickTime.new
|
15
|
+
q.play unless q.playing?
|
16
|
+
q.speed = 13.5
|
17
|
+
loop do
|
18
|
+
if q.current_time > 60
|
19
|
+
q.speed = 1
|
20
|
+
q.current_time = 10
|
21
|
+
break
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
== REQUIREMENTS:
|
26
|
+
|
27
|
+
* applescript (rubygems)
|
28
|
+
|
29
|
+
== INSTALL:
|
30
|
+
|
31
|
+
* gem install quicktime-player-mac
|
32
|
+
|
33
|
+
== LICENSE:
|
34
|
+
|
35
|
+
(The MIT License)
|
36
|
+
|
37
|
+
Copyright (c) 2010 Sho Hashimoto
|
38
|
+
|
39
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
40
|
+
a copy of this software and associated documentation files (the
|
41
|
+
'Software'), to deal in the Software without restriction, including
|
42
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
43
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
44
|
+
permit persons to whom the Software is furnished to do so, subject to
|
45
|
+
the following conditions:
|
46
|
+
|
47
|
+
The above copyright notice and this permission notice shall be
|
48
|
+
included in all copies or substantial portions of the Software.
|
49
|
+
|
50
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
51
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
52
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
53
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
54
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
55
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
56
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'hoe', '>= 2.1.0'
|
3
|
+
require 'hoe'
|
4
|
+
require 'fileutils'
|
5
|
+
require './lib/quicktime-player-mac'
|
6
|
+
|
7
|
+
Hoe.plugin :newgem
|
8
|
+
# Hoe.plugin :website
|
9
|
+
# Hoe.plugin :cucumberfeatures
|
10
|
+
|
11
|
+
# Generate all the Rake tasks
|
12
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
13
|
+
$hoe = Hoe.spec 'quicktime-player-mac' do
|
14
|
+
self.developer 'Sho Hashimoto', 'hashimoto@shokai.org'
|
15
|
+
self.rubyforge_name = self.name # TODO this is default value
|
16
|
+
self.extra_deps = [['applescript']]
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'newgem/tasks'
|
21
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
22
|
+
|
23
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
24
|
+
# remove_task :default
|
25
|
+
# task :default => [:spec, :features]
|
@@ -0,0 +1,10 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
4
|
+
Dir.glob(File.dirname(__FILE__)+'/quicktime-player-mac/*.rb').each{|lib|
|
5
|
+
require lib
|
6
|
+
}
|
7
|
+
|
8
|
+
module QuicktimePlayerMac
|
9
|
+
VERSION = '0.0.1'
|
10
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'applescript'
|
3
|
+
|
4
|
+
class QuickTime
|
5
|
+
|
6
|
+
class Error < Exception
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_accessor :movie_index
|
10
|
+
|
11
|
+
def initialize(movie_index=1)
|
12
|
+
@movie_index = movie_index
|
13
|
+
end
|
14
|
+
|
15
|
+
def speed=(speed)
|
16
|
+
raise ArgumentError.new('speed should be Number') if speed.class != Fixnum and speed.class != Float
|
17
|
+
@speed = speed
|
18
|
+
script =
|
19
|
+
"tell application 'QuickTime Player'
|
20
|
+
set preferred rate of document 1 to #{speed}
|
21
|
+
tell movie #{@movie_index}
|
22
|
+
if playing then
|
23
|
+
play
|
24
|
+
end if
|
25
|
+
end tell
|
26
|
+
end tell".gsub(/'/,'"')
|
27
|
+
AppleScript.execute(script)
|
28
|
+
end
|
29
|
+
|
30
|
+
def speed
|
31
|
+
script =
|
32
|
+
"tell application 'QuickTime Player'
|
33
|
+
get preferred rate of document 1
|
34
|
+
end tell".gsub(/'/,'"')
|
35
|
+
AppleScript.execute(script).to_f
|
36
|
+
end
|
37
|
+
|
38
|
+
def stop
|
39
|
+
script =
|
40
|
+
"tell application 'QuickTime Player'
|
41
|
+
tell movie #{@movie_index}
|
42
|
+
stop
|
43
|
+
end tell
|
44
|
+
end tell".gsub(/'/,'"')
|
45
|
+
AppleScript.execute(script)
|
46
|
+
end
|
47
|
+
|
48
|
+
def play
|
49
|
+
script =
|
50
|
+
"tell application 'QuickTime Player'
|
51
|
+
tell movie #{@movie_index}
|
52
|
+
play
|
53
|
+
end tell
|
54
|
+
end tell".gsub(/'/,'"')
|
55
|
+
AppleScript.execute(script)
|
56
|
+
end
|
57
|
+
|
58
|
+
def playing?
|
59
|
+
script =
|
60
|
+
"tell application 'QuickTime Player'
|
61
|
+
tell movie #{@movie_index}
|
62
|
+
playing
|
63
|
+
end tell
|
64
|
+
end tell".gsub(/'/,'"')
|
65
|
+
res = AppleScript.execute(script)
|
66
|
+
return true if res =~ /^true/
|
67
|
+
return false if res =~ /^false/
|
68
|
+
raise Error.new("couldn't get playing status")
|
69
|
+
end
|
70
|
+
|
71
|
+
def current_time
|
72
|
+
script =
|
73
|
+
"tell application 'QuickTime Player'
|
74
|
+
tell movie #{@movie_index}
|
75
|
+
get current time
|
76
|
+
end tell
|
77
|
+
end tell".gsub(/'/,'"')
|
78
|
+
res = AppleScript.execute(script)
|
79
|
+
res.to_f/600
|
80
|
+
end
|
81
|
+
|
82
|
+
def current_time=(sec)
|
83
|
+
sec = sec*600
|
84
|
+
script =
|
85
|
+
"tell application 'QuickTime Player'
|
86
|
+
tell movie #{@movie_index}
|
87
|
+
set current time to #{sec}
|
88
|
+
end tell
|
89
|
+
end tell".gsub(/'/, '"')
|
90
|
+
res = AppleScript.execute(script)
|
91
|
+
end
|
92
|
+
|
93
|
+
def movies
|
94
|
+
script =
|
95
|
+
"tell application 'QuickTime Player'
|
96
|
+
get documents
|
97
|
+
end tell".gsub(/'/,'"')
|
98
|
+
res = AppleScript.execute(script)
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/mac-quicktime-player.rb'}"
|
9
|
+
puts "Loading mac-quicktime-player gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/spec/spec_helper.rb
ADDED
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
5
|
+
require 'spec'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
rescue LoadError
|
10
|
+
puts <<-EOS
|
11
|
+
To use rspec for testing you must install rspec gem:
|
12
|
+
gem install rspec
|
13
|
+
EOS
|
14
|
+
exit(0)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run the specs under spec/models"
|
18
|
+
Spec::Rake::SpecTask.new do |t|
|
19
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: quicktime-player-mac
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Sho Hashimoto
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-10-09 00:00:00 +09:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: applescript
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rubyforge
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 7
|
44
|
+
segments:
|
45
|
+
- 2
|
46
|
+
- 0
|
47
|
+
- 4
|
48
|
+
version: 2.0.4
|
49
|
+
type: :development
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: hoe
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 21
|
60
|
+
segments:
|
61
|
+
- 2
|
62
|
+
- 6
|
63
|
+
- 1
|
64
|
+
version: 2.6.1
|
65
|
+
type: :development
|
66
|
+
version_requirements: *id003
|
67
|
+
description: control QuickTime Player on Mac.
|
68
|
+
email:
|
69
|
+
- hashimoto@shokai.org
|
70
|
+
executables: []
|
71
|
+
|
72
|
+
extensions: []
|
73
|
+
|
74
|
+
extra_rdoc_files:
|
75
|
+
- History.txt
|
76
|
+
- Manifest.txt
|
77
|
+
files:
|
78
|
+
- History.txt
|
79
|
+
- Manifest.txt
|
80
|
+
- README.rdoc
|
81
|
+
- Rakefile
|
82
|
+
- lib/quicktime-player-mac.rb
|
83
|
+
- lib/quicktime-player-mac/quicktime.rb
|
84
|
+
- script/console
|
85
|
+
- script/destroy
|
86
|
+
- script/generate
|
87
|
+
- spec/mac-quicktime-player_spec.rb
|
88
|
+
- spec/spec.opts
|
89
|
+
- spec/spec_helper.rb
|
90
|
+
- tasks/rspec.rake
|
91
|
+
has_rdoc: true
|
92
|
+
homepage: http://github.com/shokai/quicktime-player-mac
|
93
|
+
licenses: []
|
94
|
+
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options:
|
97
|
+
- --main
|
98
|
+
- README.rdoc
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
hash: 3
|
107
|
+
segments:
|
108
|
+
- 0
|
109
|
+
version: "0"
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
hash: 3
|
116
|
+
segments:
|
117
|
+
- 0
|
118
|
+
version: "0"
|
119
|
+
requirements: []
|
120
|
+
|
121
|
+
rubyforge_project: quicktime-player-mac
|
122
|
+
rubygems_version: 1.3.7
|
123
|
+
signing_key:
|
124
|
+
specification_version: 3
|
125
|
+
summary: control QuickTime Player on Mac.
|
126
|
+
test_files: []
|
127
|
+
|