@@ -5,33 +5,34 @@ module ViewHelpers
5
5
# js method with given option parameters.
6
6
#
7
7
# @param [Hash] options options for the player
8
- # @option options [String ] :src The location of an audio file, local ore remote.
9
- # @option options [String ] :type The media type of the resource.
10
- # @option options [String ] :mp4 The location of an audio file with the type mp4.
11
- # @option options [String ] :mp3 The location of an audio file with the type mp3.
12
- # @option options [String ] :ogg The location of an audio file with the type ogg.
13
- # @option options [String ] :opus The location of an audio file with the type opus.
14
- # @option options [String ] :poster The location of the cover image for the rich audio player.
8
+ # @option options [string ] :src The location of an audio file, local ore remote.
9
+ # @option options [string ] :type The media type of the resource.
10
+ # @option options [string ] :mp4 The location of an audio file with the type mp4.
11
+ # @option options [string ] :mp3 The location of an audio file with the type mp3.
12
+ # @option options [string ] :ogg The location of an audio file with the type ogg.
13
+ # @option options [string ] :opus The location of an audio file with the type opus.
14
+ # @option options [string ] :poster The location of the cover image for the rich audio player.
15
15
# @option options [integer] :width (auto) The width of the player.
16
16
# @option options [integer] :height The height of the player.
17
17
# @option options [boolean] :loop (false) Loops the audio when it ends.
18
- # @option options [boolean ] :preload (true ) Start loading the audio as soon as possible,
18
+ # @option options [string ] :preload (auto ) Start loading the video as soon as possible,
19
19
# before the user clicks play. This might not work on all browsers.
20
+ # Options are: 'auto', 'metadata' and 'none'
20
21
# @option options [boolean] :autoplay (false) Start playing the audio as soon as it's ready.
21
22
# This might not work on all (mobile) devices.
22
- # @option options [String ] :duration (false) Enables display of duration without having to load the
23
+ # @option options [string ] :duration (false) Enables display of duration without having to load the
23
24
# media file. Use seconds or timecode as a unit
24
25
# (e.g. "3522" or "00:58:42")
25
26
# @option options [boolean] :alwaysShowHours (true) Displays the time in 00:00:00 instead of 00:00.
26
27
# @option options [boolean] :alwaysShowControls (true) Defines whether the player control bar is
27
28
# permanently visible.
28
29
# @option options [boolean] :volume (true) Disables the volume slider.
29
30
# @option options [boolean] :progress (true) Disables the progress bar.
30
- # @option options [String ] :captions URL to a WebVTT captions file.
31
+ # @option options [string ] :captions URL to a WebVTT captions file.
31
32
# @option options [boolean] :chapters Takes chapter string in JSON format and builds an interactive
32
33
# chapter table. Chapters must be written in the following format:
33
34
# !{'start':'00:00:00.000', 'title':'Chapter One', 'image':''}
34
- # @option options [String ] :chapterlinks (all) Option for the jumplink behaviour in chapter table.
35
+ # @option options [string ] :chapterlinks (all) Option for the jumplink behaviour in chapter table.
35
36
# Options are: 'all' (all chapter links are clickable), 'buffered' (only
36
37
# buffered chapters are clickable), 'false' (chapters are not linked)
37
38
# @option options [boolean] :chaptersVisible (false) Defines the default visibility status of
@@ -42,7 +43,7 @@ module ViewHelpers
42
43
# toggable summary module.
43
44
# @option options [boolean] :downloadbuttonsVisible (false) Defines the default visibility of the
44
45
# download buttons.
45
- # @return [String ] HTML markup and JS call.
46
+ # @return [string ] HTML markup and JS call.
46
47
def podloveaudio ( options = { } )
47
48
podlove ( "audio" , options )
48
49
end
@@ -51,17 +52,18 @@ def podloveaudio(options = {})
51
52
# js method with given option parameters.
52
53
#
53
54
# @param [Hash] options options for the player
54
- # @option options [String ] :src This location of an video file, local ore remote.
55
- # @option options [String ] :type The media type of the resource.
56
- # @option options [String ] :mp4 The location of an audio file with the type mp4.
57
- # @option options [String ] :webm The location of an audio file with the type webm.
58
- # @option options [String ] :ogg The location of an audio file with the type ogg.
59
- # @option options [String ] :poster The location of the poster frame for the video.
55
+ # @option options [string ] :src This location of an video file, local ore remote.
56
+ # @option options [string ] :type The media type of the resource.
57
+ # @option options [string ] :mp4 The location of an audio file with the type mp4.
58
+ # @option options [string ] :webm The location of an audio file with the type webm.
59
+ # @option options [string ] :ogg The location of an audio file with the type ogg.
60
+ # @option options [string ] :poster The location of the poster frame for the video.
60
61
# @option options [integer] :width (auto) The width of the player.
61
62
# @option options [integer] :height The height of the player.
62
63
# @option options [boolean] :loop (false) Loops the video when it ends.
63
- # @option options [boolean ] :preload (true ) Start loading the video as soon as possible,
64
+ # @option options [string ] :preload (auto ) Start loading the video as soon as possible,
64
65
# before the user clicks play. This might not work on all browsers.
66
+ # Options are: 'auto', 'metadata' and 'none'
65
67
# @option options [boolean] :autoplay (false) Start playing the video as soon as it's ready.
66
68
# This might not work on all (mobile) devices.
67
69
# @option options [boolean] :fullscreen (true) Disables the fullscreen button for video.
@@ -74,11 +76,11 @@ def podloveaudio(options = {})
74
76
# controls out when not hovering the video.
75
77
# @option options [boolean] :volume (true) Disables the volume slider.
76
78
# @option options [boolean] :progress (true) Disables the progress bar.
77
- # @option options [String ] :captions URL to a WebVTT captions file.
79
+ # @option options [string ] :captions URL to a WebVTT captions file.
78
80
# @option options [boolean] :chapters Takes chapter string in JSON format and builds an interactive
79
81
# chapter table. Chapters must be written in the following format:
80
82
# !{'start':'00:00:00.000', 'title':'Chapter One', 'image':''}
81
- # @option options [String ] :chapterlinks (all) Option for the jumplink behaviour in chapter table.
83
+ # @option options [string ] :chapterlinks (all) Option for the jumplink behaviour in chapter table.
82
84
# Options are: 'all' (all chapter links are clickable), 'buffered' (only
83
85
# buffered chapters are clickable), 'false' (chapters are not linked)
84
86
# @option options [boolean] :chaptersVisible (false) Defines the default visibility status of
@@ -89,7 +91,7 @@ def podloveaudio(options = {})
89
91
# toggable summary module.
90
92
# @option options [boolean] :downloadbuttonsVisible (false) Defines the default visibility of the
91
93
# download buttons.
92
- # @return [String ] HTML markup and JS call.
94
+ # @return [string ] HTML markup and JS call.
93
95
def podlovevideo ( options = { } )
94
96
podlove ( "video" , options )
95
97
end
@@ -98,8 +100,9 @@ def podlovevideo(options = {})
98
100
99
101
def podlove ( type , options = { } )
100
102
id = "player_" + SecureRandom . hex ( 5 )
103
+ preload ||= "auto"
101
104
102
- html = "<#{ type } id='#{ id } ' preload=\" none \" >"
105
+ html = "<#{ type } id='#{ id } ' preload=#{ preload } >"
103
106
html << "<source src='#{ options [ :src ] } '" \
104
107
"" + ( options [ :type ] ? " type='#{ options [ :type ] } '" : "" ) + "></source>" if options [ :src ]
105
108
html << "<source src='#{ options [ :mp4 ] } ' type='#{ type } /mp4'></source>" if options [ :mp4 ]
@@ -109,7 +112,7 @@ def podlove(type, options = {})
109
112
html << "<source src='#{ options [ :webm ] } ' type='#{ type } /webm'></source>" if options [ :webm ]
110
113
html << "</#{ type } >"
111
114
112
- [ :src , :type , :mp4 , :mp3 , :ogg , :opus , :webm ] . each { |key | options . delete ( key ) }
115
+ [ :src , :type , :mp4 , :mp3 , :ogg , :opus , :webm , :preload ] . each { |key | options . delete ( key ) }
113
116
114
117
script = "jQuery('##{ id } ').podlovewebplayer(#{ options . to_json } );"
115
118
0 commit comments