Skip to content

Commit 29a94ab

Browse files
author
Bastian Bartmann
committed
added support for multiple codecs
1 parent 327f800 commit 29a94ab

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

lib/podlove-web-player-rails/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module Podlove
22
module Web
33
module Player
44
module Rails
5-
VERSION = "0.2.0.alpha"
5+
VERSION = "0.3.0"
66
end
77
end
88
end

lib/podlove-web-player-rails/view_helpers.rb

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,22 @@ def podlovevideo(options = {})
1515

1616
def podlove(type, options = {})
1717
html = "<#{type} id='player'>"
18-
html << "<source src='#{options[:src]}' type='#{options[:type]}'></source>"
19-
html << "</audio>"
18+
html << "<source src='#{options[:src]}'"\
19+
"" + (options[:type] ? " type='#{options[:type]}'" : "") + "></source>" if options[:src]
20+
html << "<source src='#{options[:mp3]}' type='audio/mpeg'></source>" if options[:mp3]
21+
html << "<source src='#{options[:opus]}' type='audio/ogg; codecs=opus'></source>" if options[:opus]
22+
if type == 'audio'
23+
html << "<source src='#{options[:mp4]}' type='audio/mp4'></source>" if options[:mp4]
24+
html << "<source src='#{options[:ogg]}' type='audio/ogg; codecs=vorbis'></source>" if options[:ogg]
25+
end
26+
html << "<source src='#{options[:opus]}' type='video/webm'></source>" if options[:webm]
27+
if type == 'video'
28+
html << "<source src='#{options[:mp4]}' type='video/mp4'></source>" if options[:mp4]
29+
html << "<source src='#{options[:ogg]}' type='video/ogg'></source>" if options[:ogg]
30+
end
31+
html << "</#{type}>"
2032

21-
options.delete(:src)
22-
options.delete(:type)
33+
[:src, :type, :mp4, :mp3, :ogg, :opus, :webm].each{ |key| options.delete(key) }
2334

2435
script = "$('#player').podlovewebplayer(#{options.to_json});"
2536

0 commit comments

Comments
 (0)