Add a form to change videos
Create a form field to specify an HLS stream URL on the example page.
Showing
1 changed file
with
26 additions
and
0 deletions
... | @@ -39,6 +39,11 @@ | ... | @@ -39,6 +39,11 @@ |
39 | padding: 0 5px; | 39 | padding: 0 5px; |
40 | margin: 20px 0; | 40 | margin: 20px 0; |
41 | } | 41 | } |
42 | input { | ||
43 | margin-top: 15px; | ||
44 | min-width: 450px; | ||
45 | padding: 5px; | ||
46 | } | ||
42 | </style> | 47 | </style> |
43 | 48 | ||
44 | </head> | 49 | </head> |
... | @@ -56,10 +61,31 @@ | ... | @@ -56,10 +61,31 @@ |
56 | src="http://solutions.brightcove.com/jwhisenant/hls/apple/bipbop/bipbopall.m3u8" | 61 | src="http://solutions.brightcove.com/jwhisenant/hls/apple/bipbop/bipbopall.m3u8" |
57 | type="application/x-mpegURL"> | 62 | type="application/x-mpegURL"> |
58 | </video> | 63 | </video> |
64 | |||
65 | <form id=load-url> | ||
66 | <label> | ||
67 | Video URL: | ||
68 | <input id=url type=url value="http://solutions.brightcove.com/jwhisenant/hls/apple/bipbop/bipbopall.m3u8"> | ||
69 | </label> | ||
70 | <button type=submit>Load</button> | ||
71 | </form> | ||
72 | |||
59 | <script> | 73 | <script> |
60 | videojs.options.flash.swf = 'node_modules/videojs-swf/dist/video-js.swf'; | 74 | videojs.options.flash.swf = 'node_modules/videojs-swf/dist/video-js.swf'; |
61 | // initialize the player | 75 | // initialize the player |
62 | var player = videojs('video'); | 76 | var player = videojs('video'); |
77 | |||
78 | // hook up the video switcher | ||
79 | var loadUrl = document.getElementById('load-url'); | ||
80 | var url = document.getElementById('url'); | ||
81 | loadUrl.addEventListener('submit', function(event) { | ||
82 | event.preventDefault(); | ||
83 | player.src({ | ||
84 | src: url.value, | ||
85 | type: 'application/x-mpegURL' | ||
86 | }); | ||
87 | return false; | ||
88 | }); | ||
63 | </script> | 89 | </script> |
64 | </body> | 90 | </body> |
65 | </html> | 91 | </html> | ... | ... |
-
Please register or sign in to post a comment