bitmovin-player-rails 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +45 -0
- data/Rakefile +34 -0
- data/lib/bitmovin/player/rails.rb +9 -0
- data/lib/bitmovin/player/rails/engine.rb +8 -0
- data/lib/bitmovin/player/rails/helper.rb +45 -0
- data/lib/bitmovin/player/rails/version.rb +7 -0
- data/lib/generators/bitmovin_player/INSTRUCTIONS +9 -0
- data/lib/generators/bitmovin_player/README +8 -0
- data/lib/generators/bitmovin_player/bitmovin_player_generator.rb +65 -0
- data/lib/generators/bitmovin_player/templates/config.yml.erb +11 -0
- data/lib/tasks/bitmovin/player/rails_tasks.rake +4 -0
- metadata +104 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7101ee068ef2b87c6f1be799b09c5b2ed7bcf046
|
4
|
+
data.tar.gz: e1dd5c81c080ce4eb6f8ac4c4427ad2245152ce7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 34d596c85d6780e14e9e5dbf276d3223dae087f33cc546163f3e0076ac8766143940374b6312d3a20f2c47dc2b23e124795991ee9639fa7c7c3f37c4c591994e
|
7
|
+
data.tar.gz: 31fe80d0d5ec4bcb5c7281c2abd7ae23e1913ce650c944dce9f5ef003111d003530c89fb860cd5e5e114fee1ce00514dea7fcdff5f8e42d16a2009a4ff5ff561
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2016
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Bitmovin-Player Rails
|
2
|
+
Adaptive HTML5 Video Player for Rails
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
After installation you can embed a Bitmovin-Player anywhere in your views as simple as this:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
<%= bitmovin_player(
|
9
|
+
width: '800px', height: '450px',
|
10
|
+
dash: "//bitmovin-a.akamaihd.net/content/MI201109210084_1/mpds/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.mpd"
|
11
|
+
hls: "//bitmovin-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8"
|
12
|
+
progressive: "//bitmovin-a.akamaihd.net/content/MI201109210084_1/MI201109210084_mpeg-4_hd_high_1080p25_10mbits.mp4"
|
13
|
+
poster: "//bitmovin-a.akamaihd.net/content/MI201109210084_1/poster.jpg") %>
|
14
|
+
```
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
Add this line to your application's Gemfile:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
gem 'bitmovin-player-rails'
|
21
|
+
```
|
22
|
+
|
23
|
+
And then execute:
|
24
|
+
```bash
|
25
|
+
$ bundle
|
26
|
+
```
|
27
|
+
|
28
|
+
Now run the generator and follow the instructions
|
29
|
+
```bash
|
30
|
+
$ rails generate bitmovin_player
|
31
|
+
```
|
32
|
+
|
33
|
+
## Configuration
|
34
|
+
|
35
|
+
Bitmovin-Player-Rails supports all settings Bitmovin-Player supports.
|
36
|
+
Please look at the [documentation](https://bitmovin.com/player-documentation/) and just translate the JavaScript config to Ruby hashes and you are good to go.
|
37
|
+
|
38
|
+
## Need Help?
|
39
|
+
If you find a bug or need some help don't hesitate to raise an Issue here on GitHub or [contact us](https://bitmovin.com/contact/)
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
Feel free to send us pull requests or suggestions!
|
43
|
+
|
44
|
+
## License
|
45
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Bitmovin::Player::Rails'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
require 'bundler/gem_tasks'
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'lib'
|
28
|
+
t.libs << 'test'
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
30
|
+
t.verbose = false
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
task default: :test
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Bitmovin::Player::Rails
|
2
|
+
module Helper
|
3
|
+
def bitmovin_player_script
|
4
|
+
javascript_include_tag Rails.configuration.bitmovin_player["cdn_url"]
|
5
|
+
end
|
6
|
+
|
7
|
+
def bitmovin_player(options={})
|
8
|
+
container = options.delete(:container) || "bitmovin-#{SecureRandom.hex[0...5]}"
|
9
|
+
width = options.delete(:width)
|
10
|
+
height = options.delete(:height)
|
11
|
+
options[:style] = options[:style] || {}
|
12
|
+
options[:style][:width] = width unless width.nil?
|
13
|
+
options[:style][:height] = height unless height.nil?
|
14
|
+
|
15
|
+
|
16
|
+
options[:source] = options[:source] || {}
|
17
|
+
options[:source][:dash] = options[:source][:dash] || options.delete(:dash) if (options[:source][:dash] || options[:dash])
|
18
|
+
options[:source][:hls] = options[:source][:hls] || options.delete(:hls) if (options[:source][:hls] || options[:hls])
|
19
|
+
options[:source][:progressive] = options[:source][:progressive] || options.delete(:progressive) if (options[:source][:progressive] || options[:progressive])
|
20
|
+
options[:source][:poster] = options[:source][:poster] || options.delete(:poster) if (options[:source][:poster] || options[:poster])
|
21
|
+
|
22
|
+
version = Rails.configuration.bitmovin_player["version"]
|
23
|
+
setup = "bitmovin.player"
|
24
|
+
setup = "bitdash" if version.include?("5")
|
25
|
+
|
26
|
+
options[:key] = Rails.configuration.bitmovin_player["license_key"]
|
27
|
+
|
28
|
+
result = <<-EOS
|
29
|
+
<div id="#{container}"></div>
|
30
|
+
<script type="text/javascript">
|
31
|
+
var conf = #{JSON.pretty_generate(options)};
|
32
|
+
var player = #{setup}("#{container}");
|
33
|
+
player.setup(conf).then(function(value) {
|
34
|
+
// Success
|
35
|
+
console.log("Successfully created bitmovin player instance");
|
36
|
+
}, function(reason) {
|
37
|
+
// Error!
|
38
|
+
console.log("Error while creating bitmovin player instance");
|
39
|
+
});
|
40
|
+
</script>
|
41
|
+
EOS
|
42
|
+
result.html_safe
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
You can now use bitmovin-player in any of your Rails templates as a view helper:
|
2
|
+
|
3
|
+
Example:
|
4
|
+
|
5
|
+
<%= bitmovin_player(
|
6
|
+
dash: "//bitmovin-a.akamaihd.net/content/MI201109210084_1/mpds/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.mpd"
|
7
|
+
hls: "//bitmovin-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8"
|
8
|
+
progressive: "//bitmovin-a.akamaihd.net/content/MI201109210084_1/MI201109210084_mpeg-4_hd_high_1080p25_10mbits.mp4"
|
9
|
+
poster: "//bitmovin-a.akamaihd.net/content/MI201109210084_1/poster.jpg") %>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
Welcome to Bitmovin-Player!
|
2
|
+
An intelligent and intuitive Adaptive HTML5 Video Player.
|
3
|
+
|
4
|
+
To use the player you need to register for a FREE License Key
|
5
|
+
on the Bitmovin website. Please visit:
|
6
|
+
https://bitmovin.com/signup/
|
7
|
+
|
8
|
+
Now please go to Settings->Api and Copy your API key.
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'rails/generators/named_base'
|
3
|
+
require 'rails/generators/base'
|
4
|
+
|
5
|
+
class BitmovinPlayerGenerator < Rails::Generators::Base
|
6
|
+
|
7
|
+
source_root File.expand_path('../templates', __FILE__)
|
8
|
+
@api_key
|
9
|
+
|
10
|
+
def install
|
11
|
+
readme File.expand_path('.././README', __FILE__)
|
12
|
+
@api_key = ask('Please enter your Bitmovin-Api-Key:')
|
13
|
+
|
14
|
+
default_versions = fetch_player_versions
|
15
|
+
|
16
|
+
puts "Available Player versions:"
|
17
|
+
default_versions.each_with_index do |version, index|
|
18
|
+
puts "#{index + 1}) [#{version["category"]}] #{version["version"]}"
|
19
|
+
end
|
20
|
+
default = default_versions.last
|
21
|
+
|
22
|
+
player_index = ask("What player version do you want to install? (#{default_versions.length}):")
|
23
|
+
player_index = default_versions.length if (player_index.blank?)
|
24
|
+
selected_version = default_versions[player_index.to_i - 1]
|
25
|
+
|
26
|
+
puts "Installing Player `#{selected_version["version"]}`"
|
27
|
+
|
28
|
+
@cdn_url = selected_version["cdnUrl"]
|
29
|
+
@license_key = get_license_key
|
30
|
+
@version = selected_version["version"]
|
31
|
+
template "config.yml.erb", "config/bitmovin_player.yml"
|
32
|
+
application "config.bitmovin_player = config_for(:bitmovin_player)"
|
33
|
+
|
34
|
+
inject_into_file 'app/views/layouts/application.html.erb', :after => 'javascript_include_tag' do
|
35
|
+
"<%= bitmovin_player_script %>"
|
36
|
+
end
|
37
|
+
|
38
|
+
puts "Installation successful!"
|
39
|
+
readme File.expand_path('.././INSTRUCTIONS', __FILE__)
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
def fetch_player_versions
|
44
|
+
headers = { "bitcodin-api-key" => @api_key }
|
45
|
+
response = HTTParty.get('https://app.bitmovin.com/api/player-versions', headers: headers)
|
46
|
+
check_api_response!(response)
|
47
|
+
player_versions = JSON.parse(response.body)
|
48
|
+
|
49
|
+
default_versions = player_versions.select { |version| version["isDefault"] == true }
|
50
|
+
end
|
51
|
+
|
52
|
+
def check_api_response!(response)
|
53
|
+
if (response.code == 401)
|
54
|
+
abort("Unrecognized API-Key - please try again")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def get_license_key
|
59
|
+
headers = { "bitcodin-api-key" => @api_key }
|
60
|
+
response = HTTParty.get('https://app.bitmovin.com/api/bitdash-licensing', headers: headers)
|
61
|
+
check_api_response!(response)
|
62
|
+
body = JSON.parse(response.body)
|
63
|
+
body["licenseKey"]
|
64
|
+
end
|
65
|
+
end
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bitmovin-player-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Hoelbling-Inzko
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-11-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.0.0
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 5.0.0.1
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 5.0.0
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 5.0.0.1
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: httparty
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: sqlite3
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
description: Quickly embed Bitmovin-Player in your Rails app
|
62
|
+
email:
|
63
|
+
- daniel.hoelbling-inzko@bitmovin.com
|
64
|
+
executables: []
|
65
|
+
extensions: []
|
66
|
+
extra_rdoc_files: []
|
67
|
+
files:
|
68
|
+
- MIT-LICENSE
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- lib/bitmovin/player/rails.rb
|
72
|
+
- lib/bitmovin/player/rails/engine.rb
|
73
|
+
- lib/bitmovin/player/rails/helper.rb
|
74
|
+
- lib/bitmovin/player/rails/version.rb
|
75
|
+
- lib/generators/bitmovin_player/INSTRUCTIONS
|
76
|
+
- lib/generators/bitmovin_player/README
|
77
|
+
- lib/generators/bitmovin_player/bitmovin_player_generator.rb
|
78
|
+
- lib/generators/bitmovin_player/templates/config.yml.erb
|
79
|
+
- lib/tasks/bitmovin/player/rails_tasks.rake
|
80
|
+
homepage: https://bitmovin.com/html5-player/
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
metadata: {}
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 2.5.1
|
101
|
+
signing_key:
|
102
|
+
specification_version: 4
|
103
|
+
summary: An Adaptive HTML5 Video Player
|
104
|
+
test_files: []
|