ClipVilla_Video_Producer - Version 1.0.0

Version Notes

initial release

license key is required for video rendering
(key: test)

The video rendering process is run by a 1-minute cronjob.

Compatible with Magento Community 1.7.x and higher

Download this release

Release Info

Developer Jens Neumann
Extension ClipVilla_Video_Producer
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (66) hide show
  1. app/code/community/ClipVilla/MorI/Block/Adminhtml/Info.php +40 -0
  2. app/code/community/ClipVilla/MorI/Block/Adminhtml/ManageVideos.php +27 -0
  3. app/code/community/ClipVilla/MorI/Block/Adminhtml/ManageVideos/Grid.php +166 -0
  4. app/code/community/ClipVilla/MorI/Block/Adminhtml/ManageVideos/Popup.php +32 -0
  5. app/code/community/ClipVilla/MorI/Block/Adminhtml/ManageVideos/Renderer/Popup.php +39 -0
  6. app/code/community/ClipVilla/MorI/Block/Adminhtml/ManageVideos/Renderer/Status.php +71 -0
  7. app/code/community/ClipVilla/MorI/Block/Adminhtml/ManageVideos/Renderer/TemplateName.php +34 -0
  8. app/code/community/ClipVilla/MorI/Block/Adminhtml/Notifications.php +58 -0
  9. app/code/community/ClipVilla/MorI/Block/Videos.php +121 -0
  10. app/code/community/ClipVilla/MorI/Helper/Data.php +129 -0
  11. app/code/community/ClipVilla/MorI/Helper/Path.php +87 -0
  12. app/code/community/ClipVilla/MorI/Model/Executer/Mori.php +68 -0
  13. app/code/community/ClipVilla/MorI/Model/File.php +39 -0
  14. app/code/community/ClipVilla/MorI/Model/Indexer.php +110 -0
  15. app/code/community/ClipVilla/MorI/Model/Mail.php +43 -0
  16. app/code/community/ClipVilla/MorI/Model/Observer/DefaultValues.php +97 -0
  17. app/code/community/ClipVilla/MorI/Model/Observer/MassAction.php +39 -0
  18. app/code/community/ClipVilla/MorI/Model/Observer/ProductEditForm.php +119 -0
  19. app/code/community/ClipVilla/MorI/Model/Observer/VideoData.php +154 -0
  20. app/code/community/ClipVilla/MorI/Model/Resource/Stack.php +22 -0
  21. app/code/community/ClipVilla/MorI/Model/Resource/Stack/Collection.php +23 -0
  22. app/code/community/ClipVilla/MorI/Model/Resource/Videos.php +22 -0
  23. app/code/community/ClipVilla/MorI/Model/Resource/Videos/Collection.php +25 -0
  24. app/code/community/ClipVilla/MorI/Model/Sitemap/Video.php +106 -0
  25. app/code/community/ClipVilla/MorI/Model/Stack.php +54 -0
  26. app/code/community/ClipVilla/MorI/Model/System/Attribute/Source/Provider.php +89 -0
  27. app/code/community/ClipVilla/MorI/Model/System/Config/Source/TemplateSelect.php +36 -0
  28. app/code/community/ClipVilla/MorI/Model/VideoCron.php +171 -0
  29. app/code/community/ClipVilla/MorI/Model/Videos.php +331 -0
  30. app/code/community/ClipVilla/MorI/controllers/Adminhtml/ManageVideosController.php +74 -0
  31. app/code/community/ClipVilla/MorI/controllers/Adminhtml/VideoController.php +105 -0
  32. app/code/community/ClipVilla/MorI/etc/adminhtml.xml +57 -0
  33. app/code/community/ClipVilla/MorI/etc/config.xml +219 -0
  34. app/code/community/ClipVilla/MorI/etc/mapping.xml +248 -0
  35. app/code/community/ClipVilla/MorI/etc/system.xml +180 -0
  36. app/code/community/ClipVilla/MorI/sql/clipvilla_mori_setup/install-0.1.0.php +106 -0
  37. app/code/community/ClipVilla/MorI/sql/clipvilla_mori_setup/upgrade-0.1.0-0.2.0.php +95 -0
  38. app/code/community/ClipVilla/MorI/sql/clipvilla_mori_setup/upgrade-0.2.0-0.3.0.php +55 -0
  39. app/code/community/ClipVilla/MorI/sql/clipvilla_mori_setup/upgrade-0.3.0-1.0.0.php +35 -0
  40. app/design/adminhtml/default/default/layout/clipvilla.xml +64 -0
  41. app/design/adminhtml/default/default/template/clipvilla/information.phtml +40 -0
  42. app/design/adminhtml/default/default/template/clipvilla/notifications.phtml +42 -0
  43. app/design/adminhtml/default/default/template/clipvilla/popup.phtml +26 -0
  44. app/design/frontend/base/default/layout/clipvilla.xml +33 -0
  45. app/design/frontend/base/default/template/clipvilla/videos.phtml +136 -0
  46. app/etc/modules/ClipVilla_MorI.xml +9 -0
  47. app/locale/en_US/template/email/clipvilla.html +10 -0
  48. js/clipvilla/popup.js +25 -0
  49. js/clipvilla/video-js/font/vjs.eot +0 -0
  50. js/clipvilla/video-js/font/vjs.svg +28 -0
  51. js/clipvilla/video-js/font/vjs.ttf +0 -0
  52. js/clipvilla/video-js/font/vjs.woff +0 -0
  53. js/clipvilla/video-js/lang/de.js +26 -0
  54. js/clipvilla/video-js/lang/es.js +26 -0
  55. js/clipvilla/video-js/lang/fr.js +26 -0
  56. js/clipvilla/video-js/lang/it.js +26 -0
  57. js/clipvilla/video-js/lang/ja.js +26 -0
  58. js/clipvilla/video-js/lang/ko.js +26 -0
  59. js/clipvilla/video-js/lang/nl.js +26 -0
  60. js/clipvilla/video-js/lang/pt-BR.js +26 -0
  61. js/clipvilla/video-js/lang/ru.js +26 -0
  62. js/clipvilla/video-js/lang/uk.js +26 -0
  63. js/clipvilla/video-js/video-js.css +961 -0
  64. js/clipvilla/video-js/video.js +8567 -0
  65. media/clipvilla/videos/clipvillalogo.png +0 -0
  66. package.xml +38 -0
app/code/community/ClipVilla/MorI/Block/Adminhtml/Info.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Block_Adminhtml_Info extends Mage_Core_Block_Template
15
+ implements Varien_Data_Form_Element_Renderer_Interface
16
+ {
17
+
18
+ /**
19
+ * returns an phtml with the extension Information
20
+ *
21
+ * @param Varien_Data_Form_Element_Abstract $element
22
+ *
23
+ * @return string
24
+ */
25
+ public function render(Varien_Data_Form_Element_Abstract $element)
26
+ {
27
+ $this->setTemplate('clipvilla' . DS . 'information.phtml');
28
+ return $this->_toHtml();
29
+ }
30
+
31
+ /**
32
+ * returns the logo file for the information tab in module configuration
33
+ *
34
+ *@ return string
35
+ */
36
+ public function getLogo()
37
+ {
38
+ return Mage::getBaseUrl('media') . 'clipvilla' . DS . 'videos' . DS . 'clipvillalogo.png';
39
+ }
40
+ }
app/code/community/ClipVilla/MorI/Block/Adminhtml/ManageVideos.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Block_Adminhtml_ManageVideos extends Mage_Adminhtml_Block_Widget_Grid_Container
15
+ {
16
+
17
+ public function __construct()
18
+ {
19
+ $this->_controller = 'adminhtml_manageVideos';
20
+ $this->_blockGroup = 'clipvilla_mori';
21
+ $this->_headerText = Mage::helper('clipvilla_mori')->__('Manage Videos');
22
+
23
+ $this->_addButtonLabel = Mage::helper('clipvilla_mori')->__('Download Video Sitemap');
24
+ parent::__construct();
25
+ }
26
+
27
+ }
app/code/community/ClipVilla/MorI/Block/Adminhtml/ManageVideos/Grid.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Block_Adminhtml_ManageVideos_Grid extends Mage_Adminhtml_Block_Widget_Grid
15
+ {
16
+
17
+ public function __construct()
18
+ {
19
+ parent::__construct();
20
+ $this->setId('manageVideosId');
21
+ $this->setDefaultSort('product_id');
22
+ $this->setDefaultDir('DESC');
23
+ $this->setSaveParametersInSession(true);
24
+ }
25
+
26
+ /**
27
+ * return the collection for the manage videos grid
28
+ *
29
+ * @return Mage_Adminhtml_Block_Widget_Grid
30
+ */
31
+ protected function _prepareCollection()
32
+ {
33
+ $collection = Mage::getModel('clipvilla_mori/videos')->getCollection();
34
+
35
+ $collection->getSelect()->joinLeft(array('stack' => 'clipvilla_stack'),
36
+ 'main_table.video_id = stack.video_id', array(
37
+ 'stack_status' => 'status',
38
+ )
39
+ );
40
+
41
+ $collection->addFieldToFilter(
42
+ array('main_table.status', 'stack.status'),
43
+ array(
44
+ array('neq' => 0), // main_table.status != 0
45
+ array('notnull' => true) // stack.status IS NOT NULL
46
+ )
47
+ );
48
+
49
+ $this->setCollection($collection);
50
+ return parent::_prepareCollection();
51
+ }
52
+
53
+ /**
54
+ * adds columns to the grid
55
+ *
56
+ * @return $this
57
+ */
58
+ protected function _prepareColumns()
59
+ {
60
+ $this->addColumn('product_id', array(
61
+ 'header' => Mage::helper('clipvilla_mori')->__('Product ID'),
62
+ 'align' =>'right',
63
+ 'width' => '50px',
64
+ 'type' => 'number',
65
+ 'index' => 'product_id'
66
+ ));
67
+
68
+ $this->addColumn('name', array(
69
+ 'header' => Mage::helper('clipvilla_mori')->__('Video Name'),
70
+ 'width' => '900px',
71
+ 'index' => 'name'
72
+ ));
73
+
74
+ $this->addColumn('video_template', array(
75
+ 'header' => Mage::helper('clipvilla_mori')->__('Video Template'),
76
+ 'type' => 'options',
77
+ 'options' => $this->getTemplateNameOptions(),
78
+ 'renderer' => 'ClipVilla_MorI_Block_Adminhtml_ManageVideos_Renderer_TemplateName',
79
+ 'index' => 'render_project_id'
80
+ ));
81
+
82
+ $this->addColumn('created_at', array(
83
+ 'header' => Mage::helper('clipvilla_mori')->__('Created At'),
84
+ 'width' => '180px',
85
+ 'align' => 'center',
86
+ 'type' => 'datetime',
87
+ 'index' => 'creation_date'
88
+ ));
89
+
90
+ $this->addColumn('status', array(
91
+ 'header' => Mage::helper('clipvilla_mori')->__('Status'),
92
+ 'type' => 'options',
93
+ 'width' => '150px',
94
+ 'align' => 'center',
95
+ 'options' => $this->getStatusOptions(),
96
+ 'renderer' => 'ClipVilla_MorI_Block_Adminhtml_ManageVideos_Renderer_Status',
97
+ 'index' => 'main_table.status'
98
+ ));
99
+
100
+ $this->addColumn('video_popup', array(
101
+ 'header' => Mage::helper('sales')->__('Show Video'),
102
+ 'width' => '5%',
103
+ 'align' => 'center',
104
+ 'renderer' => 'ClipVilla_MorI_Block_Adminhtml_ManageVideos_Renderer_Popup',
105
+ 'filter' => false,
106
+ 'sortable' => false,
107
+ 'index' => 'video_id'
108
+ ));
109
+
110
+ return parent::_prepareColumns();
111
+ }
112
+
113
+ /**
114
+ * adds the massaction to delete Videos
115
+ *
116
+ * @return $this|Mage_Adminhtml_Block_Widget_Grid
117
+ */
118
+ protected function _prepareMassaction()
119
+ {
120
+ $this->setMassactionIdField('video_id');
121
+ $this->getMassactionBlock()->setFormFieldName('video_ids');
122
+ $this->getMassactionBlock()->setUseSelectAll(true);
123
+ $this->getMassactionBlock()->addItem('remove_manageVideos', array(
124
+ 'label' => Mage::helper('clipvilla_mori')->__('Delete'),
125
+ 'url' => Mage::getModel('adminhtml/url')->getUrl('*/manageVideos/massDeleteAll'),
126
+ 'confirm' => Mage::helper('clipvilla_mori')->__('Are you sure?')
127
+ ));
128
+ return $this;
129
+ }
130
+
131
+ /**
132
+ * returns the name to all templates from the mapping.xml
133
+ *
134
+ * @return array
135
+ */
136
+ public function getTemplateNameOptions()
137
+ {
138
+ $templateNames = array();
139
+ $mapping = Mage::helper('clipvilla_mori/path')->getMappingXml();
140
+ foreach ($mapping->mapping as $template) {
141
+ $templateNames[(String)$template->renderProjectId] = (String)$template->templateName;
142
+ }
143
+
144
+ return $templateNames;
145
+ }
146
+
147
+ /**
148
+ * returns the Status of the Video
149
+ *
150
+ * @return array
151
+ */
152
+ public function getStatusOptions()
153
+ {
154
+ $status = array(
155
+ ClipVilla_MorI_Model_Videos::STATUS_EXISTS => 'Video exists',
156
+ ClipVilla_MorI_Model_Videos::STATUS_EXISTS_NOT => 'Video in queue',
157
+ ClipVilla_MorI_Model_Videos::STATUS_ERROR => 'Error',
158
+ ClipVilla_MorI_Model_Videos::STATUS_LICENSE => 'Invalid Key',
159
+ ClipVilla_MorI_Model_Videos::STATUS_CAPACITY => 'Capacity exceeded'
160
+ );
161
+
162
+ return $status;
163
+ }
164
+
165
+
166
+ }
app/code/community/ClipVilla/MorI/Block/Adminhtml/ManageVideos/Popup.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Block_Adminhtml_ManageVideos_Popup extends Mage_Adminhtml_Block_Template
15
+ {
16
+
17
+ /**
18
+ * returns the video File for the manage videos page in adimhtml
19
+ *
20
+ * @return string
21
+ */
22
+ public function getVideo()
23
+ {
24
+ $videoId = $this->getRequest()->getParam('video_id');
25
+ $productId = Mage::getModel('clipvilla_mori/videos')->load($videoId)->getProductId();
26
+
27
+ $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
28
+ $video = Mage::getStoreConfig('clipvilla/configuration/video_folder').DS.$productId.'.mp4';
29
+ return $baseUrl.$video;
30
+ }
31
+
32
+ }
app/code/community/ClipVilla/MorI/Block/Adminhtml/ManageVideos/Renderer/Popup.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *ClipVilla Video Producer
5
+ *
6
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
7
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
8
+ *
9
+ * NOTICE OF LICENSE
10
+ *
11
+ * This source file is subject to the GNU General Public License (GPLv3)
12
+ * It is available through the world-wide-web at this URL:
13
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
14
+ */
15
+ class ClipVilla_MorI_Block_Adminhtml_ManageVideos_Renderer_Popup
16
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
17
+ {
18
+
19
+ /**
20
+ * makes the "view" clickable and opens the new page in an Pop-Up
21
+ *
22
+ * @param Varien_Object $row
23
+ *
24
+ * @return string
25
+ */
26
+ public function render(Varien_Object $row)
27
+ {
28
+ $video_id = $row->getData($this->getColumn()->getIndex());
29
+ $url = Mage::helper('adminhtml')->getUrl('*/manageVideos/popup', array('video_id' => $video_id));
30
+ $name = $row->getData('name');
31
+ $name = preg_replace("/'/", "\\'", $name);
32
+ $name = preg_replace("/\"/", "&quot", $name);
33
+
34
+ if ($row->getData('status') == 1) {
35
+ return '<div style ="color:#ea7601;text-decoration:underline;cursor:pointer;" onclick="openPopup(\''.$url.'\', \''.$name.'\')">View</div>';
36
+ }
37
+ }
38
+
39
+ }
app/code/community/ClipVilla/MorI/Block/Adminhtml/ManageVideos/Renderer/Status.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Block_Adminhtml_ManageVideos_Renderer_Status
15
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
16
+ {
17
+
18
+ /**
19
+ * changes the video Status (int) to something readable
20
+ * adds an colored background depending on the status
21
+ *
22
+ * @param Varien_Object $row
23
+ *
24
+ * @return string
25
+ */
26
+ public function render(Varien_Object $row)
27
+ {
28
+ $helper = Mage::helper('clipvilla_mori/path');
29
+ $value = $row->getStatus();
30
+ $stackStatus = $row->getStackStatus();
31
+
32
+ switch ($value) {
33
+ case ClipVilla_MorI_Model_Videos::STATUS_EXISTS_NOT:
34
+
35
+ switch ($stackStatus) {
36
+ case ClipVilla_MorI_Model_Stack::STATUS_QUEUE:
37
+ $value = $helper->__('Video in queue');
38
+ $backgroundColor = '#FF8000';
39
+ break;
40
+ case ClipVilla_MorI_Model_Stack::STATUS_DOWNLOAD:
41
+ $value = $helper->__('Downloading video');
42
+ $backgroundColor = '#D7DF01';
43
+ break;
44
+ case ClipVilla_MorI_Model_Stack::STATUS_RENDERING:
45
+ $value = $helper->__('Video rendering');
46
+ $backgroundColor = '#D7DF01';
47
+ break;
48
+ }
49
+
50
+ break;
51
+ case ClipVilla_MorI_Model_Videos::STATUS_EXISTS:
52
+ $backgroundColor = '#04B431';
53
+ $value = $helper->__('Video Exists');
54
+ break;
55
+ case ClipVilla_MorI_Model_Videos::STATUS_ERROR:
56
+ $backgroundColor = '#DF0101';
57
+ $value = $helper->__('Error');
58
+ break;
59
+ case ClipVilla_MorI_Model_Videos::STATUS_LICENSE:
60
+ $backgroundColor = '#DF0101';
61
+ $value = $helper->__('Invalid Key');
62
+ break;
63
+ case ClipVilla_MorI_Model_Videos::STATUS_CAPACITY:
64
+ $backgroundColor = '#DF0101';
65
+ $value = $helper->__('Capacity exceeded');
66
+ break;
67
+ }
68
+
69
+ return '<div style="color:#FFF;font-weight:bold;background:' . $backgroundColor . ';border-radius:8px;width:100%">' . $value . '</div>';
70
+ }
71
+ }
app/code/community/ClipVilla/MorI/Block/Adminhtml/ManageVideos/Renderer/TemplateName.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Block_Adminhtml_ManageVideos_Renderer_TemplateName
15
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
16
+ {
17
+
18
+ /**
19
+ * changes template id to template name
20
+ *
21
+ * @param Varien_Object $row
22
+ *
23
+ * @return string
24
+ */
25
+ public function render(Varien_Object $row)
26
+ {
27
+ $helper = Mage::helper('clipvilla_mori');
28
+ $value = $row->getData($this->getColumn()->getIndex());
29
+ $value = $helper->getTemplateName($value);
30
+
31
+ return $value;
32
+ }
33
+
34
+ }
app/code/community/ClipVilla/MorI/Block/Adminhtml/Notifications.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Block_Adminhtml_Notifications extends Mage_Adminhtml_Block_Template
15
+ {
16
+
17
+ private $moduleActive;
18
+
19
+ protected function _construct()
20
+ {
21
+ $this->moduleActive = Mage::getStoreConfig('clipvilla/configuration/activate');
22
+ }
23
+
24
+ /**
25
+ * returns the number of entries in the stack table, which is the rendering queue
26
+ *
27
+ * @return bool
28
+ */
29
+ public function getStackCount()
30
+ {
31
+ if ($this->moduleActive) {
32
+ return Mage::getResourceModel('clipvilla_mori/stack_collection')->getSize();
33
+ } else {
34
+ return false;
35
+ }
36
+ }
37
+
38
+
39
+ /**
40
+ * returns the last renered Video
41
+ *
42
+ * @return array|bool
43
+ */
44
+ public function getLastRendered()
45
+ {
46
+ if ($this->moduleActive) {
47
+ $lastRendered = Mage::getModel('clipvilla_mori/videos')->getCollection()
48
+ ->addFieldToFilter('status', array('eq' => ClipVilla_MorI_Model_Videos::STATUS_EXISTS))
49
+ ->setOrder('creation_date', 'DESC')
50
+ ->getFirstItem();
51
+
52
+ return array('name' => $lastRendered->getName(), 'id' => $lastRendered->getProductId());
53
+ } else {
54
+ return false;
55
+ }
56
+ }
57
+
58
+ }
app/code/community/ClipVilla/MorI/Block/Videos.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Block_Videos extends Mage_Core_Block_Template
15
+ {
16
+
17
+ private $productId;
18
+ private $video;
19
+ private $videoFile;
20
+
21
+ protected function _construct()
22
+ {
23
+ $this->productId = Mage::registry('current_product')->getId();
24
+
25
+ $this->video = Mage::getModel('clipvilla_mori/videos')
26
+ ->load($this->productId, 'product_id');
27
+
28
+ $this->videoFile = Mage::getStoreConfig('clipvilla/configuration/video_folder')
29
+ . DS . $this->productId . '.mp4';
30
+ }
31
+
32
+ /**
33
+ * returns VideoFile
34
+ *
35
+ * @return string
36
+ */
37
+ public function getVideoFile()
38
+ {
39
+ $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
40
+ return $baseUrl.$this->videoFile;
41
+ }
42
+
43
+ /**
44
+ * Checks if Video can be display in frontend
45
+ *
46
+ * @return bool
47
+ */
48
+ public function videoExists()
49
+ {
50
+ if (Mage::getStoreConfig('clipvilla/configuration/activate')) {
51
+ if ($this->video->getStatus()) {
52
+ if (file_exists($this->videoFile)) {
53
+ return true;
54
+ }
55
+ }
56
+ }
57
+ return false;
58
+ }
59
+
60
+ /**
61
+ * return the Creation Date of the Video
62
+ *
63
+ * @return mixed
64
+ */
65
+ public function getCreationDate()
66
+ {
67
+ $date = Mage::getModel('core/date')->timestamp(strtotime($this->video->getCreationDate()));
68
+ $date = date('Y-m-d', $date);
69
+ return $date;
70
+ }
71
+
72
+ /**
73
+ * returns the first Image used in the Video
74
+ *
75
+ * @return string
76
+ */
77
+ public function getImageUrl()
78
+ {
79
+ return $ImageUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)
80
+ .'media' . DS . 'catalog' . DS . 'product' . $this->video->getImageOne();
81
+ }
82
+
83
+ /**
84
+ * return the Meta Title, if its empty the product Name is returned
85
+ *
86
+ * @return mixed
87
+ */
88
+ public function getMetaTitle()
89
+ {
90
+ $metaTitle = Mage::registry('current_product')->getMetaTitle();
91
+ if (empty($metaTitle)) {
92
+ $metaTitle = Mage::registry('current_product')->getName();
93
+ }
94
+ return $metaTitle;
95
+ }
96
+
97
+ /**
98
+ * return the Meta Title, if its empty the product Name is returned
99
+ *
100
+ * @return mixed
101
+ */
102
+ public function getMetaDescription()
103
+ {
104
+ $metaDescription = Mage::registry('current_product')->getMetaDescription();
105
+ if (empty($metaDescription)) {
106
+ $metaDescription = Mage::registry('current_product')->getShortDescription();
107
+ }
108
+ return $metaDescription;
109
+ }
110
+
111
+ /**
112
+ * returns the Video duration
113
+ *
114
+ * @return mixed
115
+ */
116
+ public function getVideoDuration()
117
+ {
118
+ return Mage::helper('clipvilla_mori')->getVideoDuration($this->video->getRenderProjectId());
119
+ }
120
+
121
+ }
app/code/community/ClipVilla/MorI/Helper/Data.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Helper_Data extends Mage_Core_Helper_Abstract
15
+ {
16
+
17
+ /**
18
+ * Returns the Corresponding Word to a number
19
+ *
20
+ * @param $count
21
+ *
22
+ * @return string
23
+ */
24
+ public function numberConverter($count)
25
+ {
26
+ switch ($count) {
27
+ case 1:
28
+ return 'One';
29
+ break;
30
+ case 2:
31
+ return 'Two';
32
+ break;
33
+ case 3:
34
+ return 'Three';
35
+ break;
36
+ case 4:
37
+ return 'Four';
38
+ break;
39
+ default:
40
+ return '';
41
+ break;
42
+ }
43
+ }
44
+
45
+ /**
46
+ * returns array with all product images
47
+ *
48
+ *
49
+ * @return array
50
+ */
51
+ public function getImageFiles($images)
52
+ {
53
+ if ($images != '') {
54
+ $imagesFiles = array();
55
+ foreach ($images as $image) {
56
+ if (!$image['disabled']) {
57
+ if (!array_key_exists('removed', $image)) {
58
+ $imagesFiles[] = $image['file'];
59
+ } elseif (!$image['removed']) {
60
+ $imagesFiles[] = $image['file'];
61
+ }
62
+ }
63
+ }
64
+ return $imagesFiles;
65
+ }
66
+ }
67
+
68
+ /**
69
+ * returns Templatename from mapping.xml
70
+ *
71
+ * @param $templateId
72
+ *
73
+ * @return mixed
74
+ */
75
+ public function getTemplateName($templateId)
76
+ {
77
+ $mapping = Mage::helper('clipvilla_mori/path')->getMappingXml();
78
+ foreach ($mapping->mapping as $template) {
79
+ if ($template->renderProjectId == $templateId) {
80
+ return $template->templateName;
81
+ }
82
+ }
83
+ }
84
+
85
+ /**
86
+ * returns Video duration from mapping.xml
87
+ *
88
+ * @param $templateId
89
+ *
90
+ * @return mixed
91
+ */
92
+ public function getVideoDuration($templateId)
93
+ {
94
+ $mapping = Mage::helper('clipvilla_mori/path')->getMappingXml();
95
+ foreach ($mapping->mapping as $template) {
96
+ if ($template->renderProjectId == $templateId) {
97
+ return $template->duration;
98
+ }
99
+ }
100
+ }
101
+
102
+ /**
103
+ * returns all template ids from all categories
104
+ *
105
+ * @param $catIds
106
+ *
107
+ * @return string
108
+ */
109
+ public function getTemplateIdFromCategory($catIds)
110
+ {
111
+ if(empty($catIds)){
112
+ return '';
113
+ }
114
+ $categories = Mage::getResourceModel('catalog/category_collection')
115
+ ->addAttributeToSelect('clipvilla_template')
116
+ ->addAttributeToFilter('entity_id', $catIds)
117
+ ->addIsActiveFilter();
118
+
119
+ foreach ($categories as $cat) {
120
+ $id = $cat->getClipvillaTemplate();
121
+ if ($id != '') {
122
+ return $id;
123
+ }
124
+ }
125
+ return '';
126
+ }
127
+
128
+
129
+ }
app/code/community/ClipVilla/MorI/Helper/Path.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Helper_Path extends Mage_Core_Helper_Abstract
15
+ {
16
+
17
+ const ENCODING = '.mp4';
18
+
19
+ /**
20
+ * returns Logo that got uploaded in the Module Configuration
21
+ *
22
+ * @param string $file
23
+ *
24
+ * @return string
25
+ */
26
+ public function getLogoFile($file = '')
27
+ {
28
+ return Mage::getBaseDir() . DS . 'media' . DS . 'clipvilla' . DS . $file;
29
+ }
30
+
31
+ /**
32
+ * returns directory for product images
33
+ *
34
+ * @param string $file
35
+ *
36
+ * @return string
37
+ */
38
+ public function getProductImageDir($file = '')
39
+ {
40
+ return Mage::getBaseDir('media') . DS . 'catalog' . DS . 'product' . $file;
41
+ }
42
+
43
+ /**
44
+ * @param $productId
45
+ *
46
+ * @return string
47
+ */
48
+ public function getVideoFile($productId)
49
+ {
50
+ return Mage::getBaseDir() . DS . Mage::getStoreConfig('clipvilla/configuration/video_folder') . DS . $productId
51
+ . self::ENCODING;
52
+ }
53
+
54
+ /**
55
+ * returns URL for Video download
56
+ *
57
+ * @param $productId
58
+ *
59
+ * @return string
60
+ */
61
+ public function getVideoDownloadPath($productId)
62
+ {
63
+ $myFile = $this->getMoriResultFile($productId, self::COMPLETE);
64
+ $lines = file($myFile);
65
+ return trim($lines[1]);
66
+ }
67
+
68
+ /**
69
+ * returns the mapping XML for the Rendering Templates
70
+ *
71
+ * @return string
72
+ */
73
+ public function getMappingXml()
74
+ {
75
+ return $mapping = simplexml_load_file(Mage::getModuleDir('etc', 'ClipVilla_MorI') . DS . 'mapping.xml');
76
+ }
77
+
78
+ /**
79
+ * returns File + Path of the Video-Sitemap
80
+ *
81
+ * @return string
82
+ */
83
+ public function getSitemapVideo()
84
+ {
85
+ return Mage::getBaseDir() . DS . 'media' . DS . 'clipvilla' . DS . 'sitemap_video.xml';
86
+ }
87
+ }
app/code/community/ClipVilla/MorI/Model/Executer/Mori.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Model_Executer_Mori
15
+ {
16
+
17
+ const WSDL = 'http://85.88.11.170:8080/MoRI/mori?wsdl';
18
+
19
+ /**
20
+ * starts the rendering process via soap for a single entry
21
+ *
22
+ * @param $soapVar
23
+ *
24
+ * @return mixed
25
+ */
26
+ public function startRendering($soapVar)
27
+ {
28
+ $options = array();
29
+ $wsdl = self::WSDL;
30
+
31
+ $soapclient = new SoapClient($wsdl, $options);
32
+ $response = $soapclient->renderProjectMtom($soapVar);
33
+ $responseObj = $response->RenderResponse;
34
+
35
+ if (property_exists($responseObj, 'error')) {
36
+ return $responseObj->error->message;
37
+ } else {
38
+ return $responseObj->renderJobId;
39
+ }
40
+ }
41
+
42
+ /**
43
+ * returns the Status of the Video currently in rendering
44
+ * returns the file path, if the video rendering is complete
45
+ *
46
+ * @param $id
47
+ *
48
+ * @return mixed
49
+ */
50
+ public function getStatus($id)
51
+ {
52
+ $wsdl = self::WSDL;;
53
+ $options = array();
54
+
55
+ $soapVar = array(
56
+ 'StatusRequest' => array(
57
+ 'renderJobId' => $id
58
+ )
59
+ );
60
+
61
+ $soapclient = new SoapClient($wsdl, $options);
62
+ $response = $soapclient->getStatus($soapVar);
63
+
64
+ $responseObj = $response->StatusResponse;
65
+
66
+ return $responseObj;
67
+ }
68
+ }
app/code/community/ClipVilla/MorI/Model/File.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Model_File extends Mage_Core_Model_Abstract
15
+ {
16
+
17
+ /**
18
+ * downloads the video
19
+ *
20
+ * @param $moriVideoFile
21
+ * @param $shopVideoFile
22
+ *
23
+ * @return bool
24
+ */
25
+ public function downloadMovieFile($fullServerFilePath, $localFile)
26
+ {
27
+ try {
28
+ preg_match("/Projects.*/", $fullServerFilePath, $serverFile);
29
+ $filew = "ftp://Mgnt-Extension:CVMgnt8588@85.88.11.170:21/$serverFile[0]";
30
+ $openFile = fopen($filew , 'r');
31
+ $strwri = file_put_contents($localFile, $openFile);
32
+
33
+ } catch (Exception $e) {
34
+ return $e;
35
+ }
36
+ }
37
+
38
+
39
+ }
app/code/community/ClipVilla/MorI/Model/Indexer.php ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Model_Indexer extends Mage_Index_Model_Indexer_Abstract
15
+ {
16
+
17
+ protected $_matchedEntities = array(
18
+ 'test_entity' => array(
19
+ Mage_Index_Model_Event::TYPE_SAVE
20
+ )
21
+ );
22
+
23
+ protected $_registered = false;
24
+ protected $_processed = false;
25
+
26
+ /**
27
+ * returns Indexer Name
28
+ *
29
+ * @return string
30
+ */
31
+ public function getName()
32
+ {
33
+ return Mage::helper('core')->__('Render Videos');
34
+ }
35
+
36
+ /**
37
+ * returns Indexer Description
38
+ *
39
+ * @return string
40
+ */
41
+ public function getDescription()
42
+ {
43
+ return Mage::helper('core')->__('Generate Videos for all visible products');
44
+ }
45
+
46
+ /**
47
+ * registers event
48
+ *
49
+ * @param Mage_Index_Model_Event $event
50
+ *
51
+ * @return $this
52
+ */
53
+ protected function _registerEvent(Mage_Index_Model_Event $event)
54
+ {
55
+ $this->_registered = true;
56
+ return $this;
57
+ }
58
+
59
+ /**
60
+ * renders video for visibile product on save
61
+ *
62
+ * @param Mage_Index_Model_Event $event
63
+ */
64
+ protected function _processEvent(Mage_Index_Model_Event $event)
65
+ {
66
+ if (!$this->_processed && Mage::getStoreConfig('clipvilla/configuration/activate')) {
67
+ $this->_processed = true;
68
+ $product = $event->getDataObject();
69
+
70
+ $video = Mage::getModel('clipvilla_mori/videos')->load($product->getId(), 'product_id');
71
+ $stack = Mage::getModel('clipvilla_mori/stack')->load($video->getVideoId(), 'video_id');
72
+
73
+ if ($event->getType() == Mage_Index_Model_Event::TYPE_SAVE) {
74
+ if ($video->getStatus() == 0 && $product->getVisibility() != 1) {
75
+ $stackData = $stack->getData();
76
+ if (empty($stackData) && $video->getImageOne() !== '') {
77
+ $stack = Mage::getModel('clipvilla_mori/stack');
78
+ $stack->setVideoId($video->getVideoId());
79
+ $stack->setPriority(0);
80
+ $stack->setStatus(ClipVilla_MorI_Model_Stack::STATUS_QUEUE);
81
+ $stack->save();
82
+ }
83
+ }
84
+ }
85
+ }
86
+ $this->_processed = false;
87
+ }
88
+
89
+ /**
90
+ * returns if the event matches
91
+ *
92
+ * @param Mage_Index_Model_Event $event
93
+ *
94
+ * @return bool
95
+ */
96
+ public function matchEvent(Mage_Index_Model_Event $event)
97
+ {
98
+ return Mage_Catalog_Model_Product::ENTITY == $event->getEntity();
99
+ }
100
+
101
+ /**
102
+ * renders Videos for all visible products
103
+ */
104
+ public function reindexAll()
105
+ {
106
+ if (Mage::getStoreConfig('clipvilla/configuration/activate')) {
107
+ Mage::getModel('clipvilla_mori/videos')->saveForAllProducts();
108
+ }
109
+ }
110
+ }
app/code/community/ClipVilla/MorI/Model/Mail.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Model_Mail extends Mage_Core_Model_Abstract
15
+ {
16
+
17
+ /**
18
+ * sends an Email in case of an Error during download, rendering etc
19
+ *
20
+ * @param $productId
21
+ * @param $errorMessage
22
+ *
23
+ * @return string
24
+ */
25
+ public function sendErrorMail($productId, $errorMessage)
26
+ {
27
+ if (Mage::getStoreConfig('clipvilla/rendering/allow_mail')) {
28
+ $emailTemplate = Mage::getModel('core/email_template')
29
+ ->loadDefault('clipvilla_mail');
30
+ $emailTemplateVariables = array(
31
+ 'productId' => $productId,
32
+ 'errorMessage' => $errorMessage
33
+ );
34
+
35
+ $emailTemplate->setSenderName('ClipVilla - Error Messenger');
36
+ $emailTemplate->setSenderEmail(Mage::getStoreConfig('trans_email/ident_general/email'));
37
+
38
+ $recipient = Mage::getStoreConfig('clipvilla/rendering/mail');
39
+ $emailTemplate->send($recipient, 'Backend-User', $emailTemplateVariables);
40
+ }
41
+ }
42
+
43
+ }
app/code/community/ClipVilla/MorI/Model/Observer/DefaultValues.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Model_Observer_DefaultValues
15
+ {
16
+
17
+ private $_product;
18
+
19
+ /**
20
+ * sets default values for product on product edit page
21
+ *
22
+ * @param Varien_Event_Observer $observer
23
+ */
24
+ public function setDefaultValues(Varien_Event_Observer $observer)
25
+ {
26
+ if (Mage::getStoreConfig('clipvilla/configuration/activate')) {
27
+ $this->_product = $observer->getProduct();
28
+
29
+ $values = array(
30
+ 'name' => array(
31
+ 'productValue' => $this->_product->getClipvillaName(),
32
+ 'configValue' => $this->_product->getName(),
33
+ 'setMethod' => 'setClipvillaName'
34
+ ),
35
+ 'uspOne' => array(
36
+ 'productValue' => $this->_product->getClipvillaUspOne(),
37
+ 'configValue' => Mage::getStoreConfig('clipvilla/custom_data/usp_one'),
38
+ 'setMethod' => 'setClipvillaUspOne'
39
+ ),
40
+ 'uspTwo' => array(
41
+ 'productValue' => $this->_product->getClipvillaUspTwo(),
42
+ 'configValue' => Mage::getStoreConfig('clipvilla/custom_data/usp_two'),
43
+ 'setMethod' => 'setClipvillaUspTwo'
44
+ ),
45
+ 'uspThree' => array(
46
+ 'productValue' => $this->_product->getClipvillaUspThree(),
47
+ 'configValue' => Mage::getStoreConfig('clipvilla/custom_data/usp_three'),
48
+ 'setMethod' => 'setClipvillaUspThree'
49
+ )
50
+ );
51
+
52
+ foreach ($values as $value) {
53
+ if ($value['productValue'] == '') {
54
+ $this->_product->$value['setMethod']($value['configValue']);
55
+ }
56
+ }
57
+ }
58
+ }
59
+
60
+ /**
61
+ * sets the Attributes that have been left empty
62
+ *
63
+ * @param Varien_Event_Observer $observer
64
+ */
65
+ public function setEmptyAttributes(Varien_Event_Observer $observer)
66
+ {
67
+ $product = $observer->getProduct();
68
+ if ($product->getClipvillaName() == '') {
69
+ $product->setClipvillaName($product->getName());
70
+ }
71
+
72
+ }
73
+
74
+ /**
75
+ * Compares Product-USP with Config-USP and deletes Product-USP if the values are equal
76
+ *
77
+ * @param Varien_Event_Observer $observer
78
+ */
79
+ public function deleteValues(Varien_Event_Observer $observer)
80
+ {
81
+ if (Mage::getStoreConfig('clipvilla/configuration/activate')) {
82
+ $helper = Mage::helper('clipvilla_mori');
83
+ $this->_product = $observer->getProduct();
84
+ $usps = array();
85
+ for ($i = 1; $i !== 4; $i++) {
86
+ $getMethod = 'getClipvillaUsp' . $helper->numberConverter($i);
87
+ $usps[] = $this->_product->$getMethod();
88
+
89
+ if ($this->_product->$getMethod() == Mage::getStoreConfig('clipvilla/custom_data/usp_' . strtolower($helper->numberConverter($i)))) {
90
+ $setMethod = 'setClipvillaUsp' . $helper->numberConverter($i);
91
+ $this->_product->$setMethod('');
92
+ }
93
+ }
94
+ Mage::register('usps', $usps);
95
+ }
96
+ }
97
+ }
app/code/community/ClipVilla/MorI/Model/Observer/MassAction.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Model_Observer_MassAction
15
+ {
16
+
17
+ /**
18
+ * Adds an mass-action to product grid for video rendering
19
+ *
20
+ * @param $observer
21
+ */
22
+ public function addRenderAll($observer)
23
+ {
24
+ $block = $observer->getEvent()->getBlock();
25
+ if (get_class($block) == 'Mage_Adminhtml_Block_Widget_Grid_Massaction'
26
+ && $block->getRequest()->getControllerName() == 'catalog_product'
27
+ ) {
28
+ $block->addItem(
29
+ 'newmodule', array(
30
+ 'label' => 'Render Video',
31
+ 'url' => Mage::getModel('adminhtml/url')->getUrl(
32
+ '*/video/massSaveAll', array('_current' => true)
33
+ )
34
+ )
35
+ );
36
+ }
37
+ }
38
+
39
+ }
app/code/community/ClipVilla/MorI/Model/Observer/ProductEditForm.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Model_Observer_ProductEditForm
15
+ {
16
+
17
+ /**
18
+ * adds the active template name on the product edit page video producer tab
19
+ *
20
+ * @param Varien_Event_Observer $observer
21
+ */
22
+ public function addTemplateName(Varien_Event_Observer $observer)
23
+ {
24
+ $helper = Mage::helper('clipvilla_mori');
25
+
26
+ $_product = Mage::registry('current_product');
27
+ $templateId = $helper->getTemplateIdFromCategory($_product->getCategoryIds());
28
+ if ($templateId == '') {
29
+ $templateId = Mage::getStoreConfig('clipvilla/custom_data/default_template');
30
+ }
31
+
32
+ $productTemplateId = $_product->getClipvillaTemplate();
33
+ if (empty($productTemplateId)) {
34
+ $templateName = $helper->getTemplateName($templateId);
35
+ } else {
36
+ $templateName = $helper->getTemplateName($productTemplateId);
37
+ }
38
+
39
+ $form = $observer->getEvent()->getForm();
40
+ foreach ($form->getElements() as $element) {
41
+ // ID is different in each attribute set
42
+ if ($element->getLegend() == 'ClipVilla Video Producer') {
43
+ $element->setLegend('Active ClipVilla - Template: ' . $templateName);
44
+ }
45
+ }
46
+ }
47
+
48
+ /**
49
+ * adds the render Video and Delete Video Buttons to the product edit page
50
+ */
51
+ public function addCustomButtons()
52
+ {
53
+ if (Mage::getStoreConfig('clipvilla/configuration/activate')) {
54
+ $productId = Mage::app()->getRequest()->getParam('id');
55
+ $existingVideo = Mage::getModel('clipvilla_mori/videos')->load($productId, 'product_id');
56
+
57
+ $this->addButton(
58
+ 'Render Video', 'If the Product has not been saved, rendering will not start!',
59
+ 'save_button', 'render', 'save'
60
+ );
61
+
62
+ if ($existingVideo->getStatus() == ClipVilla_MorI_Model_Videos::STATUS_EXISTS) {
63
+ $this->addButton('Delete Video', 'Are you sure?', 'delete_button', 'delete', 'delete');
64
+ }
65
+ }
66
+ }
67
+
68
+ /**
69
+ * adds custom Button to Product Edit Page
70
+ *
71
+ */
72
+ public function addButton($label, $message, $origButtonName, $action, $cssClass)
73
+ {
74
+ if (Mage::getStoreConfig('clipvilla/configuration/activate')) {
75
+
76
+ $layout = Mage::app()->getLayout();
77
+ $productEditBlock = $layout->getBlock('product_edit');
78
+ $origButton = $productEditBlock->getChild($origButtonName);
79
+
80
+ // New Custom Button
81
+ $newButton = $layout->createBlock('adminhtml/widget_button');
82
+ $newButton->setLabel(Mage::helper('clipvilla_mori')->__($label));
83
+ $newButton->setClass($cssClass);
84
+ if ($cssClass == 'delete') {
85
+ // prompts Javascript Message
86
+ $newButton->setOnClick(
87
+ 'confirmSetLocation(\'' . Mage::helper('clipvilla_mori')->__($message) . '\', \''
88
+ . $this->getButtonUrl($action) . '\')'
89
+ );
90
+ } else {
91
+ // simple link
92
+ $newButton->setOnClick('setLocation(\'' . $this->getButtonUrl($action) . '\')');
93
+ }
94
+
95
+ $container = $layout->createBlock('core/text_list', 'button_container.' . $action);
96
+ $container->append($newButton);
97
+ $container->append($origButton);
98
+ $productEditBlock->setChild($origButtonName, $container);
99
+ }
100
+ }
101
+
102
+ /**
103
+ * Retrieve the URL for button click
104
+ *
105
+ * @return string
106
+ */
107
+ public function getButtonUrl($action)
108
+ {
109
+ return Mage::getModel('adminhtml/url')->getUrl(
110
+ '*/video/' . $action, array(
111
+ '_current' => true,
112
+ 'back' => 'edit',
113
+ 'tab' => '{{tab_id}}',
114
+ 'active_tab' => null
115
+ )
116
+ );
117
+ }
118
+
119
+ }
app/code/community/ClipVilla/MorI/Model/Observer/VideoData.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Model_Observer_VideoData
15
+ {
16
+
17
+ /**
18
+ * saves Video Parameters in clipvilla_videos table
19
+ *
20
+ * @param Varien_Event_Observer $observer
21
+ */
22
+ public function saveValues(Varien_Event_Observer $observer)
23
+ {
24
+ if (Mage::getStoreConfig('clipvilla/configuration/activate')) {
25
+ $product = $observer->getProduct();
26
+ $helper = Mage::helper('clipvilla_mori');
27
+ $existingVideo = Mage::getModel('clipvilla_mori/videos')->getCollection()
28
+ ->addFieldToFilter('product_id', $product->getId())
29
+ ->getFirstItem();
30
+
31
+ if ($existingVideo->getProductId()) {
32
+ $video = $existingVideo;
33
+ } else {
34
+ $video = Mage::getModel('clipvilla_mori/videos');
35
+ }
36
+
37
+ // sets RenderProjectId
38
+ $templateId = $product->getClipvillaTemplate();
39
+ if ($templateId == '') {
40
+ $templateId = $helper->getTemplateIdFromCategory($product->getCategoryIds());
41
+ if ($templateId == '') {
42
+ $templateId = Mage::getStoreConfig('clipvilla/custom_data/default_template');
43
+ }
44
+ }
45
+
46
+ $this->setProductUsps($product);
47
+ $images = $product->getData('media_gallery');
48
+ $images = $images['images'];
49
+ $images = $helper->getImageFiles($images);
50
+
51
+
52
+ if ($video->needUpdate($product, $images) || $video->getProductId() == '') {
53
+ $mapping = Mage::helper('clipvilla_mori/path')->getMappingXml();
54
+ $video->setProductId($product->getId());
55
+ $video->setRenderProjectId($templateId);
56
+
57
+ foreach ($mapping as $map) {
58
+ if ($map->renderProjectId == $video->getRenderProjectId()) {
59
+ $video->setImages($images, $map, $product);
60
+ foreach ($map->textDZs as $textDz) {
61
+ foreach ($textDz as $param) {
62
+ $videoMethod = 'set' . $param->name;
63
+ $productMethod = 'getClipvilla' . $param->name;
64
+ $video->$videoMethod($product->$productMethod());
65
+ }
66
+ }
67
+ }
68
+ }
69
+ $video->setStatus(ClipVilla_MorI_Model_Videos::STATUS_EXISTS_NOT);
70
+ $existingVideo->setCreationDate(null);
71
+ $video->save();
72
+ }
73
+ $this->unsetProductUsps($product);
74
+ Mage::unregister('usps');
75
+ }
76
+ }
77
+
78
+ /**
79
+ * only used to check the Product USPs in needUpdate
80
+ *
81
+ * @param $product
82
+ */
83
+ protected function setProductUsps($product)
84
+ {
85
+ $helper = Mage::helper('clipvilla_mori');
86
+ $usps = Mage::registry('usps');
87
+ $i = 1;
88
+
89
+ if ($usps != '') {
90
+ foreach ($usps as $usp) {
91
+ $method = 'setClipvillaUsp' . $helper->numberConverter($i);
92
+ if ($usp == '') {
93
+ $usp = Mage::getStoreConfig('clipvilla/custom_data/usp_' . strtolower($helper->numberConverter($i)));
94
+ }
95
+ $product->$method($usp);
96
+ $i++;
97
+ }
98
+ }
99
+ }
100
+
101
+ /**
102
+ * unsets the product usps if they are the same with the usps in config
103
+ *
104
+ * @param $product
105
+ */
106
+ protected function unsetProductUsps($product)
107
+ {
108
+ $helper = Mage::helper('clipvilla_mori');
109
+ $usps = Mage::registry('usps');
110
+ $i = 1;
111
+
112
+ if ($usps != '') {
113
+ foreach ($usps as $usp) {
114
+ $method = 'setClipvillaUsp' . $helper->numberConverter($i);
115
+ if ($usp == Mage::getStoreConfig('clipvilla/custom_data/usp_' . strtolower($helper->numberConverter($i)))) {
116
+ $product->$method('');
117
+ }
118
+ $i++;
119
+ }
120
+ }
121
+ }
122
+
123
+ /*
124
+ * Deletes table entries and the corresponding video on product-delete
125
+ *
126
+ */
127
+ public function deleteAll(Varien_Event_Observer $observer)
128
+ {
129
+ $path = Mage::helper('clipvilla_mori/path');
130
+ $product = $observer->getProduct();
131
+ $video = Mage::getModel('clipvilla_mori/videos')->load($product->getId(), 'product_id');
132
+ $stack = Mage::getModel('clipvilla_mori/stack')->load($video->getVideoId(), 'video_id');
133
+ $file = $path->getVideoFile($product->getId());
134
+ if (file_exists($file)) {
135
+ unlink($file);
136
+ }
137
+ $video->delete();
138
+ $stack->delete();
139
+
140
+ // sets index "update required" to no -> Column is displayed Green in Backend
141
+ $index = Mage::getSingleton('index/indexer')
142
+ ->getProcessByCode('clipvilla_indexer');
143
+ $indexEvent = Mage::getModel('index/event')->getCollection()
144
+ ->addFieldToSelect('event_id')
145
+ ->addFieldToFilter('entity_pk', $product->getId())
146
+ ->addFieldToFilter('type', 'delete')
147
+ ->getFirstItem();
148
+ $indexProcessEvent = Mage::getResourceModel('index/process');
149
+ $indexProcessEvent->updateEventStatus(
150
+ $index->getId(), $indexEvent->getId(), Mage_Index_Model_Process::EVENT_STATUS_DONE
151
+ );
152
+ }
153
+
154
+ }
app/code/community/ClipVilla/MorI/Model/Resource/Stack.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Model_Resource_Stack extends Mage_Core_Model_Resource_Db_Abstract
15
+ {
16
+
17
+ protected function _construct()
18
+ {
19
+ $this->_init('clipvilla_mori/stack', 'stack_id');
20
+ }
21
+
22
+ }
app/code/community/ClipVilla/MorI/Model/Resource/Stack/Collection.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+
15
+ class ClipVilla_MorI_Model_Resource_Stack_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
16
+ {
17
+
18
+ public function _construct()
19
+ {
20
+ $this->_init('clipvilla_mori/stack');
21
+ }
22
+
23
+ }
app/code/community/ClipVilla/MorI/Model/Resource/Videos.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Model_Resource_Videos extends Mage_Core_Model_Resource_Db_Abstract
15
+ {
16
+
17
+ protected function _construct()
18
+ {
19
+ $this->_init('clipvilla_mori/videos', 'video_id');
20
+ }
21
+
22
+ }
app/code/community/ClipVilla/MorI/Model/Resource/Videos/Collection.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+
15
+ class ClipVilla_MorI_Model_Resource_Videos_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
16
+ {
17
+
18
+ public function _construct()
19
+ {
20
+ $this->_init('clipvilla_mori/videos');
21
+ }
22
+
23
+
24
+
25
+ }
app/code/community/ClipVilla/MorI/Model/Sitemap/Video.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Model_Sitemap_Video extends Mage_Core_Model_Abstract
15
+ {
16
+ const XMLNS = 'http://www.sitemaps.org/schemas/sitemap/0.9';
17
+ const XMLNS_VIDEO = 'http://www.google.com/schemas/sitemap-video/1.1';
18
+
19
+ private $path;
20
+ private $filePath;
21
+
22
+ public function _construct()
23
+ {
24
+ $this->path = Mage::helper('clipvilla_mori/path');
25
+ $this->filePath = $this->path->getSitemapVideo();
26
+ }
27
+
28
+ /**
29
+ * generates an xml-video-sitemap
30
+ *
31
+ * @return mixed
32
+ */
33
+ public function createSitemap()
34
+ {
35
+ $collection = Mage::getModel('catalog/product')->getCollection()
36
+ ->addAttributeToSelect('meta_title')
37
+ ->addAttributeToSelect('meta_description')
38
+ ->addAttributeToSelect('name')
39
+ ->addAttributeToSelect('short_description');
40
+ $collection->getSelect()->joinLeft(
41
+ array('video' => "clipvilla_videos"),
42
+ "e.entity_id = video.product_id",
43
+ array('video.status', 'video.creation_date', 'image_one', 'render_project_id')
44
+ );
45
+ $collection->getSelect()->where('video.status = 1');
46
+
47
+ #echo $collection->getSelect()->__toString();die();
48
+
49
+ $xml = new SimpleXMLElement('<urlset xmlns="' . self::XMLNS . '" xmlns:video="' . self::XMLNS_VIDEO . '" />');
50
+ foreach ($collection as $item) {
51
+ Mage::app()->setCurrentStore(1);
52
+ $xml = $this->addVideo($xml, $item);
53
+ }
54
+
55
+ try {
56
+ $xml->asXML($this->filePath); // save
57
+ } catch (Exception $e) {
58
+ Mage::log($e, null, 'clipvilla.log', true);
59
+ return;
60
+ }
61
+ return $this->filePath;
62
+ }
63
+
64
+ /**
65
+ * adds an video entry to the video-sitemap
66
+ *
67
+ * @param $xml
68
+ * @param $item
69
+ *
70
+ * @return mixed
71
+ */
72
+ public function addVideo($xml, $item)
73
+ {
74
+ $duration = Mage::helper('clipvilla_mori')->getVideoDuration($item->getRenderProjectId());
75
+
76
+ $date = Mage::getModel('core/date')->timestamp(strtotime($item->getCreationDate()));
77
+ $date = date('Y-m-d', $date);
78
+
79
+ $metaDescription = $item->getMetaDescription();
80
+ if (empty($metaDescription)) {
81
+ $metaDescription = $item->getShortDescription();
82
+ }
83
+ $metaTitle = $item->getMetaTitle();
84
+ if (empty($metaTitle)) {
85
+ $metaTitle = $item->getName();
86
+ }
87
+ $ImageUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB).'media' . DS . 'catalog' . DS . 'product' . $item->getImageOne();
88
+ $videoUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB).'media' . DS . 'clipvilla' . DS . 'videos' . DS . $item->getId() . '.mp4';
89
+
90
+ $urlNode = $xml->addChild('url');
91
+ $urlNode->addChild('loc', $item->getProductUrl());
92
+ // required Params
93
+ $videoNode = $urlNode->addChild('video','', self::XMLNS_VIDEO);
94
+ $videoNode->addChild('thumbnail_loc', $ImageUrl, self::XMLNS_VIDEO);
95
+ $videoNode->addChild('title', $metaTitle, self::XMLNS_VIDEO);
96
+ $videoNode->addChild('description', $metaDescription, self::XMLNS_VIDEO);
97
+ $videoNode->addChild('content_loc', $videoUrl, self::XMLNS_VIDEO);
98
+ // optional Params
99
+ $videoNode->addChild('duration', $duration, self::XMLNS_VIDEO);
100
+ $videoNode->addChild('publication_date', $date, self::XMLNS_VIDEO);
101
+ $videoNode->addChild('family_friendly', 'yes', self::XMLNS_VIDEO);
102
+
103
+ return $xml;
104
+ }
105
+
106
+ }
app/code/community/ClipVilla/MorI/Model/Stack.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Model_Stack extends Mage_Core_Model_Abstract
15
+ {
16
+
17
+ const STATUS_QUEUE = 0;
18
+ const STATUS_DOWNLOAD = 1;
19
+ const STATUS_RENDERING = 2;
20
+
21
+ protected function _construct()
22
+ {
23
+ $this->_init('clipvilla_mori/stack');
24
+ }
25
+
26
+ /**
27
+ * inserts entry into clipvilla_stack with priority 1 and deletes
28
+ * the same entry if already in the table with (status must be 0)
29
+ *
30
+ * @param $videoId
31
+ */
32
+ public function prioritizeVideo($videoId)
33
+ {
34
+ $existingStackItem = Mage::getModel('clipvilla_mori/stack')->getCollection()
35
+ ->addFieldToFilter('video_id', $videoId)
36
+ ->getFirstItem();
37
+ $stackData = $existingStackItem->getData();
38
+ if (!empty($stackData)) {
39
+ if ($existingStackItem->getStatus() == self::STATUS_QUEUE) {
40
+ $existingStackItem->delete();
41
+ }
42
+ }
43
+
44
+ $insertData = array(
45
+ 'video_id' => $videoId,
46
+ 'priority' => 1,
47
+ 'status' => self::STATUS_QUEUE,
48
+ );
49
+ $this->setData($insertData);
50
+ $this->save();
51
+
52
+ }
53
+
54
+ }
app/code/community/ClipVilla/MorI/Model/System/Attribute/Source/Provider.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Model_System_Attribute_Source_Provider extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
15
+ {
16
+ protected $_options = null;
17
+
18
+ /**
19
+ * returns the options for template select in category
20
+ *
21
+ * @param bool $withEmpty
22
+ *
23
+ * @return array|null
24
+ */
25
+ public function getAllOptions($withEmpty = false)
26
+ {
27
+ if (is_null($this->_options)) {
28
+ $this->_options = array();
29
+ $mapping = Mage::helper('clipvilla_mori/path')->getMappingXml();
30
+ foreach ($mapping->mapping as $map) {
31
+ $this->_options[] = array(
32
+ 'value' => $map->renderProjectId,
33
+ 'label' => $map->templateName
34
+ );
35
+ }
36
+ }
37
+ $options = $this->_options;
38
+ if ($withEmpty) {
39
+ array_unshift($options, array('value' => '', 'label' => ''));
40
+ }
41
+ return $options;
42
+ }
43
+
44
+ /**
45
+ * returns the label for the options (template id -> template name)
46
+ *
47
+ * @param int|string $value
48
+ *
49
+ * @return bool|string
50
+ */
51
+ public function getOptionText($value)
52
+ {
53
+ $options = $this->getAllOptions(false);
54
+
55
+ foreach ($options as $item) {
56
+ if ($item['value'] == $value) {
57
+ return $item['label'];
58
+ }
59
+ }
60
+ return false;
61
+ }
62
+
63
+ public function getFlatColums()
64
+ {
65
+ $attributeCode = $this->getAttribute()->getAttributeCode();
66
+ $column = array(
67
+ 'unsigned' => false,
68
+ 'default' => null,
69
+ 'extra' => null
70
+ );
71
+
72
+ if (Mage::helper('core')->useDbCompatibleMode()) {
73
+ $column['type'] = 'int(10)';
74
+ $column['is_null'] = true;
75
+ } else {
76
+ $column['type'] = Varien_Db_Ddl_Table::TYPE_SMALLINT;
77
+ $column['length'] = 10;
78
+ $column['nullable'] = true;
79
+ $column['comment'] = $attributeCode . ' column';
80
+ }
81
+
82
+ return array($attributeCode => $column);
83
+ }
84
+
85
+ public function getFlatUpdateSelect($store)
86
+ {
87
+ return Mage::getResourceModel('eav/entity_attribute')->getFlatUpdateSelect($this->getAttribute(), $store);
88
+ }
89
+ }
app/code/community/ClipVilla/MorI/Model/System/Config/Source/TemplateSelect.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Model_System_Config_Source_TemplateSelect
15
+ {
16
+
17
+ /**
18
+ * returns the options for the template select in module configuration
19
+ *
20
+ * @return array
21
+ */
22
+ public function toOptionArray()
23
+ {
24
+ $options = array();
25
+ $mapping = Mage::helper('clipvilla_mori/path')->getMappingXml();
26
+ foreach ($mapping->mapping as $map) {
27
+ $options[] = array(
28
+ 'value' => $map->renderProjectId,
29
+ 'label' => $map->templateName
30
+ );
31
+ }
32
+
33
+ return $options;
34
+ }
35
+
36
+ }
app/code/community/ClipVilla/MorI/Model/VideoCron.php ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Model_VideoCron extends Mage_Core_Model_Abstract
15
+ {
16
+
17
+ /**
18
+ * Generate a Video-Sitemap every Night
19
+ * The previous Version gets overriden
20
+ */
21
+ public function generateVideoSitemap()
22
+ {
23
+ Mage::getModel('clipvilla_mori/sitemap_video')->createSitemap();
24
+ }
25
+
26
+
27
+ /**
28
+ * Generate a Video with every neccesary step:
29
+ * 1. Starts rendering
30
+ * 2. Checks rendering Status
31
+ * 3. Video download
32
+ */
33
+ public function generateVideo()
34
+ {
35
+ if (Mage::getStoreConfig('clipvilla/configuration/activate')) {
36
+ $path = Mage::helper('clipvilla_mori/path');
37
+
38
+ // Return stack entity that has already been sent to rendering
39
+ $stack = Mage::getModel('clipvilla_mori/stack')
40
+ ->load(ClipVilla_MorI_Model_Stack::STATUS_RENDERING, 'status');
41
+
42
+ // If for no Entity the rendering process has been started, returns first entity sorted by priority
43
+ $isRendering = $stack->getData();
44
+ if (empty($isRendering)) {
45
+ $stack = Mage::getModel('clipvilla_mori/stack')->getCollection()
46
+ ->setOrder('priority', 'DESC')
47
+ ->getFirstItem();
48
+ }
49
+
50
+ // Returns corresponding Video Data to the stack entity
51
+ $existingVideo = Mage::getModel('clipvilla_mori/videos')->load($stack->getVideoId(), 'video_id');
52
+ $existingVideoData = $existingVideo->getData();
53
+
54
+ if (!empty($existingVideoData)) {
55
+ $file = Mage::getModel('clipvilla_mori/file');
56
+ $mori = Mage::getModel('clipvilla_mori/executer_mori');
57
+ $productId = $existingVideo->getProductId();
58
+ $shopVideoFile = $path->getVideoFile($productId);
59
+
60
+ // resets Entry after 30 status requests if it gets Stuck
61
+ $renderingCount = Mage::getStoreConfig('clipvilla/rendering/reset');
62
+ if ($renderingCount == 30) {
63
+ $stack->setStatus(ClipVilla_MorI_Model_Stack::STATUS_QUEUE);
64
+ Mage::getModel('core/config')->saveConfig('clipvilla/rendering/reset', 0);
65
+ }
66
+
67
+ // 1. Starts Rendering
68
+ if ($stack->getStatus() == ClipVilla_MorI_Model_Stack::STATUS_QUEUE) {
69
+ try {
70
+ $soapVar = $existingVideo->getSoapVar($existingVideo->getRenderProjectId());
71
+ $renderId = $mori->startRendering($soapVar);
72
+
73
+ // Rendering Error (API returns error)
74
+ if (!is_int($renderId)) {
75
+ $errorMessage = substr($renderId, 0, 450);
76
+ Mage::log($errorMessage, null, 'clipvilla.log', true);
77
+ Mage::getModel('clipvilla_mori/mail')->sendErrorMail($productId, $errorMessage);
78
+ if ($renderId == 'License key invalid') {
79
+ $existingVideo->setStatus(3)->save();
80
+ } elseif('License key capacity exceeded') {
81
+ $existingVideo->setStatus(4)->save();
82
+ } else {
83
+ $existingVideo->setStatus(2)->save();
84
+ }
85
+ $stack->delete();
86
+ Mage::getModel('core/config')->saveConfig('clipvilla/rendering/reset', 0);
87
+
88
+ return;
89
+ }
90
+
91
+ $stack->setRenderId($renderId);
92
+ $stack->setStatus(ClipVilla_MorI_Model_Stack::STATUS_RENDERING);
93
+ $stack->save();
94
+
95
+ // Sonstige Fehler
96
+ } catch (Exception $e) {
97
+ $errorMessage = 'Rendering Failed';
98
+ Mage::log($e, null, 'clipvilla.log', true);
99
+ Mage::getModel('clipvilla_mori/mail')->sendErrorMail($productId, $errorMessage);
100
+ $existingVideo->setStatus(2)->save();
101
+ $stack->delete();
102
+ Mage::getModel('core/config')->saveConfig('clipvilla/rendering/reset', 0);
103
+
104
+ return;
105
+ }
106
+ return;
107
+ }
108
+
109
+ // 2. Checks the Status of the rendering process
110
+ $renderingStatus = '';
111
+ if ($stack->getStatus() == ClipVilla_MorI_Model_Stack::STATUS_RENDERING) {
112
+ try {
113
+ $renderingCount++;
114
+ Mage::getModel('core/config')->saveConfig('clipvilla/rendering/reset', $renderingCount);
115
+ $response = $mori->getStatus($stack->getRenderId());
116
+ $renderingStatus = $response->status;
117
+ if ($renderingStatus == 'Job Complete') {
118
+ $downloadUrl = $response->movieUrl;
119
+ }
120
+
121
+ // Fehler bei der Statusabfrage
122
+ } catch (Exception $e) {
123
+ $errorMessage = 'Failed to get Status';
124
+ Mage::log($e, null, 'clipvilla.log', true);
125
+ Mage::getModel('clipvilla_mori/mail')->sendErrorMail($productId, $errorMessage);
126
+ $existingVideo->setStatus(2)->save();
127
+ $stack->delete();
128
+ Mage::getModel('core/config')->saveConfig('clipvilla/rendering/reset', 0);
129
+
130
+ return;
131
+ }
132
+ }
133
+
134
+ //3. video download
135
+ if ($renderingStatus == 'Job Complete') {
136
+ try {
137
+ $stack->setStatus(ClipVilla_MorI_Model_Stack::STATUS_DOWNLOAD);
138
+ $stack->save();
139
+
140
+ $errorMessage = $file->downloadMovieFile($downloadUrl, $shopVideoFile);
141
+ if (!empty($errorMessage)) {
142
+ Mage::log(substr($errorMessage, 0, 450), null, 'clipvilla.log', true);
143
+ Mage::getModel('clipvilla_mori/mail')->sendErrorMail($productId, $errorMessage);
144
+ $existingVideo->setStatus(2)->save();
145
+ $stack->delete();
146
+ Mage::getModel('core/config')->saveConfig('clipvilla/rendering/reset', 0);
147
+
148
+ return;
149
+ }
150
+ } catch (Exception $e) {
151
+ $errorMessage = 'Videodownload Failed.';
152
+ Mage::getModel('clipvilla_mori/mail')->sendErrorMail($productId, $errorMessage);
153
+ $existingVideo->setStatus(2)->save();
154
+ $stack->delete();
155
+ Mage::getModel('core/config')->saveConfig('clipvilla/rendering/reset', 0);
156
+
157
+ return;
158
+ }
159
+ Mage::getModel('core/config')->saveConfig('clipvilla/rendering/reset', 0);
160
+ $existingVideo->setStatus(ClipVilla_MorI_Model_Videos::STATUS_EXISTS);
161
+ $existingVideo->setCreationDate(Mage::getModel('core/date')->date('Y-m-d H:i:s'));
162
+ $existingVideo->save();
163
+
164
+ //4. garbage collection
165
+ $stack->delete();
166
+
167
+ }
168
+ }
169
+ }
170
+ }
171
+ }
app/code/community/ClipVilla/MorI/Model/Videos.php ADDED
@@ -0,0 +1,331 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Model_Videos extends Mage_Core_Model_Abstract
15
+ {
16
+
17
+ const STATUS_EXISTS_NOT = 0;
18
+ const STATUS_EXISTS = 1;
19
+ const STATUS_ERROR = 2;
20
+ const STATUS_LICENSE = 3;
21
+ const STATUS_CAPACITY = 4;
22
+ const USPONE = 'setUspOne';
23
+ const USPTWO = 'setUspTwo';
24
+ const USPTHREE = 'setUspThree';
25
+ const NAME = 'setName';
26
+ public $defaultTemplateId;
27
+
28
+ protected function _construct()
29
+ {
30
+ $this->defaultTemplateId = Mage::getStoreConfig('clipvilla/custom_data/default_template');
31
+ $this->_init('clipvilla_mori/videos');
32
+ }
33
+
34
+ /**
35
+ * Checks if video relevant data has been changed
36
+ *
37
+ * @param $product
38
+ * @param $images
39
+ *
40
+ * @return bool
41
+ */
42
+ public function needUpdate($product, $images)
43
+ {
44
+ $mapping = Mage::helper('clipvilla_mori/path')->getMappingXml();
45
+ foreach ($mapping as $map) {
46
+ if ($map->renderProjectId == $this->getRenderProjectId()) {
47
+ foreach ($map->textDZs as $textDz) {
48
+ foreach ($textDz as $param) {
49
+ $videoMethod = 'get' . (String)$param->name;
50
+ $productMethod = 'getClipvilla' . (String)$param->name;
51
+ if ($product->$productMethod() != $this->$videoMethod()) {
52
+ return true;
53
+ }
54
+ }
55
+ }
56
+
57
+ $imgCount = 0;
58
+ foreach ($map->imageDZs as $imgDz) {
59
+ foreach ($imgDz as $param) {
60
+ $videoMethod = 'get' . (String)$param->name;
61
+ if ($images[$imgCount] != $this->$videoMethod()) {
62
+ return true;
63
+ }
64
+ $imgCount++;
65
+ if ($imgCount === count($images)) {
66
+ $imgCount = 0;
67
+ }
68
+ }
69
+ }
70
+ }
71
+ }
72
+
73
+ // sets RenderProjectId
74
+ $templateId = $product->getClipvillaTemplate();
75
+ if ($templateId == '') {
76
+ $templateId = Mage::helper('clipvilla_mori')->getTemplateIdFromCategory($product->getCategoryIds());
77
+ if ($templateId == '') {
78
+ $templateId = Mage::getStoreConfig('clipvilla/custom_data/default_template');
79
+ }
80
+ }
81
+
82
+ if ($templateId != $this->getRenderProjectId()) {
83
+ return true;
84
+ }
85
+
86
+ return false;
87
+ }
88
+
89
+ /**
90
+ * Checks if the Product Attribute has been set and uses it if its set
91
+ * if Product Attribute is not set the configuration Value is used
92
+ *
93
+ * @param $configAttribute
94
+ * @param $productAttribute
95
+ * @param $method
96
+ */
97
+ public function setVideoAttribute($configAttribute, $productAttribute, $method)
98
+ {
99
+ if (empty($productAttribute)) {
100
+ $this->$method($configAttribute);
101
+ } else {
102
+ $this->$method($productAttribute);
103
+ }
104
+ }
105
+
106
+ /**
107
+ * Sets Images for Video
108
+ *
109
+ * @param $video
110
+ *
111
+ * @return mixed
112
+ */
113
+ public function setImages($images, $mapping, $product)
114
+ {
115
+ try {
116
+ $imgCount = 0;
117
+ foreach ($mapping->imageDZs as $imgDz) {
118
+ foreach ($imgDz as $param) {
119
+ $method = 'set' . (String)$param->name;
120
+ if (empty($images)) {
121
+ $this->$method('');
122
+ } else {
123
+ $this->$method($images[$imgCount]);
124
+ $imgCount++;
125
+ if ($imgCount === count($images)) {
126
+ $imgCount = 0;
127
+ }
128
+ }
129
+ }
130
+ }
131
+ } catch (Exception $e) {
132
+ return;
133
+ }
134
+ return $this;
135
+ }
136
+
137
+ /**
138
+ * returns multidimensional Text-Arrays corresponding to mapping
139
+ *
140
+ * @param $mapping
141
+ *
142
+ * @return array
143
+ */
144
+ public function getTextDZs($mapping)
145
+ {
146
+ $text = array();
147
+ foreach ($mapping as $map) {
148
+ if ($map->renderProjectId == $this->getRenderProjectId()) {
149
+ foreach ($map->textDZs as $textDz) {
150
+ foreach ($textDz as $param) {
151
+ $method = 'get' . (String)$param->name;
152
+ $text[] = array(
153
+ 'text' => $this->$method(),
154
+ 'dropZoneName' => 'dz' . (String)$param->dz
155
+ );
156
+ }
157
+ }
158
+ }
159
+ }
160
+ return $text;
161
+ }
162
+
163
+ /**
164
+ * returns multidimensional Img-Arrays corresponding to mapping
165
+ *
166
+ * @param $mapping
167
+ * @param $path
168
+ *
169
+ * @return array
170
+ */
171
+ public function getImgDZs($mapping)
172
+ {
173
+ $path = Mage::helper('clipvilla_mori/path');
174
+ $img = array();
175
+ foreach ($mapping as $map) {
176
+ if ($map->renderProjectId == $this->getRenderProjectId()) {
177
+ foreach ($map->imageDZs as $imgDz) {
178
+ foreach ($imgDz as $param) {
179
+ $method = 'get' . (String)$param->name;
180
+ $imgFile = $this->$method();
181
+ $img[] = array(
182
+ 'dropZoneName' => 'dz' . (String)$param->dz,
183
+ 'renderImageType' => 'OTHER',
184
+ 'fileName' => basename($imgFile),
185
+ 'imageData' => file_get_contents($path->getProductImageDir($imgFile))
186
+ );
187
+ }
188
+ }
189
+ }
190
+ }
191
+ return $img;
192
+ }
193
+
194
+
195
+ /**
196
+ * Builds array for SOAP-Request
197
+ *
198
+ * @param $renderProjectId
199
+ *
200
+ * @return array
201
+ */
202
+ public function getSoapVar($renderProjectId)
203
+ {
204
+ $path = Mage::helper('clipvilla_mori/path');
205
+ $mapping = $path->getMappingXml();
206
+ $this->setShopName(Mage::getStoreConfig('clipvilla/custom_data/shop'));
207
+
208
+ $videoData = array(
209
+ 'RenderRequestMtom' => array(
210
+ 'renderProjectId' => $renderProjectId,
211
+ 'licenseKey' => Mage::getStoreConfig('clipvilla/configuration/license_key'),
212
+
213
+ 'renderTextList' => array(
214
+ 'renderText' => $this->getTextDZs($mapping)
215
+ ),
216
+ 'renderImageList' => array(
217
+ 'renderImageMtom' => $this->getImgDZs($mapping)
218
+ )
219
+ )
220
+ );
221
+
222
+ return $videoData;
223
+ }
224
+
225
+ /**
226
+ * Saves Video Data for all Products (must have at least 1 Image and be visible)
227
+ *
228
+ * @param string $productIds
229
+ */
230
+ public function saveForAllProducts($productIds = array())
231
+ {
232
+ $helper = Mage::helper('clipvilla_mori');
233
+ try {
234
+
235
+ $products = Mage::getModel('catalog/product')->getCollection()
236
+ ->addAttributeToSelect('*')
237
+ ->addFieldToFilter('visibility', array('neq' => 1));
238
+
239
+ if (!empty($productIds)) {
240
+ $products->addFieldToFilter('entity_id', $productIds);
241
+ }
242
+
243
+ $products->joinTable('clipvilla_mori/videos', 'product_id=entity_id', array(
244
+ 'videos_video_id' => 'video_id'
245
+ ), null, 'left'
246
+ )
247
+ ->joinTable('clipvilla_mori/stack', 'video_id=videos_video_id', array(
248
+ 'stack_id' => 'stack_id',
249
+ 'stack_status' => 'status'
250
+ ), null, 'left'
251
+ );
252
+
253
+ $configUspOne = Mage::getStoreConfig('clipvilla/custom_data/usp_one');
254
+ $configUspTwo = Mage::getStoreConfig('clipvilla/custom_data/usp_two');
255
+ $configUspThree = Mage::getStoreConfig('clipvilla/custom_data/usp_three');
256
+ $stack = Mage::getModel('clipvilla_mori/stack');
257
+
258
+ foreach ($products as $product) {
259
+ $product->getResource()->getAttribute('media_gallery')
260
+ ->getBackend()
261
+ ->afterLoad($product);
262
+ $images = $product->getData('media_gallery');
263
+ $images = $images['images'];
264
+ $images = $helper->getImageFiles($images);
265
+
266
+ if (!empty($images) && $product->getStackStatus() == ClipVilla_MorI_Model_Stack::STATUS_QUEUE) {
267
+ $productVideoId = $product->getVideosVideoId();
268
+ if ($productVideoId !== null) {
269
+ $this->setVideoId($productVideoId);
270
+ }
271
+ $this->setProductId($product->getEntityId());
272
+ $this->setStatus(self::STATUS_EXISTS_NOT);
273
+ $this->setCreationDate(null);
274
+
275
+ $mapping = Mage::helper('clipvilla_mori/path')->getMappingXml();
276
+ $this->setProductId($product->getId());
277
+
278
+ // sets RenderProjectId
279
+ $templateId = $product->getClipvillaTemplate();
280
+ if ($templateId == '') {
281
+ $templateId = $helper->getTemplateIdFromCategory($product->getCategoryIds());
282
+ if ($templateId == '') {
283
+ $templateId = Mage::getStoreConfig('clipvilla/custom_data/default_template');
284
+ }
285
+ }
286
+
287
+ $this->setRenderProjectId($templateId);
288
+ $this->setVideoAttribute(
289
+ $product->getName(), $product->getClipvillaName(),
290
+ self::NAME
291
+ );
292
+ $this->setVideoAttribute(
293
+ $configUspOne, $product->getClipvillaUspOne(),
294
+ self::USPONE
295
+ );
296
+ $this->setVideoAttribute(
297
+ $configUspTwo, $product->getClipvillaUspTwo(),
298
+ self::USPTWO
299
+ );
300
+ $this->setVideoAttribute(
301
+ $configUspThree, $product->getClipvillaUspThree(),
302
+ self::USPTHREE
303
+ );
304
+
305
+ foreach ($mapping as $map) {
306
+ if ($map->renderProjectId == $this->getRenderProjectId()) {
307
+ $this->setImages($images, $map, $product);
308
+ }
309
+ }
310
+
311
+ $this->save();
312
+
313
+ if ($product->getStackId() == null && $this->getImageOne() !== '') {
314
+ $stack->setVideoId($this->getVideoId());
315
+ $stack->setPriority(0);
316
+ $stack->setStatus(ClipVilla_MorI_Model_Stack::STATUS_QUEUE);
317
+ $stack->save();
318
+ }
319
+
320
+ $this->unsetData();
321
+ $stack->unsetData();
322
+
323
+ }
324
+ }
325
+
326
+ } catch (Exception $e) {
327
+ Mage::log($e, null, 'clipvilla.log', true);
328
+ }
329
+ }
330
+
331
+ }
app/code/community/ClipVilla/MorI/controllers/Adminhtml/ManageVideosController.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Adminhtml_ManageVideosController extends Mage_Adminhtml_Controller_Action
15
+ {
16
+ protected function _initAction()
17
+ {
18
+ $this->loadLayout()->_setActiveMenu("catalog/manageVideos")->_addBreadcrumb(Mage::helper("adminhtml")->__("Manage Videos"),Mage::helper("adminhtml")->__("Manage Videos"));
19
+ return $this;
20
+ }
21
+
22
+ public function indexAction()
23
+ {
24
+ $this->_title($this->__("Catalog"));
25
+ $this->_title($this->__("Manage Videos"));
26
+
27
+ $this->_initAction();
28
+ $this->renderLayout();
29
+ }
30
+
31
+ /**
32
+ * Deletes Videos
33
+ */
34
+ public function massDeleteAllAction()
35
+ {
36
+ $params = $this->getRequest()->getParams();
37
+
38
+ foreach ($params['video_ids'] as $videoId) {
39
+ $video = Mage::getModel('clipvilla_mori/videos')->load($videoId);
40
+ $productId = $video->getProductId();
41
+ $video->delete();
42
+ Mage::getModel('clipvilla_mori/stack')->load($videoId, 'video_id')->delete();
43
+ $file = Mage::helper('clipvilla_mori/path')->getVideoFile($productId);
44
+ if (file_exists($file)) {
45
+ unlink($file);
46
+ }
47
+ }
48
+ $this->_getSession()->addSuccess($this->__('Delete was successful.'));
49
+ $this->_redirect('*/manageVideos/index');
50
+ }
51
+
52
+ /**
53
+ * newAction = Download/create Video Sitemap - Button
54
+ *
55
+ */
56
+ public function newAction()
57
+ {
58
+ $sitemap = Mage::getModel('clipvilla_mori/sitemap_video')->createSitemap();
59
+ $fileName = 'sitemap_video.xml';
60
+ try {
61
+ $file = file_get_contents($sitemap);
62
+ $this->_prepareDownloadResponse($fileName, $file);
63
+ } catch (Exception $e) {
64
+ Mage::log($e, null, 'clipvilla.log', true);
65
+ $this->_getSession()->addSuccess($this->__('File could not be downloaded.'));
66
+ }
67
+ }
68
+
69
+ public function popupAction()
70
+ {
71
+ $this->loadLayout();
72
+ $this->renderLayout();
73
+ }
74
+ }
app/code/community/ClipVilla/MorI/controllers/Adminhtml/VideoController.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ class ClipVilla_MorI_Adminhtml_VideoController extends Mage_Adminhtml_Controller_Action
15
+ {
16
+
17
+ /**
18
+ * adds entry to rendering stack with priority 1
19
+ * video data needs to exists to add an entry to the rendering stack
20
+ * redirect to Product Edit
21
+ *
22
+ */
23
+ public function renderAction()
24
+ {
25
+ $productId = $this->getRequest()->getParam('id');
26
+ if (Mage::getStoreConfig('clipvilla/configuration/activate')) {
27
+
28
+ $existingVideo = Mage::getModel('clipvilla_mori/videos')->getCollection()
29
+ ->addFieldToFilter('product_id', $productId)
30
+ ->getFirstItem();
31
+
32
+ // Checks if the product has not excluded images
33
+ if ($existingVideo->getImageOne() !== '') {
34
+ $existingVideoData = $existingVideo->getData();
35
+
36
+ // Checks if the product needs to be saved
37
+ if (empty($existingVideoData)) {
38
+ $this->_getSession()->addError($this->__('The Product needs to be saved before rendering!'));
39
+ } else {
40
+ // add product to rendering stack with priority 1
41
+ Mage::getModel('clipvilla_mori/stack')->prioritizeVideo($existingVideo->getVideoId());
42
+ $existingVideo->setCreationDate(null)
43
+ ->setStatus(0)
44
+ ->save();
45
+ $this->_getSession()->addSuccess($this->__('Added to rendering queue'));
46
+ }
47
+ } else {
48
+ $this->_getSession()->addError(
49
+ $this->__('The Product needs at least one not excluded Image to render a video.')
50
+ );
51
+ }
52
+
53
+ }
54
+
55
+ // redirect to product edit page
56
+ $this->_redirect(
57
+ '*/catalog_product/edit', array(
58
+ 'id' => $productId,
59
+ '_current' => true
60
+ )
61
+ );
62
+ }
63
+
64
+ /**
65
+ * deletes the videos and the video data in clipvilla_videos/ clipvilla_stack tables
66
+ */
67
+ public function deleteAction()
68
+ {
69
+ $productId = $this->getRequest()->getParam('id');
70
+ $product = Mage::getModel('catalog/product')->load($productId);
71
+ $video = Mage::getModel('clipvilla_mori/videos')->load($productId, 'product_id');
72
+ $stack = Mage::getModel('clipvilla_mori/stack')->load($video->getVideoId(), 'video_id');
73
+ $file = Mage::helper('clipvilla_mori/path')->getVideoFile($product->getId());
74
+ if (file_exists($file)) {
75
+ unlink($file);
76
+ }
77
+ $video->delete();
78
+ $stack->delete();
79
+
80
+ $this->_getSession()->addSuccess($this->__('The video has been deleted.'));
81
+
82
+ // redirect to product edit page
83
+ $this->_redirect(
84
+ '*/catalog_product/edit', array(
85
+ 'id' => $productId,
86
+ '_current' => true
87
+ )
88
+ );
89
+ }
90
+
91
+ /**
92
+ * adds the product data in the clipvilla_videos/ clipvilla_stack tables
93
+ * only on visibly products and products that meet the requirements (has Images etc.)
94
+ */
95
+ public function massSaveAllAction()
96
+ {
97
+ $params = $this->getRequest()->getParams();
98
+ $productIds = $params['product'];
99
+ Mage::getModel('clipvilla_mori/videos')->saveForAllProducts($productIds);
100
+ $this->_getSession()->addSuccess($this->__('Products have been added to rendering queue.'));
101
+
102
+ $this->_redirect('*/catalog_product/index');
103
+ }
104
+
105
+ }
app/code/community/ClipVilla/MorI/etc/adminhtml.xml ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ *ClipVilla Video Producer
5
+ *
6
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
7
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
8
+ *
9
+ * NOTICE OF LICENSE
10
+ *
11
+ * This source file is subject to the GNU General Public License (GPLv3)
12
+ * It is available through the world-wide-web at this URL:
13
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
14
+ */
15
+ -->
16
+ <config>
17
+ <menu>
18
+ <catalog>
19
+ <children>
20
+ <clipvilla_mori translate="title" module="clipvilla_mori">
21
+ <sort_order>15</sort_order>
22
+ <title>Manage Videos</title>
23
+ <action>adminhtml/manageVideos/</action>
24
+ </clipvilla_mori>
25
+ </children>
26
+ </catalog>
27
+ </menu>
28
+ <acl>
29
+ <resources>
30
+ <all>
31
+ <title>Allow Everything</title>
32
+ </all>
33
+ <admin>
34
+ <children>
35
+ <catalog>
36
+ <children>
37
+ <clipvilla_mori>
38
+ <title>Manage Videos</title>
39
+ </clipvilla_mori>
40
+ </children>
41
+ </catalog>
42
+ <system>
43
+ <children>
44
+ <config>
45
+ <children>
46
+ <clipvilla>
47
+ <title>ClipVilla</title>
48
+ </clipvilla>
49
+ </children>
50
+ </config>
51
+ </children>
52
+ </system>
53
+ </children>
54
+ </admin>
55
+ </resources>
56
+ </acl>
57
+ </config>
app/code/community/ClipVilla/MorI/etc/config.xml ADDED
@@ -0,0 +1,219 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ *ClipVilla Video Producer
5
+ *
6
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
7
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
8
+ *
9
+ * NOTICE OF LICENSE
10
+ *
11
+ * This source file is subject to the GNU General Public License (GPLv3)
12
+ * It is available through the world-wide-web at this URL:
13
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
14
+ */
15
+ -->
16
+ <config>
17
+ <modules>
18
+ <ClipVilla_MorI>
19
+ <version>1.0.0</version>
20
+ </ClipVilla_MorI>
21
+ </modules>
22
+ <global>
23
+ <models>
24
+ <clipvilla_mori>
25
+ <class>ClipVilla_MorI_Model</class>
26
+ <resourceModel>clipvilla_mori_resource</resourceModel>
27
+ </clipvilla_mori>
28
+ <clipvilla_mori_resource>
29
+ <class>ClipVilla_MorI_Model_Resource</class>
30
+ <entities>
31
+ <videos>
32
+ <table>clipvilla_videos</table>
33
+ </videos>
34
+ <stack>
35
+ <table>clipvilla_stack</table>
36
+ </stack>
37
+ </entities>
38
+ </clipvilla_mori_resource>
39
+ </models>
40
+ <blocks>
41
+ <clipvilla_mori>
42
+ <class>ClipVilla_MorI_Block</class>
43
+ </clipvilla_mori>
44
+ </blocks>
45
+ <helpers>
46
+ <clipvilla_mori>
47
+ <class>ClipVilla_MorI_Helper</class>
48
+ </clipvilla_mori>
49
+ </helpers>
50
+ <resources>
51
+ <clipvilla_mori_setup>
52
+ <setup>
53
+ <module>ClipVilla_MorI</module>
54
+ </setup>
55
+ </clipvilla_mori_setup>
56
+ </resources>
57
+ <events>
58
+ <controller_action_layout_render_before_adminhtml_catalog_product_edit>
59
+ <observers>
60
+ <clipvilla_mori_add_button>
61
+ <class>clipvilla_mori/observer_productEditForm</class>
62
+ <method>addCustomButtons</method>
63
+ </clipvilla_mori_add_button>
64
+ </observers>
65
+ </controller_action_layout_render_before_adminhtml_catalog_product_edit>
66
+ <adminhtml_catalog_product_edit_prepare_form>
67
+ <observers>
68
+ <clipvilla_mori_test>
69
+ <class>clipvilla_mori/observer_productEditForm</class>
70
+ <method>addTemplateName</method>
71
+ </clipvilla_mori_test>
72
+ </observers>
73
+ </adminhtml_catalog_product_edit_prepare_form>
74
+ <catalog_product_new_action>
75
+ <observers>
76
+ <clipvilla_mori_new_product>
77
+ <class>clipvilla_mori/observer_defaultValues</class>
78
+ <method>setDefaultValues</method>
79
+ </clipvilla_mori_new_product>
80
+ </observers>
81
+ </catalog_product_new_action>
82
+ <catalog_product_edit_action>
83
+ <observers>
84
+ <clipvilla_mori_set_fields>
85
+ <class>clipvilla_mori/observer_defaultValues</class>
86
+ <method>setDefaultValues</method>
87
+ </clipvilla_mori_set_fields>
88
+ </observers>
89
+ </catalog_product_edit_action>
90
+ <catalog_product_save_before>
91
+ <observers>
92
+ <clipvilla_mori_set_empty_fields>
93
+ <class>clipvilla_mori/observer_defaultValues</class>
94
+ <method>setEmptyAttributes</method>
95
+ </clipvilla_mori_set_empty_fields>
96
+ </observers>
97
+ </catalog_product_save_before>
98
+ <catalog_product_prepare_save>
99
+ <observers>
100
+ <clipvilla_mori_delete_fields>
101
+ <class>clipvilla_mori/observer_defaultValues</class>
102
+ <method>deleteValues</method>
103
+ </clipvilla_mori_delete_fields>
104
+ </observers>
105
+ </catalog_product_prepare_save>
106
+ <catalog_product_delete_after>
107
+ <observers>
108
+ <clipvilla_mori_delete_fields>
109
+ <class>clipvilla_mori/observer_videoData</class>
110
+ <method>deleteAll</method>
111
+ </clipvilla_mori_delete_fields>
112
+ </observers>
113
+ </catalog_product_delete_after>
114
+ <catalog_product_save_after>
115
+ <observers>
116
+ <clipvilla_mori_save_fields>
117
+ <class>clipvilla_mori/observer_videoData</class>
118
+ <method>saveValues</method>
119
+ </clipvilla_mori_save_fields>
120
+ </observers>
121
+ </catalog_product_save_after>
122
+ </events>
123
+ <index>
124
+ <indexer>
125
+ <clipvilla_indexer>
126
+ <model>clipvilla_mori/indexer</model>
127
+ </clipvilla_indexer>
128
+ </indexer>
129
+ </index>
130
+ <template>
131
+ <email>
132
+ <clipvilla_mail>
133
+ <label>ClipVilla Error Email</label>
134
+ <file>clipvilla.html</file>
135
+ <type>html</type>
136
+ </clipvilla_mail>
137
+ </email>
138
+ </template>
139
+ </global>
140
+ <frontend>
141
+ <layout>
142
+ <updates>
143
+ <clipvilla_mori>
144
+ <file>clipvilla.xml</file>
145
+ </clipvilla_mori>
146
+ </updates>
147
+ </layout>
148
+ </frontend>
149
+ <default>
150
+ <clipvilla>
151
+ <configuration>
152
+ <video_folder>media/clipvilla/videos</video_folder>
153
+ </configuration>
154
+ <custom_data>
155
+ <default_template>15</default_template>
156
+ </custom_data>
157
+ <rendering>
158
+ <messages>1</messages>
159
+ </rendering>
160
+ </clipvilla>
161
+ </default>
162
+ <admin>
163
+ <routers>
164
+ <adminhtml>
165
+ <args>
166
+ <modules>
167
+ <clipvilla_mori before="Mage_Adminhtml">ClipVilla_MorI_Adminhtml</clipvilla_mori>
168
+ </modules>
169
+ </args>
170
+ </adminhtml>
171
+ <manageVideos>
172
+ <use>admin</use>
173
+ <args>
174
+ <module>ClipVilla_MorI</module>
175
+ <frontName>admin_manageVideos</frontName>
176
+ </args>
177
+ </manageVideos>
178
+ </routers>
179
+ </admin>
180
+ <adminhtml>
181
+ <layout>
182
+ <updates>
183
+ <clipvilla_mori>
184
+ <file>clipvilla.xml</file>
185
+ </clipvilla_mori>
186
+ </updates>
187
+ </layout>
188
+ <events>
189
+ <core_block_abstract_prepare_layout_before>
190
+ <observers>
191
+ <newmodule_core_block_abstract_prepare_layout_before>
192
+ <class>clipvilla_mori/observer_massAction</class>
193
+ <method>addRenderAll</method>
194
+ </newmodule_core_block_abstract_prepare_layout_before>
195
+ </observers>
196
+ </core_block_abstract_prepare_layout_before>
197
+ </events>
198
+ </adminhtml>
199
+ <crontab>
200
+ <jobs>
201
+ <clipvilla_video>
202
+ <schedule>
203
+ <cron_expr>*/1 * * * *</cron_expr>
204
+ </schedule>
205
+ <run>
206
+ <model>clipvilla_mori/videoCron::generateVideo</model>
207
+ </run>
208
+ </clipvilla_video>
209
+ <clipvilla_video_sitemap>
210
+ <schedule>
211
+ <cron_expr>0 3 * * *</cron_expr>
212
+ </schedule>
213
+ <run>
214
+ <model>clipvilla_mori/videoCron::generateVideoSitemap</model>
215
+ </run>
216
+ </clipvilla_video_sitemap>
217
+ </jobs>
218
+ </crontab>
219
+ </config>
app/code/community/ClipVilla/MorI/etc/mapping.xml ADDED
@@ -0,0 +1,248 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <!--
3
+ /**
4
+ *ClipVilla Video Producer
5
+ *
6
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
7
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
8
+ *
9
+ * NOTICE OF LICENSE
10
+ *
11
+ * This source file is subject to the GNU General Public License (GPLv3)
12
+ * It is available through the world-wide-web at this URL:
13
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
14
+ */
15
+ -->
16
+ <projectMapping>
17
+
18
+ <mapping>
19
+ <renderProjectId>2</renderProjectId>
20
+ <templateName>Lens Flare</templateName>
21
+ <duration>27</duration>
22
+ <textDZs>
23
+ <textDZ>
24
+ <name>ShopName</name>
25
+ <dz>1</dz>
26
+ </textDZ>
27
+ <textDZ>
28
+ <name>Name</name>
29
+ <dz>3</dz>
30
+ </textDZ>
31
+ <textDZ>
32
+ <name>UspOne</name>
33
+ <dz>5</dz>
34
+ </textDZ>
35
+ <textDZ>
36
+ <name>UspTwo</name>
37
+ <dz>7</dz>
38
+ </textDZ>
39
+ <textDZ>
40
+ <name>UspThree</name>
41
+ <dz>9</dz>
42
+ </textDZ>
43
+ </textDZs>
44
+ <imageDZs>
45
+ <imageDZ>
46
+ <name>ImageOne</name>
47
+ <dz>2</dz>
48
+ </imageDZ>
49
+ <imageDZ>
50
+ <name>ImageTwo</name>
51
+ <dz>4</dz>
52
+ </imageDZ>
53
+ <imageDZ>
54
+ <name>ImageThree</name>
55
+ <dz>6</dz>
56
+ </imageDZ>
57
+ <imageDZ>
58
+ <name>ImageFour</name>
59
+ <dz>8</dz>
60
+ </imageDZ>
61
+ </imageDZs>
62
+ </mapping>
63
+
64
+ <mapping>
65
+ <renderProjectId>3</renderProjectId>
66
+ <templateName>Circles</templateName>
67
+ <duration>27</duration>
68
+ <textDZs>
69
+ <textDZ>
70
+ <name>ShopName</name>
71
+ <dz>1</dz>
72
+ </textDZ>
73
+ <textDZ>
74
+ <name>Name</name>
75
+ <dz>3</dz>
76
+ </textDZ>
77
+ <textDZ>
78
+ <name>UspOne</name>
79
+ <dz>5</dz>
80
+ </textDZ>
81
+ <textDZ>
82
+ <name>UspTwo</name>
83
+ <dz>7</dz>
84
+ </textDZ>
85
+ <textDZ>
86
+ <name>UspThree</name>
87
+ <dz>9</dz>
88
+ </textDZ>
89
+ </textDZs>
90
+ <imageDZs>
91
+ <imageDZ>
92
+ <name>ImageOne</name>
93
+ <dz>2</dz>
94
+ </imageDZ>
95
+ <imageDZ>
96
+ <name>ImageTwo</name>
97
+ <dz>4</dz>
98
+ </imageDZ>
99
+ <imageDZ>
100
+ <name>ImageThree</name>
101
+ <dz>6</dz>
102
+ </imageDZ>
103
+ <imageDZ>
104
+ <name>ImageFour</name>
105
+ <dz>8</dz>
106
+ </imageDZ>
107
+ </imageDZs>
108
+ </mapping>
109
+
110
+ <mapping>
111
+ <renderProjectId>4</renderProjectId>
112
+ <templateName>Portrait</templateName>
113
+ <duration>27</duration>
114
+ <textDZs>
115
+ <textDZ>
116
+ <name>ShopName</name>
117
+ <dz>1</dz>
118
+ </textDZ>
119
+ <textDZ>
120
+ <name>Name</name>
121
+ <dz>3</dz>
122
+ </textDZ>
123
+ <textDZ>
124
+ <name>UspOne</name>
125
+ <dz>5</dz>
126
+ </textDZ>
127
+ <textDZ>
128
+ <name>UspTwo</name>
129
+ <dz>7</dz>
130
+ </textDZ>
131
+ <textDZ>
132
+ <name>UspThree</name>
133
+ <dz>9</dz>
134
+ </textDZ>
135
+ </textDZs>
136
+ <imageDZs>
137
+ <imageDZ>
138
+ <name>ImageOne</name>
139
+ <dz>2</dz>
140
+ </imageDZ>
141
+ <imageDZ>
142
+ <name>ImageTwo</name>
143
+ <dz>4</dz>
144
+ </imageDZ>
145
+ <imageDZ>
146
+ <name>ImageThree</name>
147
+ <dz>6</dz>
148
+ </imageDZ>
149
+ <imageDZ>
150
+ <name>ImageFour</name>
151
+ <dz>8</dz>
152
+ </imageDZ>
153
+ </imageDZs>
154
+ </mapping>
155
+
156
+ <mapping>
157
+ <renderProjectId>5</renderProjectId>
158
+ <templateName>Hands Push</templateName>
159
+ <duration>27</duration>
160
+ <textDZs>
161
+ <textDZ>
162
+ <name>ShopName</name>
163
+ <dz>1</dz>
164
+ </textDZ>
165
+ <textDZ>
166
+ <name>Name</name>
167
+ <dz>3</dz>
168
+ </textDZ>
169
+ <textDZ>
170
+ <name>UspOne</name>
171
+ <dz>5</dz>
172
+ </textDZ>
173
+ <textDZ>
174
+ <name>UspTwo</name>
175
+ <dz>7</dz>
176
+ </textDZ>
177
+ <textDZ>
178
+ <name>UspThree</name>
179
+ <dz>9</dz>
180
+ </textDZ>
181
+ </textDZs>
182
+ <imageDZs>
183
+ <imageDZ>
184
+ <name>ImageOne</name>
185
+ <dz>2</dz>
186
+ </imageDZ>
187
+ <imageDZ>
188
+ <name>ImageTwo</name>
189
+ <dz>4</dz>
190
+ </imageDZ>
191
+ <imageDZ>
192
+ <name>ImageThree</name>
193
+ <dz>6</dz>
194
+ </imageDZ>
195
+ <imageDZ>
196
+ <name>ImageFour</name>
197
+ <dz>8</dz>
198
+ </imageDZ>
199
+ </imageDZs>
200
+ </mapping>
201
+
202
+ <mapping>
203
+ <renderProjectId>6</renderProjectId>
204
+ <templateName>Sale</templateName>
205
+ <duration>28</duration>
206
+ <textDZs>
207
+ <textDZ>
208
+ <name>ShopName</name>
209
+ <dz>1</dz>
210
+ </textDZ>
211
+ <textDZ>
212
+ <name>Name</name>
213
+ <dz>3</dz>
214
+ </textDZ>
215
+ <textDZ>
216
+ <name>UspOne</name>
217
+ <dz>5</dz>
218
+ </textDZ>
219
+ <textDZ>
220
+ <name>UspTwo</name>
221
+ <dz>7</dz>
222
+ </textDZ>
223
+ <textDZ>
224
+ <name>UspThree</name>
225
+ <dz>9</dz>
226
+ </textDZ>
227
+ </textDZs>
228
+ <imageDZs>
229
+ <imageDZ>
230
+ <name>ImageOne</name>
231
+ <dz>2</dz>
232
+ </imageDZ>
233
+ <imageDZ>
234
+ <name>ImageTwo</name>
235
+ <dz>4</dz>
236
+ </imageDZ>
237
+ <imageDZ>
238
+ <name>ImageThree</name>
239
+ <dz>6</dz>
240
+ </imageDZ>
241
+ <imageDZ>
242
+ <name>ImageFour</name>
243
+ <dz>8</dz>
244
+ </imageDZ>
245
+ </imageDZs>
246
+ </mapping>
247
+
248
+ </projectMapping>
app/code/community/ClipVilla/MorI/etc/system.xml ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ *ClipVilla Video Producer
5
+ *
6
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
7
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
8
+ *
9
+ * NOTICE OF LICENSE
10
+ *
11
+ * This source file is subject to the GNU General Public License (GPLv3)
12
+ * It is available through the world-wide-web at this URL:
13
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
14
+ */
15
+ -->
16
+ <config>
17
+ <tabs>
18
+ <clipvilla translate="label" module="clipvilla_mori">
19
+ <label>ClipVilla</label>
20
+ <sort_order>100</sort_order>
21
+ </clipvilla>
22
+ </tabs>
23
+ <sections>
24
+ <clipvilla translate="label" module="clipvilla_mori">
25
+ <label>Video Producer</label>
26
+ <tab>clipvilla</tab>
27
+ <sort_order>1000</sort_order>
28
+ <show_in_default>1</show_in_default>
29
+ <show_in_website>0</show_in_website>
30
+ <show_in_store>0</show_in_store>
31
+ <groups>
32
+ <info>
33
+ <label>Package Information</label>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>0</show_in_website>
36
+ <show_in_store>0</show_in_store>
37
+ <fields>
38
+ <module_information>
39
+ <label>Module Information</label>
40
+ <frontend_type>text</frontend_type>
41
+ <frontend_model>clipvilla_mori/adminhtml_info</frontend_model>
42
+ <sort_order>1</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>0</show_in_website>
45
+ <show_in_store>0</show_in_store>
46
+ </module_information>
47
+ </fields>
48
+ </info>
49
+ <configuration translate="label" module="clipvilla_mori">
50
+ <label>Basic Configuration</label>
51
+ <frontend_type>text</frontend_type>
52
+ <sort_order>1000</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>0</show_in_website>
55
+ <show_in_store>0</show_in_store>
56
+ <fields>
57
+ <activate translate="label">
58
+ <label>Activate Module: </label>
59
+ <frontend_type>select</frontend_type>
60
+ <sort_order>10</sort_order>
61
+ <show_in_default>1</show_in_default>
62
+ <show_in_website>0</show_in_website>
63
+ <show_in_store>0</show_in_store>
64
+ <source_model>adminhtml/system_config_source_yesno</source_model>
65
+ </activate>
66
+ <license_key translate="label">
67
+ <label>License Key: </label>
68
+ <frontend_type>text</frontend_type>
69
+ <sort_order>30</sort_order>
70
+ <show_in_default>1</show_in_default>
71
+ <show_in_website>0</show_in_website>
72
+ <show_in_store>0</show_in_store>
73
+ </license_key>
74
+ <video_folder translate="label">
75
+ <label>Video Folder: </label>
76
+ <frontend_type>text</frontend_type>
77
+ <sort_order>40</sort_order>
78
+ <show_in_default>1</show_in_default>
79
+ <show_in_website>0</show_in_website>
80
+ <show_in_store>0</show_in_store>
81
+ </video_folder>
82
+ </fields>
83
+ </configuration>
84
+ <custom_data translate="label" module="clipvilla_mori">
85
+ <label>Global Video Parameters</label>
86
+ <frontend_type>text</frontend_type>
87
+ <sort_order>2000</sort_order>
88
+ <show_in_default>1</show_in_default>
89
+ <show_in_website>1</show_in_website>
90
+ <show_in_store>1</show_in_store>
91
+ <fields>
92
+ <default_template translate="label comment">
93
+ <label>Video Template</label>
94
+ <frontend_type>select</frontend_type>
95
+ <source_model>clipvilla_mori/system_config_source_templateSelect</source_model>
96
+ <sort_order>1</sort_order>
97
+ <show_in_default>1</show_in_default>
98
+ <show_in_website>0</show_in_website>
99
+ <show_in_store>0</show_in_store>
100
+ </default_template>
101
+ <shop translate="label">
102
+ <label>Shop Name/ URL: </label>
103
+ <frontend_type>text</frontend_type>
104
+ <sort_order>10</sort_order>
105
+ <show_in_default>1</show_in_default>
106
+ <show_in_website>0</show_in_website>
107
+ <show_in_store>0</show_in_store>
108
+ <validate>required-entry</validate>
109
+ </shop>
110
+ <usp_one translate="label">
111
+ <label>Video Text 1: </label>
112
+ <frontend_type>text</frontend_type>
113
+ <sort_order>20</sort_order>
114
+ <show_in_default>1</show_in_default>
115
+ <show_in_website>0</show_in_website>
116
+ <show_in_store>0</show_in_store>
117
+ <validate>required-entry</validate>
118
+ </usp_one>
119
+ <usp_two translate="label">
120
+ <label>Video Text 2: </label>
121
+ <frontend_type>text</frontend_type>
122
+ <sort_order>30</sort_order>
123
+ <show_in_default>1</show_in_default>
124
+ <show_in_website>0</show_in_website>
125
+ <show_in_store>0</show_in_store>
126
+ <validate>required-entry</validate>
127
+ </usp_two>
128
+ <usp_three translate="label">
129
+ <label>Video Text 3: </label>
130
+ <frontend_type>text</frontend_type>
131
+ <sort_order>40</sort_order>
132
+ <show_in_default>1</show_in_default>
133
+ <show_in_website>0</show_in_website>
134
+ <show_in_store>0</show_in_store>
135
+ <validate>required-entry</validate>
136
+ </usp_three>
137
+ </fields>
138
+ </custom_data>
139
+ <rendering translate="label" module="clipvilla_mori">
140
+ <label>Notification Options</label>
141
+ <frontend_type>text</frontend_type>
142
+ <sort_order>3000</sort_order>
143
+ <show_in_default>1</show_in_default>
144
+ <show_in_website>0</show_in_website>
145
+ <show_in_store>0</show_in_store>
146
+ <fields>
147
+ <messages translate="label">
148
+ <label>Show Rendering Messages: </label>
149
+ <frontend_type>select</frontend_type>
150
+ <sort_order>10</sort_order>
151
+ <show_in_default>1</show_in_default>
152
+ <show_in_website>0</show_in_website>
153
+ <show_in_store>0</show_in_store>
154
+ <source_model>adminhtml/system_config_source_yesno</source_model>
155
+ </messages>
156
+ <allow_mail translate="label">
157
+ <label>Email Error Notification: </label>
158
+ <comment>Sends an Email if rendering fails.</comment>
159
+ <frontend_type>select</frontend_type>
160
+ <sort_order>20</sort_order>
161
+ <show_in_default>1</show_in_default>
162
+ <show_in_website>0</show_in_website>
163
+ <show_in_store>0</show_in_store>
164
+ <source_model>adminhtml/system_config_source_yesno</source_model>
165
+ </allow_mail>
166
+ <mail translate="label">
167
+ <label>Email: </label>
168
+ <frontend_type>text</frontend_type>
169
+ <sort_order>30</sort_order>
170
+ <show_in_default>1</show_in_default>
171
+ <show_in_website>0</show_in_website>
172
+ <show_in_store>0</show_in_store>
173
+ <depends><allow_mail>1</allow_mail></depends>
174
+ </mail>
175
+ </fields>
176
+ </rendering>
177
+ </groups>
178
+ </clipvilla>
179
+ </sections>
180
+ </config>
app/code/community/ClipVilla/MorI/sql/clipvilla_mori_setup/install-0.1.0.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ $installer = $this;
15
+ $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
16
+ $installer->startSetup();
17
+
18
+ // Product Attribute Group
19
+ $setup->addAttributeGroup('catalog_product', 'Default', 'ClipVilla Video Producer', 1000);
20
+
21
+ // Product Attributes
22
+ $templateData = array(
23
+ 'attribute_set' => 'Default',
24
+ 'group' => 'ClipVilla Video Producer',
25
+ 'label' => 'Video Template',
26
+ 'visible' => true,
27
+ 'type' => 'int',
28
+ 'input' => 'select',
29
+ 'source' => 'clipvilla_mori/system_attribute_source_provider',
30
+ 'system' => true,
31
+ 'required' => false,
32
+ 'user_defined' => true,
33
+ );
34
+ $setup->addAttribute('catalog_product', 'clipvilla_template', $templateData);
35
+
36
+
37
+ $nameData = array(
38
+ 'attribute_set' => 'Default',
39
+ 'group' => 'ClipVilla Video Producer',
40
+ 'label' => 'Product Name',
41
+ 'visible' => true,
42
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
43
+ 'input' => 'text',
44
+ 'system' => true,
45
+ 'required' => false,
46
+ 'user_defined' => true,
47
+ );
48
+ $setup->addAttribute('catalog_product', 'clipvilla_name', $nameData);
49
+
50
+ $uspDataOne = array(
51
+ 'attribute_set' => 'Default',
52
+ 'group' => 'ClipVilla Video Producer',
53
+ 'label' => 'Video Text 1',
54
+ 'visible' => true,
55
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
56
+ 'input' => 'text',
57
+ 'system' => true,
58
+ 'required' => false,
59
+ 'user_defined' => true,
60
+ );
61
+ $setup->addAttribute('catalog_product', 'clipvilla_usp_one', $uspDataOne);
62
+
63
+ $uspDataTwo = array(
64
+ 'attribute_set' => 'Default',
65
+ 'group' => 'ClipVilla Video Producer',
66
+ 'label' => 'Video Text 2',
67
+ 'visible' => true,
68
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
69
+ 'input' => 'text',
70
+ 'system' => true,
71
+ 'required' => false,
72
+ 'user_defined' => true,
73
+ );
74
+ $setup->addAttribute('catalog_product', 'clipvilla_usp_two', $uspDataTwo);
75
+
76
+ $uspDataThree = array(
77
+ 'attribute_set' => 'Default',
78
+ 'group' => 'ClipVilla Video Producer',
79
+ 'label' => 'Video Text 3',
80
+ 'visible' => true,
81
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
82
+ 'input' => 'text',
83
+ 'system' => true,
84
+ 'required' => false,
85
+ 'user_defined' => true,
86
+ );
87
+ $setup->addAttribute('catalog_product', 'clipvilla_usp_three', $uspDataThree);
88
+
89
+ // Template select in category-page
90
+ $template = array (
91
+ 'group' => 'General Information',
92
+ 'type' => 'int',
93
+ 'backend' => '',
94
+ 'frontend_input' => '',
95
+ 'frontend' => '',
96
+ 'label' => 'Video Template',
97
+ 'input' => 'select',
98
+ 'class' => '',
99
+ 'source' => 'clipvilla_mori/system_attribute_source_provider',
100
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
101
+ 'required' => false,
102
+ 'default' => '',
103
+ );
104
+ $setup->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'clipvilla_template', $template);
105
+
106
+ $installer->endSetup();
app/code/community/ClipVilla/MorI/sql/clipvilla_mori_setup/upgrade-0.1.0-0.2.0.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ $installer = $this;
15
+ $installer->startSetup();
16
+
17
+ if ($installer->getConnection()->isTableExists('clipvilla_videos') != true) {
18
+ $table = $installer->getConnection()
19
+ ->newTable($installer->getTable('clipvilla_mori/videos'))
20
+ ->addColumn(
21
+ 'video_id', Varien_Db_Ddl_Table::TYPE_BIGINT, null, array(
22
+ 'identity' => true,
23
+ 'unsigned' => true,
24
+ 'nullable' => false,
25
+ 'primary' => true,
26
+ ), 'Id'
27
+ )
28
+ ->addColumn(
29
+ 'product_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
30
+ 'unsigned' => true,
31
+ 'nullable' => false,
32
+ ), 'Product ID'
33
+ )
34
+ ->addColumn(
35
+ 'render_project_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
36
+ 'unsigned' => true,
37
+ 'nullable' => false,
38
+ ), 'Product ID'
39
+ )
40
+ ->addColumn(
41
+ 'name', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
42
+ 'nullable' => false,
43
+ ), 'Render Project ID'
44
+ )
45
+ ->addColumn(
46
+ 'usp_one', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
47
+ 'nullable' => false,
48
+ ), 'USP One'
49
+ )
50
+ ->addColumn(
51
+ 'usp_two', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
52
+ 'nullable' => false,
53
+ ), 'USP two'
54
+ )
55
+ ->addColumn(
56
+ 'usp_three', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
57
+ 'nullable' => false,
58
+ ), 'USP Three'
59
+ )
60
+ ->addColumn(
61
+ 'image_one', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
62
+ 'nullable' => false,
63
+ ), 'Product Image'
64
+ )
65
+ ->addColumn(
66
+ 'image_two', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
67
+ 'nullable' => false,
68
+ ), 'Product Image'
69
+ )
70
+ ->addColumn(
71
+ 'image_three', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
72
+ 'nullable' => false,
73
+ ), 'Product Image'
74
+ )
75
+ ->addColumn(
76
+ 'image_four', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
77
+ 'nullable' => false,
78
+ ), 'Product Image'
79
+ )
80
+ ->addColumn(
81
+ 'creation_date', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array(
82
+ 'nullable' => true,
83
+ ), 'Video Creation Date'
84
+ )
85
+ ->addColumn(
86
+ 'status', Varien_Db_Ddl_Table::TYPE_TINYINT, null, array(
87
+ 'unsigned' => true,
88
+ 'nullable' => false,
89
+ ), 'Video Status'
90
+ );
91
+
92
+ $installer->getConnection()->createTable($table);
93
+ }
94
+
95
+ $installer->endSetup();
app/code/community/ClipVilla/MorI/sql/clipvilla_mori_setup/upgrade-0.2.0-0.3.0.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ $installer = $this;
15
+ $installer->startSetup();
16
+
17
+ if ($installer->getConnection()->isTableExists('clipvilla_stack') != true) {
18
+ $table = $installer->getConnection()
19
+ ->newTable($installer->getTable('clipvilla_mori/stack'))
20
+ ->addColumn(
21
+ 'stack_id', Varien_Db_Ddl_Table::TYPE_BIGINT, null, array(
22
+ 'identity' => true,
23
+ 'unsigned' => true,
24
+ 'nullable' => false,
25
+ 'primary' => true,
26
+ ), 'Id'
27
+ )
28
+ ->addColumn(
29
+ 'video_id', Varien_Db_Ddl_Table::TYPE_BIGINT, null, array(
30
+ 'unsigned' => true,
31
+ 'nullable' => false,
32
+ ), ' Video ID'
33
+ )
34
+ ->addColumn(
35
+ 'priority', Varien_Db_Ddl_Table::TYPE_TINYINT, null, array(
36
+ 'unsigned' => true,
37
+ 'nullable' => false,
38
+ ), 'Priority'
39
+ )
40
+ ->addColumn(
41
+ 'status', Varien_Db_Ddl_Table::TYPE_TINYINT, null, array(
42
+ 'unsigned' => true,
43
+ 'nullable' => false,
44
+ ), 'Video Status'
45
+ )
46
+ ->addColumn(
47
+ 'render_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
48
+ 'unsigned' => true,
49
+ 'nullable' => true,
50
+ ), 'Render Id'
51
+ );
52
+ $installer->getConnection()->createTable($table);
53
+ }
54
+
55
+ $installer->endSetup();
app/code/community/ClipVilla/MorI/sql/clipvilla_mori_setup/upgrade-0.3.0-1.0.0.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+
15
+ // Marks Indexer as Ready on Module Installation
16
+ Mage::getSingleton('index/indexer')
17
+ ->getProcessByCode('clipvilla_indexer')
18
+ ->changeStatus(Mage_Index_Model_Process::STATUS_PENDING);
19
+
20
+ // Opens in the ClipVilla Information Group in Magento Backend on default for all admin users
21
+ $adminUsers = Mage::getModel('admin/user')->getCollection()->load();
22
+ foreach ($adminUsers as $adminUser) {
23
+ $extra = $adminUser->getExtra();
24
+ if (!is_array($extra)) {
25
+ $extra = array();
26
+ }
27
+ if (!isset($extra['configState'])) {
28
+ $extra['configState'] = array();
29
+ }
30
+ $extra['configState']['clipvilla_info'] = 1;
31
+ $adminUser->saveExtra($extra);
32
+ }
33
+
34
+ // generates reset counter for stuck entries in the rendering queue
35
+ Mage::getModel('core/config')->saveConfig('clipvilla/rendering/reset', 0);
app/design/adminhtml/default/default/layout/clipvilla.xml ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ *ClipVilla Video Producer
5
+ *
6
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
7
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
8
+ *
9
+ * NOTICE OF LICENSE
10
+ *
11
+ * This source file is subject to the GNU General Public License (GPLv3)
12
+ * It is available through the world-wide-web at this URL:
13
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
14
+ */
15
+ -->
16
+ <layout>
17
+ <default>
18
+ <reference name="notifications">
19
+ <block type="clipvilla_mori/adminhtml_notifications" template="clipvilla/notifications.phtml" before="-" />
20
+ </reference>
21
+ </default>
22
+
23
+ <adminhtml_managevideos_index>
24
+ <reference name="head">
25
+ <action method="addJs">
26
+ <script>clipvilla/popup.js</script>
27
+ </action>
28
+ <action method="addItem">
29
+ <type>js_css</type>
30
+ <name>prototype/windows/themes/default.css</name>
31
+ </action>
32
+ <action method="addCss">
33
+ <name>lib/prototype/windows/themes/magento.css</name>
34
+ </action>
35
+ </reference>
36
+ <reference name="content">
37
+ <block type="clipvilla_mori/adminhtml_manageVideos" name="manageVideos" />
38
+ </reference>
39
+ </adminhtml_managevideos_index>
40
+
41
+ <adminhtml_managevideos_popup>
42
+ <reference name="head">
43
+ <action method="addJs">
44
+ <script>clipvilla/video-js/video.js</script>
45
+ </action>
46
+ <action method="addItem">
47
+ <type>js_css</type>
48
+ <name>clipvilla/video-js/video-js.css</name>
49
+ </action>
50
+ </reference>
51
+ <reference name="notifications">
52
+ <remove name="global_notices" />
53
+ </reference>
54
+ <reference name="root">
55
+ <action method="setTemplate">
56
+ <template>empty.phtml</template>
57
+ </action>
58
+ </reference>
59
+ <reference name="content">
60
+ <block type="clipvilla_mori/adminhtml_manageVideos_popup" template="clipvilla/popup.phtml">
61
+ </block>
62
+ </reference>
63
+ </adminhtml_managevideos_popup>
64
+ </layout>
app/design/adminhtml/default/default/template/clipvilla/information.phtml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ ?>
15
+
16
+
17
+ <img style="float:right;" src="<?php echo $this->getLogo(); ?>" width="365px" />
18
+ <p style="font-weight:bold">Are you enjoying your experience with the ClipVilla Video Producer?</p>
19
+
20
+ <p>
21
+ <strong>Need a quick start?</strong><br/>
22
+ If you have difficulties getting started, simply watch our 3-minute <a href="http://videoproducer.clipvilla.com/#Howto" target="_blank">support video</a> on how to use the ClipVilla Video Producer.
23
+ </p>
24
+ <p>
25
+ We have so much more for you:<br/>
26
+ <a href="http://videoproducer.clipvilla.com/#Price" target="_blank">Click here</a> to book your package offer and get your video contingent and templates to start right
27
+ off with the production. Simply select a video template, royalty free music and insert text modules!<br/>
28
+ For a monthly investment starting at as little as 99 $!
29
+ </p>
30
+
31
+ <p>
32
+ Or choose our <a href="http://videoproducer.clipvilla.com/#Price" target="_blank">customized package</a> and the ClipVilla Video Producer will be adjusted to your
33
+ individual system requirements. A custom-made video-template, synthesization with your magento-data,
34
+ motion, animation and text voice over, global shop attributes and up to 10 product categories included!
35
+ </p>
36
+
37
+ <p>
38
+ <strong>You need support for the Video Producer?</strong><br/>
39
+ For technical support please contact <a href="mailto:techsupport@clipvilla.com?Subject=Customized%20Extension" target="_top">techsupport@clipvilla.com</a>
40
+ </p>
app/design/adminhtml/default/default/template/clipvilla/notifications.phtml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ ?>
15
+
16
+ <?php
17
+ /**
18
+ * @see ClipVilla_MorI_Block_Adminhtml_Notifications
19
+ */
20
+ ?>
21
+ <?php
22
+ $count = $this->getStackCount();
23
+ $lastRendered = $this->getLastRendered();
24
+ ?>
25
+
26
+ <?php if (Mage::getStoreConfig('clipvilla/rendering/messages') && ($count || $lastRendered['name'])): ?>
27
+ <div class="notification-global">
28
+ <?php if ($count): ?>
29
+ <?php echo $this->__('Videos in Rendering Queue:'); ?> <strong><?php echo $count ?></strong>
30
+ <?php endif; ?>
31
+
32
+ <?php if ($count && $lastRendered['name']): ?>
33
+ |
34
+ <?php endif; ?>
35
+
36
+ <?php if ($lastRendered['name']): ?>
37
+ <?php echo $this->__('Last rendered Video:'); ?>
38
+ <strong><?php echo $lastRendered['name']; ?></strong>
39
+ (<?php echo $this->__('Product ID'); ?> <?php echo $lastRendered['id']; ?>)
40
+ <?php endif; ?>
41
+ </div>
42
+ <?php endif; ?>
app/design/adminhtml/default/default/template/clipvilla/popup.phtml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ ?>
15
+ <?php
16
+ /**
17
+ * @see ClipVilla_MorI_Block_Adminhtml_ManageVideos_Popup
18
+ */
19
+ ?>
20
+ <div style="margin-top:6px; margin-left:5px; max-width:795px;">
21
+ <video id="product_video" class="video-js vjs-default-skin vjs-big-play-centered"
22
+ controls preload="auto" width="auto" height="auto"
23
+ data-setup='{}'>
24
+ <source src="<?php echo $this->getVideo(); ?>" type='video/mp4' />
25
+ </video>
26
+ </div>
app/design/frontend/base/default/layout/clipvilla.xml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ *ClipVilla Video Producer
5
+ *
6
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
7
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
8
+ *
9
+ * NOTICE OF LICENSE
10
+ *
11
+ * This source file is subject to the GNU General Public License (GPLv3)
12
+ * It is available through the world-wide-web at this URL:
13
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
14
+ */
15
+ -->
16
+ <layout version="0.1.0">
17
+ <catalog_product_view translate="label">
18
+ <reference name="head">
19
+ <action method="addJs">
20
+ <script>clipvilla/video-js/video.js</script>
21
+ </action>
22
+ <action method="addItem">
23
+ <type>js_css</type>
24
+ <name>clipvilla/video-js/video-js.css</name>
25
+ </action>
26
+ </reference>
27
+ <reference name="content">
28
+ <reference name="product.info">
29
+ <block type="clipvilla_mori/videos" name="other" template="clipvilla/videos.phtml" before="-"/>
30
+ </reference>
31
+ </reference>
32
+ </catalog_product_view>
33
+ </layout>
app/design/frontend/base/default/template/clipvilla/videos.phtml ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *ClipVilla Video Producer
4
+ *
5
+ *The ClipVilla Video Producer's code is created by ClipVilla GmbH.
6
+ *If the code is completely or partially changed by a third party all guarantee and warranty claims against ClipVilla GmbH will be invalidated.
7
+ *
8
+ * NOTICE OF LICENSE
9
+ *
10
+ * This source file is subject to the GNU General Public License (GPLv3)
11
+ * It is available through the world-wide-web at this URL:
12
+ * http://www.gnu.org/licenses/quick-guide-gplv3.html.en
13
+ */
14
+ ?>
15
+ <?php
16
+ /**
17
+ * @see ClipVilla_MorI_Block_Videos
18
+ */
19
+ ?>
20
+ <?php if (Mage::registry('current_product')->getId() == 423) { ?>
21
+
22
+ <div itemscope itemtype="http://schema.org/VideoObject" style="max-width: 585px">
23
+ <meta itemprop="name" content="<?php echo $this->getMetaTitle(); ?>">
24
+ <meta itemprop="description" content="<?php echo $this->getMetaDescription(); ?>">
25
+ <meta itemprop="thumbnailUrl" content="<?php echo $this->getImageUrl(); ?>">
26
+ <meta itemprop="contentUrl" content="<?php echo $this->getVideoFile(); ?>">
27
+ <meta itemprop="duration" content="<?php echo $this->getVideoDuration(); ?>">
28
+ <meta itemprop="uploadDate" content="<?php echo $this->getCreationDate(); ?>">
29
+ <video id="product_video" class="video-js vjs-default-skin vjs-big-play-centered"
30
+ controls preload="auto" width="auto" height="auto" data-setup='{}' />
31
+ <source src="http://clipvilla.55.test-dmz-s1-nsd.neusta.de/media/clipvilla/videos/maxi.mp4" type='video/mp4' />
32
+ </video>
33
+ </div>
34
+
35
+ <?php } ?>
36
+
37
+ <?php if (Mage::registry('current_product')->getId() == 888) { ?>
38
+
39
+ <div itemscope itemtype="http://schema.org/VideoObject" style="max-width: 585px">
40
+ <meta itemprop="name" content="<?php echo $this->getMetaTitle(); ?>">
41
+ <meta itemprop="description" content="<?php echo $this->getMetaDescription(); ?>">
42
+ <meta itemprop="thumbnailUrl" content="<?php echo $this->getImageUrl(); ?>">
43
+ <meta itemprop="contentUrl" content="<?php echo $this->getVideoFile(); ?>">
44
+ <meta itemprop="duration" content="<?php echo $this->getVideoDuration(); ?>">
45
+ <meta itemprop="uploadDate" content="<?php echo $this->getCreationDate(); ?>">
46
+ <video id="product_video" class="video-js vjs-default-skin vjs-big-play-centered"
47
+ controls preload="auto" width="auto" height="auto" data-setup='{}' />
48
+ <source src="http://clipvilla.55.test-dmz-s1-nsd.neusta.de/media/clipvilla/videos/electronics.mp4" type='video/mp4' />
49
+ </video>
50
+ </div>
51
+
52
+ <?php } ?>
53
+
54
+ <?php if (Mage::registry('current_product')->getId() == 414) { ?>
55
+
56
+ <div itemscope itemtype="http://schema.org/VideoObject" style="max-width: 585px">
57
+ <meta itemprop="name" content="<?php echo $this->getMetaTitle(); ?>">
58
+ <meta itemprop="description" content="<?php echo $this->getMetaDescription(); ?>">
59
+ <meta itemprop="thumbnailUrl" content="<?php echo $this->getImageUrl(); ?>">
60
+ <meta itemprop="contentUrl" content="<?php echo $this->getVideoFile(); ?>">
61
+ <meta itemprop="duration" content="<?php echo $this->getVideoDuration(); ?>">
62
+ <meta itemprop="uploadDate" content="<?php echo $this->getCreationDate(); ?>">
63
+ <video id="product_video" class="video-js vjs-default-skin vjs-big-play-centered"
64
+ controls preload="auto" width="auto" height="auto" data-setup='{}' />
65
+ <source src="http://clipvilla.55.test-dmz-s1-nsd.neusta.de/media/clipvilla/videos/fashionMan.mp4" type='video/mp4' />
66
+ </video>
67
+ </div>
68
+
69
+ <?php } ?>
70
+
71
+ <?php if (Mage::registry('current_product')->getId() == 418) { ?>
72
+
73
+ <div itemscope itemtype="http://schema.org/VideoObject" style="max-width: 585px">
74
+ <meta itemprop="name" content="<?php echo $this->getMetaTitle(); ?>">
75
+ <meta itemprop="description" content="<?php echo $this->getMetaDescription(); ?>">
76
+ <meta itemprop="thumbnailUrl" content="<?php echo $this->getImageUrl(); ?>">
77
+ <meta itemprop="contentUrl" content="<?php echo $this->getVideoFile(); ?>">
78
+ <meta itemprop="duration" content="<?php echo $this->getVideoDuration(); ?>">
79
+ <meta itemprop="uploadDate" content="<?php echo $this->getCreationDate(); ?>">
80
+ <video id="product_video" class="video-js vjs-default-skin vjs-big-play-centered"
81
+ controls preload="auto" width="auto" height="auto" data-setup='{}' />
82
+ <source src="http://clipvilla.55.test-dmz-s1-nsd.neusta.de/media/clipvilla/videos/fashionWoman.mp4" type='video/mp4' />
83
+ </video>
84
+ </div>
85
+
86
+ <?php } ?>
87
+
88
+ <?php if (Mage::registry('current_product')->getId() == 447) { ?>
89
+
90
+ <div itemscope itemtype="http://schema.org/VideoObject" style="max-width: 585px">
91
+ <meta itemprop="name" content="<?php echo $this->getMetaTitle(); ?>">
92
+ <meta itemprop="description" content="<?php echo $this->getMetaDescription(); ?>">
93
+ <meta itemprop="thumbnailUrl" content="<?php echo $this->getImageUrl(); ?>">
94
+ <meta itemprop="contentUrl" content="<?php echo $this->getVideoFile(); ?>">
95
+ <meta itemprop="duration" content="<?php echo $this->getVideoDuration(); ?>">
96
+ <meta itemprop="uploadDate" content="<?php echo $this->getCreationDate(); ?>">
97
+ <video id="product_video" class="video-js vjs-default-skin vjs-big-play-centered"
98
+ controls preload="auto" width="auto" height="auto" data-setup='{}' />
99
+ <source src="http://clipvilla.55.test-dmz-s1-nsd.neusta.de/media/clipvilla/videos/sale.mp4" type='video/mp4' />
100
+ </video>
101
+ </div>
102
+
103
+ <?php } ?>
104
+
105
+
106
+ <?php if (Mage::registry('current_product')->getId() == 375) { ?>
107
+
108
+ <div itemscope itemtype="http://schema.org/VideoObject" style="max-width: 585px">
109
+ <meta itemprop="name" content="<?php echo $this->getMetaTitle(); ?>">
110
+ <meta itemprop="description" content="<?php echo $this->getMetaDescription(); ?>">
111
+ <meta itemprop="thumbnailUrl" content="<?php echo $this->getImageUrl(); ?>">
112
+ <meta itemprop="contentUrl" content="<?php echo $this->getVideoFile(); ?>">
113
+ <meta itemprop="duration" content="<?php echo $this->getVideoDuration(); ?>">
114
+ <meta itemprop="uploadDate" content="<?php echo $this->getCreationDate(); ?>">
115
+ <video id="product_video" class="video-js vjs-default-skin vjs-big-play-centered"
116
+ controls preload="auto" width="auto" height="auto" data-setup='{}' />
117
+ <source src="http://clipvilla.55.test-dmz-s1-nsd.neusta.de/media/clipvilla/videos/circles.mp4" type='video/mp4' />
118
+ </video>
119
+ </div>
120
+
121
+ <?php } ?>
122
+
123
+ <?php if($this->videoExists()): ?>
124
+ <div itemscope itemtype="http://schema.org/VideoObject" style="max-width: 585px">
125
+ <meta itemprop="name" content="<?php echo $this->getMetaTitle(); ?>">
126
+ <meta itemprop="description" content="<?php echo $this->getMetaDescription(); ?>">
127
+ <meta itemprop="thumbnailUrl" content="<?php echo $this->getImageUrl(); ?>">
128
+ <meta itemprop="contentUrl" content="<?php echo $this->getVideoFile(); ?>">
129
+ <meta itemprop="duration" content="<?php echo $this->getVideoDuration(); ?>">
130
+ <meta itemprop="uploadDate" content="<?php echo $this->getCreationDate(); ?>">
131
+ <video id="product_video" class="video-js vjs-default-skin vjs-big-play-centered"
132
+ controls preload="auto" width="auto" height="auto" data-setup='{}' />
133
+ <source src="<?php echo $this->getVideoFile(); ?>" type='video/mp4' />
134
+ </video>
135
+ </div>
136
+ <?php endif ?>
app/etc/modules/ClipVilla_MorI.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <ClipVilla_MorI>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </ClipVilla_MorI>
8
+ </modules>
9
+ </config>
app/locale/en_US/template/email/clipvilla.html ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject ClipVilla - Rendering Error@-->
2
+ <!--@vars
3
+ {"var productId":"Product ID",
4
+ "var errorMessage":"More specific cause of Error"}
5
+ @-->
6
+ <div>
7
+ <h1>ClipVilla - Video Rendering Error</h1>
8
+ <p>The Video for the Product with the ID {{var productId}} could not be rendered.</p>
9
+ <p>{{var errorMessage}}</p>
10
+ </div>
js/clipvilla/popup.js ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function openPopup(url, name) {
2
+ var dialogWindow = Dialog.info(null, {
3
+ id: 'browser_window',
4
+ className: 'magento',
5
+ windowClassName: 'popup-window',
6
+ title: name,
7
+ url: url,
8
+ width: 808,
9
+ height: 457,
10
+ zIndex: 1000,
11
+ closable: true,
12
+ resizable: false,
13
+ draggable: false,
14
+ minimizable: false,
15
+ maximizable: false,
16
+ recenterAuto: false,
17
+ hideEffect: Element.hide,
18
+ showEffect: Element.show,
19
+ destroyOnClose: true
20
+ });
21
+ }
22
+
23
+ function closePopup() {
24
+ Windows.close('browser_window');
25
+ }
js/clipvilla/video-js/font/vjs.eot ADDED
Binary file
js/clipvilla/video-js/font/vjs.svg ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
3
+ <svg xmlns="http://www.w3.org/2000/svg">
4
+ <metadata>Generated by IcoMoon</metadata>
5
+ <defs>
6
+ <font id="icomoon" horiz-adv-x="1024">
7
+ <font-face units-per-em="1024" ascent="960" descent="-64" />
8
+ <missing-glyph horiz-adv-x="1024" />
9
+ <glyph unicode="&#x20;" d="" horiz-adv-x="512" />
10
+ <glyph unicode="&#xe000;" d="M1024 960v-416l-160 160-192-192-96 96 192 192-160 160zM448 288l-192-192 160-160h-416v416l160-160 192 192z" />
11
+ <glyph unicode="&#xe001;" d="M192 832l640-384-640-384z" />
12
+ <glyph unicode="&#xe002;" d="M128 832h320v-768h-320zM576 832h320v-768h-320z" />
13
+ <glyph unicode="&#xe003;" d="M401.332 881.332c25.668 25.668 46.668 16.968 46.668-19.332v-828c0-36.3-21-44.998-46.668-19.33l-241.332 241.33h-160v384h160l241.332 241.332z" />
14
+ <glyph unicode="&#xe004;" d="M549.020 218.98c-12.286 0-24.568 4.686-33.942 14.058-18.746 18.746-18.746 49.136 0 67.882 81.1 81.1 81.1 213.058 0 294.156-18.746 18.746-18.746 49.138 0 67.882 18.746 18.744 49.136 18.744 67.882 0 118.53-118.53 118.53-311.392 0-429.922-9.372-9.37-21.656-14.056-33.94-14.056zM401.332 881.332c25.668 25.668 46.668 16.968 46.668-19.332v-828c0-36.3-21-44.998-46.668-19.33l-241.332 241.33h-160v384h160l241.332 241.332z" />
15
+ <glyph unicode="&#xe005;" d="M719.53 128.47c-12.286 0-24.568 4.686-33.942 14.058-18.744 18.744-18.744 49.136 0 67.882 131.006 131.006 131.006 344.17 0 475.176-18.744 18.746-18.744 49.138 0 67.882 18.744 18.742 49.138 18.744 67.882 0 81.594-81.592 126.53-190.076 126.53-305.468 0-115.39-44.936-223.876-126.53-305.47-9.372-9.374-21.656-14.060-33.94-14.060zM549.020 218.98c-12.286 0-24.568 4.686-33.942 14.058-18.746 18.746-18.746 49.136 0 67.882 81.1 81.1 81.1 213.058 0 294.156-18.746 18.746-18.746 49.138 0 67.882 18.746 18.744 49.136 18.744 67.882 0 118.53-118.53 118.53-311.392 0-429.922-9.372-9.37-21.656-14.056-33.94-14.056zM401.332 881.332c25.668 25.668 46.668 16.968 46.668-19.332v-828c0-36.3-21-44.998-46.668-19.33l-241.332 241.33h-160v384h160l241.332 241.332z" />
16
+ <glyph unicode="&#xe006;" d="M890.040 37.96c-12.286 0-24.568 4.686-33.942 14.058-18.744 18.746-18.744 49.136 0 67.882 87.638 87.642 135.904 204.16 135.904 328.1 0 123.938-48.266 240.458-135.904 328.098-18.744 18.746-18.744 49.138 0 67.882 18.744 18.744 49.138 18.744 67.882 0 105.77-105.772 164.022-246.4 164.022-395.98 0-149.582-58.252-290.208-164.022-395.98-9.372-9.374-21.656-14.060-33.94-14.060zM719.53 128.47c-12.286 0-24.568 4.686-33.942 14.058-18.744 18.744-18.744 49.136 0 67.882 131.006 131.006 131.006 344.17 0 475.176-18.744 18.746-18.744 49.138 0 67.882 18.744 18.742 49.138 18.744 67.882 0 81.594-81.592 126.53-190.076 126.53-305.468 0-115.39-44.936-223.876-126.53-305.47-9.372-9.374-21.656-14.060-33.94-14.060zM549.020 218.98c-12.286 0-24.568 4.686-33.942 14.058-18.746 18.746-18.746 49.136 0 67.882 81.1 81.1 81.1 213.058 0 294.156-18.746 18.746-18.746 49.138 0 67.882 18.746 18.744 49.136 18.744 67.882 0 118.53-118.53 118.53-311.392 0-429.922-9.372-9.37-21.656-14.056-33.94-14.056zM401.332 881.332c25.668 25.668 46.668 16.968 46.668-19.332v-828c0-36.3-21-44.998-46.668-19.33l-241.332 241.33h-160v384h160l241.332 241.332z" horiz-adv-x="1088" />
17
+ <glyph unicode="&#xe007;" d="M512 960l-320-512 320-512 320 512z" />
18
+ <glyph unicode="&#xe008;" d="M0 960h1374.316v-1030.414h-1374.316v1030.414zM1245.462 449.276c-1.706 180.052-8.542 258.568-51.2 314.036-7.68 11.946-22.186 18.772-34.132 27.296-41.814 30.73-238.944 41.814-467.636 41.814-228.702 0-435.21-11.084-476.17-41.814-12.8-8.524-27.316-15.35-35.84-27.296-41.822-55.468-47.786-133.984-50.346-314.036 2.56-180.062 8.524-258.57 50.346-314.036 8.524-12.8 23.040-18.774 35.84-27.306 40.96-31.574 247.468-41.814 476.17-43.52 228.692 1.706 425.822 11.946 467.636 43.52 11.946 8.532 26.452 14.506 34.132 27.306 42.658 55.466 49.494 133.974 51.2 314.036zM662.358 495.904c-11.58 140.898-86.51 223.906-220.556 223.906-122.458 0-218.722-110.432-218.722-287.88 0-178.212 87.73-289.396 232.734-289.396 115.766 0 196.798 85.298 209.588 226.95h-138.302c-5.48-52.548-27.414-92.914-73.72-92.914-73.108 0-86.51 72.354-86.51 149.27 0 105.868 30.46 159.932 81.032 159.932 45.082 0 73.718-32.75 77.976-89.868h136.48zM1140.026 495.904c-11.57 140.898-86.51 223.906-220.546 223.906-122.466 0-218.722-110.432-218.722-287.88 0-178.212 87.73-289.396 232.734-289.396 115.758 0 196.788 85.298 209.58 226.95h-138.304c-5.47-52.548-27.404-92.914-73.71-92.914-73.116 0-86.518 72.354-86.518 149.27 0 105.868 30.468 159.932 81.030 159.932 45.084 0 73.728-32.75 77.986-89.868h136.47z" horiz-adv-x="1374" />
19
+ <glyph unicode="&#xe009;" d="M128 832h768v-768h-768z" />
20
+ <glyph unicode="&#xe00a;" d="M384 832c0-70.692 57.308-128 128-128s128 57.308 128 128c0 70.692-57.308 128-128 128-70.692 0-128-57.308-128-128zM655.53 719.53c0-70.692 57.308-128 128-128s128 57.308 128 128c0 70.692-57.308 128-128 128-70.692 0-128-57.308-128-128zM832 448c0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64-35.346 0-64-28.654-64-64zM719.53 176.47c0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64-35.346 0-64-28.654-64-64zM448.002 64c0 0 0 0 0 0 0-35.346 28.654-64 64-64 35.346 0 64 28.654 64 64 0 0 0 0 0 0 0 0 0 0 0 0 0 35.346-28.654 64-64 64-35.346 0-64-28.654-64-64s0 0 0 0zM176.472 176.47c0 0 0 0 0 0 0-35.346 28.654-64 64-64 35.346 0 64 28.654 64 64 0 0 0 0 0 0 0 0 0 0 0 0 0 35.346-28.654 64-64 64-35.346 0-64-28.654-64-64s0 0 0 0zM144.472 719.53c0 0 0 0 0 0 0-53.019 42.981-96 96-96 53.019 0 96 42.981 96 96 0 0 0 0 0 0 0 0 0 0 0 0 0 53.019-42.981 96-96 96-53.019 0-96-42.981-96-96s0 0 0 0zM56 448c0-39.765 32.235-72 72-72s72 32.235 72 72c0 39.765-32.235 72-72 72-39.765 0-72-32.235-72-72z" />
21
+ <glyph unicode="&#xe00b;" d="M448 384v-416l-160 160-192-192-96 96 192 192-160 160zM1024 864l-192-192 160-160h-416v416l160-160 192 192z" />
22
+ <glyph unicode="&#xe00c;" d="M512 896c282.77 0 512-186.25 512-416 0-229.752-229.23-416-512-416-27.156 0-53.81 1.734-79.824 5.044-109.978-109.978-241.25-129.7-368.176-132.596v26.916c68.536 33.578 128 94.74 128 164.636 0 9.754-0.758 19.33-2.164 28.696-115.796 76.264-189.836 192.754-189.836 323.304 0 229.75 229.23 416 512 416z" />
23
+ <glyph unicode="&#xe00d;" d="M512 960c-282.77 0-512-229.23-512-512s229.23-512 512-512 512 229.23 512 512-229.23 512-512 512zM512 704c141.384 0 256-114.616 256-256s-114.616-256-256-256-256 114.616-256 256 114.616 256 256 256zM817.47 142.53c-81.594-81.594-190.080-126.53-305.47-126.53-115.392 0-223.876 44.936-305.47 126.53-81.594 81.594-126.53 190.078-126.53 305.47 0 115.39 44.936 223.876 126.53 305.47l67.882-67.882c0 0 0 0 0 0-131.006-131.006-131.006-344.17 0-475.176 63.462-63.462 147.838-98.412 237.588-98.412 89.748 0 174.124 34.95 237.588 98.412 131.006 131.006 131.006 344.168 0 475.176l67.882 67.882c81.594-81.594 126.53-190.080 126.53-305.47 0-115.392-44.936-223.876-126.53-305.47z" />
24
+ <glyph unicode="&#xe00e;" d="M864 256c-45.16 0-85.92-18.738-115.012-48.83l-431.004 215.502c1.314 8.252 2.016 16.706 2.016 25.328s-0.702 17.076-2.016 25.326l431.004 215.502c29.092-30.090 69.852-48.828 115.012-48.828 88.366 0 160 71.634 160 160s-71.634 160-160 160-160-71.634-160-160c0-8.622 0.704-17.076 2.016-25.326l-431.004-215.504c-29.092 30.090-69.852 48.83-115.012 48.83-88.366 0-160-71.636-160-160 0-88.368 71.634-160 160-160 45.16 0 85.92 18.738 115.012 48.828l431.004-215.502c-1.312-8.25-2.016-16.704-2.016-25.326 0-88.368 71.634-160 160-160s160 71.632 160 160c0 88.364-71.634 160-160 160z" />
25
+ <glyph unicode="&#xe01e;" d="M1024 448c-1.278 66.862-15.784 133.516-42.576 194.462-26.704 61-65.462 116.258-113.042 161.92-47.552 45.696-103.944 81.82-164.984 105.652-61.004 23.924-126.596 35.352-191.398 33.966-64.81-1.282-129.332-15.374-188.334-41.356-59.048-25.896-112.542-63.47-156.734-109.576-44.224-46.082-79.16-100.708-102.186-159.798-23.114-59.062-34.128-122.52-32.746-185.27 1.286-62.76 14.964-125.148 40.134-182.206 25.088-57.1 61.476-108.828 106.11-151.548 44.61-42.754 97.472-76.504 154.614-98.72 57.118-22.304 118.446-32.902 179.142-31.526 60.708 1.29 120.962 14.554 176.076 38.914 55.15 24.282 105.116 59.48 146.366 102.644 41.282 43.14 73.844 94.236 95.254 149.43 13.034 33.458 21.88 68.4 26.542 103.798 1.246-0.072 2.498-0.12 3.762-0.12 35.346 0 64 28.652 64 64 0 1.796-0.094 3.572-0.238 5.332h0.238zM922.306 278.052c-23.472-53.202-57.484-101.4-99.178-141.18-41.67-39.81-91-71.186-144.244-91.79-53.228-20.678-110.29-30.452-166.884-29.082-56.604 1.298-112.596 13.736-163.82 36.474-51.25 22.666-97.684 55.49-135.994 95.712-38.338 40.198-68.528 87.764-88.322 139.058-19.87 51.284-29.228 106.214-27.864 160.756 1.302 54.552 13.328 108.412 35.254 157.69 21.858 49.3 53.498 93.97 92.246 130.81 38.73 36.868 84.53 65.87 133.874 84.856 49.338 19.060 102.136 28.006 154.626 26.644 52.5-1.306 104.228-12.918 151.562-34.034 47.352-21.050 90.256-51.502 125.624-88.782 35.396-37.258 63.21-81.294 81.39-128.688 18.248-47.392 26.782-98.058 25.424-148.496h0.238c-0.144-1.76-0.238-3.536-0.238-5.332 0-33.012 24.992-60.174 57.086-63.624-6.224-34.822-16.53-68.818-30.78-100.992z" />
26
+ <glyph unicode="&#xe01f;" d="M512 960c-278.748 0-505.458-222.762-511.848-499.974 5.92 241.864 189.832 435.974 415.848 435.974 229.75 0 416-200.576 416-448 0-53.020 42.98-96 96-96 53.020 0 96 42.98 96 96 0 282.77-229.23 512-512 512zM512-64c278.748 0 505.458 222.762 511.848 499.974-5.92-241.864-189.832-435.974-415.848-435.974-229.75 0-416 200.576-416 448 0 53.020-42.98 96-96 96-53.020 0-96-42.98-96-96 0-282.77 229.23-512 512-512z" />
27
+ <glyph unicode="&#xe600;" d="M1024 351.906v192.188l-146.774 24.462c-5.958 18.132-13.222 35.668-21.694 52.5l86.454 121.034-135.896 135.898-120.826-86.304c-16.91 8.554-34.538 15.888-52.768 21.902l-24.402 146.414h-192.188l-24.402-146.416c-18.23-6.014-35.858-13.348-52.766-21.902l-120.828 86.304-135.898-135.898 86.454-121.036c-8.47-16.83-15.734-34.366-21.692-52.498l-146.774-24.46v-192.188l147.118-24.52c5.96-17.968 13.21-35.348 21.642-52.030l-86.748-121.448 135.898-135.896 121.654 86.894c16.602-8.35 33.89-15.528 51.764-21.434l24.578-147.472h192.188l24.578 147.474c17.874 5.906 35.162 13.084 51.766 21.432l121.652-86.892 135.896 135.896-86.744 121.446c8.432 16.682 15.678 34.062 21.64 52.032l147.118 24.518zM512 320c-70.692 0-128 57.306-128 128 0 70.692 57.308 128 128 128 70.694 0 128-57.308 128-128 0-70.694-57.306-128-128-128z" />
28
+ </font></defs></svg>
js/clipvilla/video-js/font/vjs.ttf ADDED
Binary file
js/clipvilla/video-js/font/vjs.woff ADDED
Binary file
js/clipvilla/video-js/lang/de.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ videojs.addLanguage("de",{
2
+ "Play": "Wiedergabe",
3
+ "Pause": "Pause",
4
+ "Current Time": "Aktuelle Uhrzeit",
5
+ "Duration Time": "Laufzeit",
6
+ "Remaining Time": "Verbleibende Zeit",
7
+ "Stream Type": "Streamtyp",
8
+ "LIVE": "LIVE",
9
+ "Loaded": "Geladen",
10
+ "Progress": "Status",
11
+ "Fullscreen": "Vollbild",
12
+ "Non-Fullscreen": "Kein Vollbild",
13
+ "Mute": "Ton aus",
14
+ "Unmuted": "Ton ein",
15
+ "Playback Rate": "Wiedergaberate",
16
+ "Subtitles": "Untertitel",
17
+ "subtitles off": "Untertitel aus",
18
+ "Captions": "Geschlossene Untertitel",
19
+ "captions off": "Geschlossene Untertitel aus",
20
+ "Chapters": "Kapitel",
21
+ "You aborted the video playback": "Sie haben die Videowiedergabe abgebrochen.",
22
+ "A network error caused the video download to fail part-way.": "Der Videodownload ist aufgrund eines Netzwerkfehlers fehlgeschlagen.",
23
+ "The video could not be loaded, either because the server or network failed or because the format is not supported.": "Das Video konnte nicht geladen werden, da entweder ein Server- oder Netzwerkfehler auftrat oder das Format nicht unterstützt wird.",
24
+ "The video playback was aborted due to a corruption problem or because the video used features your browser did not support.": "Die Videowiedergabe wurde entweder wegen eines Problems mit einem beschädigten Video oder wegen verwendeten Funktionen, die vom Browser nicht unterstützt werden, abgebrochen.",
25
+ "No compatible source was found for this video.": "Für dieses Video wurde keine kompatible Quelle gefunden."
26
+ });
js/clipvilla/video-js/lang/es.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ videojs.addLanguage("es",{
2
+ "Play": "Reproducción",
3
+ "Pause": "Pausa",
4
+ "Current Time": "Tiempo reproducido",
5
+ "Duration Time": "Duración total",
6
+ "Remaining Time": "Tiempo restante",
7
+ "Stream Type": "Tipo de secuencia",
8
+ "LIVE": "DIRECTO",
9
+ "Loaded": "Cargado",
10
+ "Progress": "Progreso",
11
+ "Fullscreen": "Pantalla completa",
12
+ "Non-Fullscreen": "Pantalla no completa",
13
+ "Mute": "Silenciar",
14
+ "Unmuted": "No silenciado",
15
+ "Playback Rate": "Velocidad de reproducción",
16
+ "Subtitles": "Subtítulos",
17
+ "subtitles off": "Subtítulos desactivados",
18
+ "Captions": "Subtítulos especiales",
19
+ "captions off": "Subtítulos especiales desactivados",
20
+ "Chapters": "Capítulos",
21
+ "You aborted the video playback": "Ha interrumpido la reproducción del vídeo.",
22
+ "A network error caused the video download to fail part-way.": "Un error de red ha interrumpido la descarga del vídeo.",
23
+ "The video could not be loaded, either because the server or network failed or because the format is not supported.": "No se ha podido cargar el vídeo debido a un fallo de red o del servidor o porque el formato es incompatible.",
24
+ "The video playback was aborted due to a corruption problem or because the video used features your browser did not support.": "La reproducción de vídeo se ha interrumpido por un problema de corrupción de datos o porque el vídeo precisa funciones que su navegador no ofrece.",
25
+ "No compatible source was found for this video.": "No se ha encontrado ninguna fuente compatible con este vídeo."
26
+ });
js/clipvilla/video-js/lang/fr.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ videojs.addLanguage("fr",{
2
+ "Play": "Lecture",
3
+ "Pause": "Pause",
4
+ "Current Time": "Temps actuel",
5
+ "Duration Time": "Durée",
6
+ "Remaining Time": "Temps restant",
7
+ "Stream Type": "Type de flux",
8
+ "LIVE": "EN DIRECT",
9
+ "Loaded": "Chargé",
10
+ "Progress": "Progression",
11
+ "Fullscreen": "Plein écran",
12
+ "Non-Fullscreen": "Fenêtré",
13
+ "Mute": "Sourdine",
14
+ "Unmuted": "Son activé",
15
+ "Playback Rate": "Vitesse de lecture",
16
+ "Subtitles": "Sous-titres",
17
+ "subtitles off": "Sous-titres désactivés",
18
+ "Captions": "Sous-titres",
19
+ "captions off": "Sous-titres désactivés",
20
+ "Chapters": "Chapitres",
21
+ "You aborted the video playback": "Vous avez interrompu la lecture de la vidéo.",
22
+ "A network error caused the video download to fail part-way.": "Une erreur de réseau a interrompu le téléchargement de la vidéo.",
23
+ "The video could not be loaded, either because the server or network failed or because the format is not supported.": "Cette vidéo n'a pas pu être chargée, soit parce que le serveur ou le réseau a échoué ou parce que le format n'est pas reconnu.",
24
+ "The video playback was aborted due to a corruption problem or because the video used features your browser did not support.": "La lecture de la vidéo a été interrompue à cause d'un problème de corruption ou parce que la vidéo utilise des fonctionnalités non prises en charge par votre navigateur.",
25
+ "No compatible source was found for this video.": "Aucune source compatible n'a été trouvée pour cette vidéo."
26
+ });
js/clipvilla/video-js/lang/it.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ videojs.addLanguage("it",{
2
+ "Play": "Play",
3
+ "Pause": "Pausa",
4
+ "Current Time": "Orario attuale",
5
+ "Duration Time": "Durata",
6
+ "Remaining Time": "Tempo rimanente",
7
+ "Stream Type": "Tipo del Streaming",
8
+ "LIVE": "LIVE",
9
+ "Loaded": "Caricato",
10
+ "Progress": "Stato",
11
+ "Fullscreen": "Schermo intero",
12
+ "Non-Fullscreen": "Chiudi schermo intero",
13
+ "Mute": "Muto",
14
+ "Unmuted": "Audio",
15
+ "Playback Rate": "Tasso di riproduzione",
16
+ "Subtitles": "Sottotitoli",
17
+ "subtitles off": "Senza sottotitoli",
18
+ "Captions": "Sottotitoli non udenti",
19
+ "captions off": "Senza sottotitoli non udenti",
20
+ "Chapters": "Capitolo",
21
+ "You aborted the video playback": "La riproduzione del filmato è stata interrotta.",
22
+ "A network error caused the video download to fail part-way.": "Il download del filmato è stato interrotto a causa di un problema rete.",
23
+ "The video could not be loaded, either because the server or network failed or because the format is not supported.": "Il filmato non può essere caricato a causa di un errore nel server o nella rete o perché il formato non viene supportato.",
24
+ "The video playback was aborted due to a corruption problem or because the video used features your browser did not support.": "La riproduzione del filmato è stata interrotta a causa di un file danneggiato o per l’utilizzo di impostazioni non supportate dal browser.",
25
+ "No compatible source was found for this video.": "Non ci sono fonti compatibili per questo filmato."
26
+ });
js/clipvilla/video-js/lang/ja.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ videojs.addLanguage("ja",{
2
+ "Play": "再生",
3
+ "Pause": "一時停止",
4
+ "Current Time": "現在の時間",
5
+ "Duration Time": "長さ",
6
+ "Remaining Time": "残りの時間",
7
+ "Stream Type": "ストリームの種類",
8
+ "LIVE": "ライブ",
9
+ "Loaded": "ロード済み",
10
+ "Progress": "進行状況",
11
+ "Fullscreen": "フルスクリーン",
12
+ "Non-Fullscreen": "フルスクリーン以外",
13
+ "Mute": "ミュート",
14
+ "Unmuted": "ミュート解除",
15
+ "Playback Rate": "再生レート",
16
+ "Subtitles": "サブタイトル",
17
+ "subtitles off": "サブタイトル オフ",
18
+ "Captions": "キャプション",
19
+ "captions off": "キャプション オフ",
20
+ "Chapters": "チャプター",
21
+ "You aborted the video playback": "動画再生を中止しました",
22
+ "A network error caused the video download to fail part-way.": "ネットワーク エラーにより動画のダウンロードが途中で失敗しました",
23
+ "The video could not be loaded, either because the server or network failed or because the format is not supported.": "サーバーまたはネットワークのエラー、またはフォーマットがサポートされていないため、動画をロードできませんでした",
24
+ "The video playback was aborted due to a corruption problem or because the video used features your browser did not support.": "破損の問題、またはお使いのブラウザがサポートしていない機能が動画に使用されていたため、動画の再生が中止されました",
25
+ "No compatible source was found for this video.": "この動画に対して互換性のあるソースが見つかりませんでした"
26
+ });
js/clipvilla/video-js/lang/ko.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ videojs.addLanguage("ko",{
2
+ "Play": "재생",
3
+ "Pause": "일시중지",
4
+ "Current Time": "현재 시간",
5
+ "Duration Time": "지정 기간",
6
+ "Remaining Time": "남은 시간",
7
+ "Stream Type": "스트리밍 유형",
8
+ "LIVE": "라이브",
9
+ "Loaded": "로드됨",
10
+ "Progress": "진행",
11
+ "Fullscreen": "전체 화면",
12
+ "Non-Fullscreen": "전체 화면 해제",
13
+ "Mute": "음소거",
14
+ "Unmuted": "음소거 해제",
15
+ "Playback Rate": "재생 비율",
16
+ "Subtitles": "서브타이틀",
17
+ "subtitles off": "서브타이틀 끄기",
18
+ "Captions": "자막",
19
+ "captions off": "자막 끄기",
20
+ "Chapters": "챕터",
21
+ "You aborted the video playback": "비디오 재생을 취소했습니다.",
22
+ "A network error caused the video download to fail part-way.": "네트워크 오류로 인하여 비디오 일부를 다운로드하지 못 했습니다.",
23
+ "The video could not be loaded, either because the server or network failed or because the format is not supported.": "비디오를 로드할 수 없습니다. 서버 혹은 네트워크 오류 때문이거나 지원되지 않는 형식 때문일 수 있습니다.",
24
+ "The video playback was aborted due to a corruption problem or because the video used features your browser did not support.": "비디오 재생이 취소됐습니다. 비디오가 손상되었거나 비디오가 사용하는 기능을 브라우저에서 지원하지 않는 것 같습니다.",
25
+ "No compatible source was found for this video.": "비디오에 호환되지 않는 소스가 있습니다."
26
+ });
js/clipvilla/video-js/lang/nl.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ videojs.addLanguage("nl",{
2
+ "Play": "Afspelen",
3
+ "Pause": "Pauze",
4
+ "Current Time": "Huidige Tijd",
5
+ "Duration Time": "Looptijd",
6
+ "Remaining Time": "Resterende Tijd",
7
+ "Stream Type": "Stream Type",
8
+ "LIVE": "LIVE",
9
+ "Loaded": "Geladen",
10
+ "Progress": "Status",
11
+ "Fullscreen": "Volledig scherm",
12
+ "Non-Fullscreen": "Geen volledig scherm",
13
+ "Mute": "Geluid Uit",
14
+ "Unmuted": "Geluid Aan",
15
+ "Playback Rate": "Weergave Rate",
16
+ "Subtitles": "Ondertiteling",
17
+ "subtitles off": "Ondertiteling uit",
18
+ "Captions": "Onderschriften",
19
+ "captions off": "Onderschriften uit",
20
+ "Chapters": "Hoofdstukken",
21
+ "You aborted the video playback": "Je hebt de video weergave afgebroken.",
22
+ "A network error caused the video download to fail part-way.": "De video download is mislukt door een netwerkfout.",
23
+ "The video could not be loaded, either because the server or network failed or because the format is not supported.": "De video kon niet worden geladen, veroorzaakt door een server of netwerkfout of het formaat word niet ondersteund.",
24
+ "The video playback was aborted due to a corruption problem or because the video used features your browser did not support.": "De video weergave is afgebroken omdat deze beschadigd is of de video gebruikt functionaliteit die niet door je browser word ondersteund.",
25
+ "No compatible source was found for this video.": "Voor deze video is geen ondersteunde bron gevonden."
26
+ });
js/clipvilla/video-js/lang/pt-BR.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ videojs.addLanguage("pt-BR",{
2
+ "Play": "Tocar",
3
+ "Pause": "Pause",
4
+ "Current Time": "Tempo",
5
+ "Duration Time": "Duração",
6
+ "Remaining Time": "Tempo Restante",
7
+ "Stream Type": "Tipo de Stream",
8
+ "LIVE": "AO VIVO",
9
+ "Loaded": "Carregado",
10
+ "Progress": "Progressão",
11
+ "Fullscreen": "Tela Cheia",
12
+ "Non-Fullscreen": "Tela Normal",
13
+ "Mute": "Mudo",
14
+ "Unmuted": "Habilitar Som",
15
+ "Playback Rate": "Velocidade",
16
+ "Subtitles": "Legendas",
17
+ "subtitles off": "Sem Legendas",
18
+ "Captions": "Anotações",
19
+ "captions off": "Sem Anotações",
20
+ "Chapters": "Capítulos",
21
+ "You aborted the video playback": "Você parou a execução de vídeo.",
22
+ "A network error caused the video download to fail part-way.": "Um erro na rede fez o vídeo parar parcialmente.",
23
+ "The video could not be loaded, either because the server or network failed or because the format is not supported.": "O vídeo não pode ser carregado, ou porque houve um problema com sua rede ou pelo formato do vídeo não ser suportado.",
24
+ "The video playback was aborted due to a corruption problem or because the video used features your browser did not support.": "A Execução foi interrompida por um problema com o vídeo ou por seu navegador não dar suporte ao seu formato.",
25
+ "No compatible source was found for this video.": "Não foi encontrada fonte de vídeo compatível."
26
+ });
js/clipvilla/video-js/lang/ru.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ videojs.addLanguage("ru",{
2
+ "Play": "Воспроизвести",
3
+ "Pause": "Приостановить",
4
+ "Current Time": "Текущее время",
5
+ "Duration Time": "Продолжительность",
6
+ "Remaining Time": "Оставшееся время",
7
+ "Stream Type": "Тип потока",
8
+ "LIVE": "ОНЛАЙН",
9
+ "Loaded": "Загрузка",
10
+ "Progress": "Прогресс",
11
+ "Fullscreen": "Полноэкранный режим",
12
+ "Non-Fullscreen": "Неполноэкранный режим",
13
+ "Mute": "Без звука",
14
+ "Unmuted": "Со звуком",
15
+ "Playback Rate": "Скорость воспроизведения",
16
+ "Subtitles": "Субтитры",
17
+ "subtitles off": "Субтитры выкл.",
18
+ "Captions": "Подписи",
19
+ "captions off": "Подписи выкл.",
20
+ "Chapters": "Главы",
21
+ "You aborted the video playback": "Вы прервали воспроизведение видео",
22
+ "A network error caused the video download to fail part-way.": "Ошибка сети вызвала сбой во время загрузки видео.",
23
+ "The video could not be loaded, either because the server or network failed or because the format is not supported.": "Невозможно загрузить видео из-за сетевого или серверного сбоя либо формат не поддерживается.",
24
+ "The video playback was aborted due to a corruption problem or because the video used features your browser did not support.": "Воспроизведение видео было приостановлено из-за повреждения либо в связи с тем, что видео использует функции, неподдерживаемые вашим браузером.",
25
+ "No compatible source was found for this video.": "Совместимые источники для этого видео отсутствуют."
26
+ });
js/clipvilla/video-js/lang/uk.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ videojs.addLanguage("uk",{
2
+ "Play": "Відтворити",
3
+ "Pause": "Призупинити",
4
+ "Current Time": "Поточний час",
5
+ "Duration Time": "Тривалість",
6
+ "Remaining Time": "Час, що залишився",
7
+ "Stream Type": "Тип потоку",
8
+ "LIVE": "НАЖИВО",
9
+ "Loaded": "Завантаження",
10
+ "Progress": "Прогрес",
11
+ "Fullscreen": "Повноекранний режим",
12
+ "Non-Fullscreen": "Неповноекранний режим",
13
+ "Mute": "Без звуку",
14
+ "Unmuted": "Зі звуком",
15
+ "Playback Rate": "Швидкість відтворення",
16
+ "Subtitles": "Субтитри",
17
+ "subtitles off": "Без субтитрів",
18
+ "Captions": "Підписи",
19
+ "captions off": "Без підписів",
20
+ "Chapters": "Розділи",
21
+ "You aborted the video playback": "Ви припинили відтворення відео",
22
+ "A network error caused the video download to fail part-way.": "Помилка мережі викликала збій під час завантаження відео.",
23
+ "The video could not be loaded, either because the server or network failed or because the format is not supported.": "Неможливо завантажити відео через мережевий чи серверний збій або формат не підтримується.",
24
+ "The video playback was aborted due to a corruption problem or because the video used features your browser did not support.": "Відтворення відео було припинено через пошкодження або у зв'язку з тим, що відео використовує функції, які не підтримуються вашим браузером.",
25
+ "No compatible source was found for this video.": "Сумісні джерела для цього відео відсутні."
26
+ });
js/clipvilla/video-js/video-js.css ADDED
@@ -0,0 +1,961 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ Video.js Default Styles (http://videojs.com)
3
+ Version 4.9.1
4
+ Create your own skin at http://designer.videojs.com
5
+ */
6
+ /* SKIN
7
+ ================================================================================
8
+ The main class name for all skin-specific styles. To make your own skin,
9
+ replace all occurances of 'vjs-default-skin' with a new name. Then add your new
10
+ skin name to your video tag instead of the default skin.
11
+ e.g. <video class="video-js my-skin-name">
12
+ */
13
+ .vjs-default-skin {
14
+ color: #cccccc;
15
+ }
16
+ /* Custom Icon Font
17
+ --------------------------------------------------------------------------------
18
+ The control icons are from a custom font. Each icon corresponds to a character
19
+ (e.g. "\e001"). Font icons allow for easy scaling and coloring of icons.
20
+ */
21
+ @font-face {
22
+ font-family: 'VideoJS';
23
+ src: url('font/vjs.eot');
24
+ src: url('font/vjs.eot?#iefix') format('embedded-opentype'), url('font/vjs.woff') format('woff'), url('font/vjs.ttf') format('truetype'), url('font/vjs.svg#icomoon') format('svg');
25
+ font-weight: normal;
26
+ font-style: normal;
27
+ }
28
+ /* Base UI Component Classes
29
+ --------------------------------------------------------------------------------
30
+ */
31
+ /* Slider - used for Volume bar and Seek bar */
32
+ .vjs-default-skin .vjs-slider {
33
+ /* Replace browser focus hightlight with handle highlight */
34
+ outline: 0;
35
+ position: relative;
36
+ cursor: pointer;
37
+ padding: 0;
38
+ /* background-color-with-alpha */
39
+ background-color: #333333;
40
+ background-color: rgba(51, 51, 51, 0.9);
41
+ }
42
+ .vjs-default-skin .vjs-slider:focus {
43
+ /* box-shadow */
44
+ -webkit-box-shadow: 0 0 2em #ffffff;
45
+ -moz-box-shadow: 0 0 2em #ffffff;
46
+ box-shadow: 0 0 2em #ffffff;
47
+ }
48
+ .vjs-default-skin .vjs-slider-handle {
49
+ position: absolute;
50
+ /* Needed for IE6 */
51
+ left: 0;
52
+ top: 0;
53
+ }
54
+ .vjs-default-skin .vjs-slider-handle:before {
55
+ content: "\e009";
56
+ font-family: VideoJS;
57
+ font-size: 1em;
58
+ line-height: 1;
59
+ text-align: center;
60
+ text-shadow: 0em 0em 1em #fff;
61
+ position: absolute;
62
+ top: 0;
63
+ left: 0;
64
+ /* Rotate the square icon to make a diamond */
65
+ /* transform */
66
+ -webkit-transform: rotate(-45deg);
67
+ -moz-transform: rotate(-45deg);
68
+ -ms-transform: rotate(-45deg);
69
+ -o-transform: rotate(-45deg);
70
+ transform: rotate(-45deg);
71
+ }
72
+ /* Control Bar
73
+ --------------------------------------------------------------------------------
74
+ The default control bar that is a container for most of the controls.
75
+ */
76
+ .vjs-default-skin .vjs-control-bar {
77
+ /* Start hidden */
78
+ display: none;
79
+ position: absolute;
80
+ /* Place control bar at the bottom of the player box/video.
81
+ If you want more margin below the control bar, add more height. */
82
+ bottom: 0;
83
+ /* Use left/right to stretch to 100% width of player div */
84
+ left: 0;
85
+ right: 0;
86
+ /* Height includes any margin you want above or below control items */
87
+ height: 3.0em;
88
+ /* background-color-with-alpha */
89
+ background-color: #07141e;
90
+ background-color: rgba(7, 20, 30, 0.7);
91
+ }
92
+ /* Show the control bar only once the video has started playing */
93
+ .vjs-default-skin.vjs-has-started .vjs-control-bar {
94
+ display: block;
95
+ /* Visibility needed to make sure things hide in older browsers too. */
96
+
97
+ visibility: visible;
98
+ opacity: 1;
99
+ /* transition */
100
+ -webkit-transition: visibility 0.1s, opacity 0.1s;
101
+ -moz-transition: visibility 0.1s, opacity 0.1s;
102
+ -o-transition: visibility 0.1s, opacity 0.1s;
103
+ transition: visibility 0.1s, opacity 0.1s;
104
+ }
105
+ /* Hide the control bar when the video is playing and the user is inactive */
106
+ .vjs-default-skin.vjs-has-started.vjs-user-inactive.vjs-playing .vjs-control-bar {
107
+ display: block;
108
+ visibility: hidden;
109
+ opacity: 0;
110
+ /* transition */
111
+ -webkit-transition: visibility 1s, opacity 1s;
112
+ -moz-transition: visibility 1s, opacity 1s;
113
+ -o-transition: visibility 1s, opacity 1s;
114
+ transition: visibility 1s, opacity 1s;
115
+ }
116
+ .vjs-default-skin.vjs-controls-disabled .vjs-control-bar {
117
+ display: none;
118
+ }
119
+ .vjs-default-skin.vjs-using-native-controls .vjs-control-bar {
120
+ display: none;
121
+ }
122
+ /* The control bar shouldn't show after an error */
123
+ .vjs-default-skin.vjs-error .vjs-control-bar {
124
+ display: none;
125
+ }
126
+ /* Don't hide the control bar if it's audio */
127
+ .vjs-audio.vjs-default-skin.vjs-has-started.vjs-user-inactive.vjs-playing .vjs-control-bar {
128
+ opacity: 1;
129
+ visibility: visible;
130
+ }
131
+ /* IE8 is flakey with fonts, and you have to change the actual content to force
132
+ fonts to show/hide properly.
133
+ - "\9" IE8 hack didn't work for this
134
+ - Found in XP IE8 from http://modern.ie. Does not show up in "IE8 mode" in IE9
135
+ */
136
+ @media \0screen {
137
+ .vjs-default-skin.vjs-user-inactive.vjs-playing .vjs-control-bar :before {
138
+ content: "";
139
+ }
140
+ }
141
+ /* General styles for individual controls. */
142
+ .vjs-default-skin .vjs-control {
143
+ outline: none;
144
+ position: relative;
145
+ float: left;
146
+ text-align: center;
147
+ margin: 0;
148
+ padding: 0;
149
+ height: 3.0em;
150
+ width: 4em;
151
+ }
152
+ /* Font button icons */
153
+ .vjs-default-skin .vjs-control:before {
154
+ font-family: VideoJS;
155
+ font-size: 1.5em;
156
+ line-height: 2;
157
+ position: absolute;
158
+ top: 0;
159
+ left: 0;
160
+ width: 100%;
161
+ height: 100%;
162
+ text-align: center;
163
+ text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
164
+ }
165
+ /* Replacement for focus outline */
166
+ .vjs-default-skin .vjs-control:focus:before,
167
+ .vjs-default-skin .vjs-control:hover:before {
168
+ text-shadow: 0em 0em 1em #ffffff;
169
+ }
170
+ .vjs-default-skin .vjs-control:focus {
171
+ /* outline: 0; */
172
+ /* keyboard-only users cannot see the focus on several of the UI elements when
173
+ this is set to 0 */
174
+
175
+ }
176
+ /* Hide control text visually, but have it available for screenreaders */
177
+ .vjs-default-skin .vjs-control-text {
178
+ /* hide-visually */
179
+ border: 0;
180
+ clip: rect(0 0 0 0);
181
+ height: 1px;
182
+ margin: -1px;
183
+ overflow: hidden;
184
+ padding: 0;
185
+ position: absolute;
186
+ width: 1px;
187
+ }
188
+ /* Play/Pause
189
+ --------------------------------------------------------------------------------
190
+ */
191
+ .vjs-default-skin .vjs-play-control {
192
+ width: 5em;
193
+ cursor: pointer;
194
+ }
195
+ .vjs-default-skin .vjs-play-control:before {
196
+ content: "\e001";
197
+ }
198
+ .vjs-default-skin.vjs-playing .vjs-play-control:before {
199
+ content: "\e002";
200
+ }
201
+ /* Playback toggle
202
+ --------------------------------------------------------------------------------
203
+ */
204
+ .vjs-default-skin .vjs-playback-rate .vjs-playback-rate-value {
205
+ font-size: 1.5em;
206
+ line-height: 2;
207
+ position: absolute;
208
+ top: 0;
209
+ left: 0;
210
+ width: 100%;
211
+ height: 100%;
212
+ text-align: center;
213
+ text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
214
+ }
215
+ .vjs-default-skin .vjs-playback-rate.vjs-menu-button .vjs-menu .vjs-menu-content {
216
+ width: 4em;
217
+ left: -2em;
218
+ list-style: none;
219
+ }
220
+ /* Volume/Mute
221
+ -------------------------------------------------------------------------------- */
222
+ .vjs-default-skin .vjs-mute-control,
223
+ .vjs-default-skin .vjs-volume-menu-button {
224
+ cursor: pointer;
225
+ float: right;
226
+ }
227
+ .vjs-default-skin .vjs-mute-control:before,
228
+ .vjs-default-skin .vjs-volume-menu-button:before {
229
+ content: "\e006";
230
+ }
231
+ .vjs-default-skin .vjs-mute-control.vjs-vol-0:before,
232
+ .vjs-default-skin .vjs-volume-menu-button.vjs-vol-0:before {
233
+ content: "\e003";
234
+ }
235
+ .vjs-default-skin .vjs-mute-control.vjs-vol-1:before,
236
+ .vjs-default-skin .vjs-volume-menu-button.vjs-vol-1:before {
237
+ content: "\e004";
238
+ }
239
+ .vjs-default-skin .vjs-mute-control.vjs-vol-2:before,
240
+ .vjs-default-skin .vjs-volume-menu-button.vjs-vol-2:before {
241
+ content: "\e005";
242
+ }
243
+ .vjs-default-skin .vjs-volume-control {
244
+ width: 5em;
245
+ float: right;
246
+ }
247
+ .vjs-default-skin .vjs-volume-bar {
248
+ width: 5em;
249
+ height: 0.6em;
250
+ margin: 1.1em auto 0;
251
+ }
252
+ .vjs-default-skin .vjs-volume-level {
253
+ position: absolute;
254
+ top: 0;
255
+ left: 0;
256
+ height: 0.5em;
257
+ /* assuming volume starts at 1.0 */
258
+
259
+ width: 100%;
260
+ background: #66a8cc url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAAGCAYAAADgzO9IAAAAP0lEQVQIHWWMAQoAIAgDR/QJ/Ub//04+w7ZICBwcOg5FZi5iBB82AGzixEglJrd4TVK5XUJpskSTEvpdFzX9AB2pGziSQcvAAAAAAElFTkSuQmCC) -50% 0 repeat;
261
+ }
262
+ .vjs-default-skin .vjs-volume-bar .vjs-volume-handle {
263
+ width: 0.5em;
264
+ height: 0.5em;
265
+ /* Assumes volume starts at 1.0. If you change the size of the
266
+ handle relative to the volume bar, you'll need to update this value
267
+ too. */
268
+
269
+ left: 4.5em;
270
+ }
271
+ .vjs-default-skin .vjs-volume-handle:before {
272
+ font-size: 0.9em;
273
+ top: -0.2em;
274
+ left: -0.2em;
275
+ width: 1em;
276
+ height: 1em;
277
+ }
278
+ /* The volume menu button is like menu buttons (captions/subtitles) but works
279
+ a little differently. It needs to be possible to tab to the volume slider
280
+ without hitting space bar on the menu button. To do this we're not using
281
+ display:none to hide the slider menu by default, and instead setting the
282
+ width and height to zero. */
283
+ .vjs-default-skin .vjs-volume-menu-button .vjs-menu {
284
+ display: block;
285
+ width: 0;
286
+ height: 0;
287
+ border-top-color: transparent;
288
+ }
289
+ .vjs-default-skin .vjs-volume-menu-button .vjs-menu .vjs-menu-content {
290
+ height: 0;
291
+ width: 0;
292
+ }
293
+ .vjs-default-skin .vjs-volume-menu-button:hover .vjs-menu,
294
+ .vjs-default-skin .vjs-volume-menu-button .vjs-menu.vjs-lock-showing {
295
+ border-top-color: rgba(7, 40, 50, 0.5);
296
+ /* Same as ul background */
297
+
298
+ }
299
+ .vjs-default-skin .vjs-volume-menu-button:hover .vjs-menu .vjs-menu-content,
300
+ .vjs-default-skin .vjs-volume-menu-button .vjs-menu.vjs-lock-showing .vjs-menu-content {
301
+ height: 2.9em;
302
+ width: 10em;
303
+ }
304
+ /* Progress
305
+ --------------------------------------------------------------------------------
306
+ */
307
+ .vjs-default-skin .vjs-progress-control {
308
+ position: absolute;
309
+ left: 0;
310
+ right: 0;
311
+ width: auto;
312
+ font-size: 0.3em;
313
+ height: 1em;
314
+ /* Set above the rest of the controls. */
315
+ top: -1em;
316
+ /* Shrink the bar slower than it grows. */
317
+ /* transition */
318
+ -webkit-transition: all 0.4s;
319
+ -moz-transition: all 0.4s;
320
+ -o-transition: all 0.4s;
321
+ transition: all 0.4s;
322
+ }
323
+ /* On hover, make the progress bar grow to something that's more clickable.
324
+ This simply changes the overall font for the progress bar, and this
325
+ updates both the em-based widths and heights, as wells as the icon font */
326
+ .vjs-default-skin:hover .vjs-progress-control {
327
+ font-size: .9em;
328
+ /* Even though we're not changing the top/height, we need to include them in
329
+ the transition so they're handled correctly. */
330
+
331
+ /* transition */
332
+ -webkit-transition: all 0.2s;
333
+ -moz-transition: all 0.2s;
334
+ -o-transition: all 0.2s;
335
+ transition: all 0.2s;
336
+ }
337
+ /* Box containing play and load progresses. Also acts as seek scrubber. */
338
+ .vjs-default-skin .vjs-progress-holder {
339
+ height: 100%;
340
+ }
341
+ /* Progress Bars */
342
+ .vjs-default-skin .vjs-progress-holder .vjs-play-progress,
343
+ .vjs-default-skin .vjs-progress-holder .vjs-load-progress,
344
+ .vjs-default-skin .vjs-progress-holder .vjs-load-progress div {
345
+ position: absolute;
346
+ display: block;
347
+ height: 100%;
348
+ margin: 0;
349
+ padding: 0;
350
+ /* updated by javascript during playback */
351
+
352
+ width: 0;
353
+ /* Needed for IE6 */
354
+ left: 0;
355
+ top: 0;
356
+ }
357
+ .vjs-default-skin .vjs-play-progress {
358
+ /*
359
+ Using a data URI to create the white diagonal lines with a transparent
360
+ background. Surprisingly works in IE8.
361
+ Created using http://www.patternify.com
362
+ Changing the first color value will change the bar color.
363
+ Also using a paralax effect to make the lines move backwards.
364
+ The -50% left position makes that happen.
365
+ */
366
+
367
+ background: #66a8cc url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAAGCAYAAADgzO9IAAAAP0lEQVQIHWWMAQoAIAgDR/QJ/Ub//04+w7ZICBwcOg5FZi5iBB82AGzixEglJrd4TVK5XUJpskSTEvpdFzX9AB2pGziSQcvAAAAAAElFTkSuQmCC) -50% 0 repeat;
368
+ }
369
+ .vjs-default-skin .vjs-load-progress {
370
+ background: #646464 /* IE8- Fallback */;
371
+ background: rgba(255, 255, 255, 0.2);
372
+ }
373
+ /* there are child elements of the load progress bar that represent the
374
+ specific time ranges that have been buffered */
375
+ .vjs-default-skin .vjs-load-progress div {
376
+ background: #787878 /* IE8- Fallback */;
377
+ background: rgba(255, 255, 255, 0.1);
378
+ }
379
+ .vjs-default-skin .vjs-seek-handle {
380
+ width: 1.5em;
381
+ height: 100%;
382
+ }
383
+ .vjs-default-skin .vjs-seek-handle:before {
384
+ padding-top: 0.1em /* Minor adjustment */;
385
+ }
386
+ /* Live Mode
387
+ --------------------------------------------------------------------------------
388
+ */
389
+ .vjs-default-skin.vjs-live .vjs-time-controls,
390
+ .vjs-default-skin.vjs-live .vjs-time-divider,
391
+ .vjs-default-skin.vjs-live .vjs-progress-control {
392
+ display: none;
393
+ }
394
+ .vjs-default-skin.vjs-live .vjs-live-display {
395
+ display: block;
396
+ }
397
+ /* Live Display
398
+ --------------------------------------------------------------------------------
399
+ */
400
+ .vjs-default-skin .vjs-live-display {
401
+ display: none;
402
+ font-size: 1em;
403
+ line-height: 3em;
404
+ }
405
+ /* Time Display
406
+ --------------------------------------------------------------------------------
407
+ */
408
+ .vjs-default-skin .vjs-time-controls {
409
+ font-size: 1em;
410
+ /* Align vertically by making the line height the same as the control bar */
411
+ line-height: 3em;
412
+ }
413
+ .vjs-default-skin .vjs-current-time {
414
+ float: left;
415
+ }
416
+ .vjs-default-skin .vjs-duration {
417
+ float: left;
418
+ }
419
+ /* Remaining time is in the HTML, but not included in default design */
420
+ .vjs-default-skin .vjs-remaining-time {
421
+ display: none;
422
+ float: left;
423
+ }
424
+ .vjs-time-divider {
425
+ float: left;
426
+ line-height: 3em;
427
+ }
428
+ /* Fullscreen
429
+ --------------------------------------------------------------------------------
430
+ */
431
+ .vjs-default-skin .vjs-fullscreen-control {
432
+ width: 3.8em;
433
+ cursor: pointer;
434
+ float: right;
435
+ }
436
+ .vjs-default-skin .vjs-fullscreen-control:before {
437
+ content: "\e000";
438
+ }
439
+ /* Switch to the exit icon when the player is in fullscreen */
440
+ .vjs-default-skin.vjs-fullscreen .vjs-fullscreen-control:before {
441
+ content: "\e00b";
442
+ }
443
+ /* Big Play Button (play button at start)
444
+ --------------------------------------------------------------------------------
445
+ Positioning of the play button in the center or other corners can be done more
446
+ easily in the skin designer. http://designer.videojs.com/
447
+ */
448
+ .vjs-default-skin .vjs-big-play-button {
449
+ left: 0.5em;
450
+ top: 0.5em;
451
+ font-size: 3em;
452
+ display: block;
453
+ z-index: 2;
454
+ position: absolute;
455
+ width: 4em;
456
+ height: 2.6em;
457
+ text-align: center;
458
+ vertical-align: middle;
459
+ cursor: pointer;
460
+ opacity: 1;
461
+ /* Need a slightly gray bg so it can be seen on black backgrounds */
462
+ /* background-color-with-alpha */
463
+ background-color: #07141e;
464
+ background-color: rgba(7, 20, 30, 0.7);
465
+ border: 0.1em solid #3b4249;
466
+ /* border-radius */
467
+ -webkit-border-radius: 0.8em;
468
+ -moz-border-radius: 0.8em;
469
+ border-radius: 0.8em;
470
+ /* box-shadow */
471
+ -webkit-box-shadow: 0px 0px 1em rgba(255, 255, 255, 0.25);
472
+ -moz-box-shadow: 0px 0px 1em rgba(255, 255, 255, 0.25);
473
+ box-shadow: 0px 0px 1em rgba(255, 255, 255, 0.25);
474
+ /* transition */
475
+ -webkit-transition: all 0.4s;
476
+ -moz-transition: all 0.4s;
477
+ -o-transition: all 0.4s;
478
+ transition: all 0.4s;
479
+ }
480
+ /* Optionally center */
481
+ .vjs-default-skin.vjs-big-play-centered .vjs-big-play-button {
482
+ /* Center it horizontally */
483
+ left: 50%;
484
+ margin-left: -2.1em;
485
+ /* Center it vertically */
486
+ top: 50%;
487
+ margin-top: -1.4000000000000001em;
488
+ }
489
+ /* Hide if controls are disabled */
490
+ .vjs-default-skin.vjs-controls-disabled .vjs-big-play-button {
491
+ display: none;
492
+ }
493
+ /* Hide when video starts playing */
494
+ .vjs-default-skin.vjs-has-started .vjs-big-play-button {
495
+ display: none;
496
+ }
497
+ /* Hide on mobile devices. Remove when we stop using native controls
498
+ by default on mobile */
499
+ .vjs-default-skin.vjs-using-native-controls .vjs-big-play-button {
500
+ display: none;
501
+ }
502
+ .vjs-default-skin:hover .vjs-big-play-button,
503
+ .vjs-default-skin .vjs-big-play-button:focus {
504
+ outline: 0;
505
+ border-color: #fff;
506
+ /* IE8 needs a non-glow hover state */
507
+ background-color: #505050;
508
+ background-color: rgba(50, 50, 50, 0.75);
509
+ /* box-shadow */
510
+ -webkit-box-shadow: 0 0 3em #ffffff;
511
+ -moz-box-shadow: 0 0 3em #ffffff;
512
+ box-shadow: 0 0 3em #ffffff;
513
+ /* transition */
514
+ -webkit-transition: all 0s;
515
+ -moz-transition: all 0s;
516
+ -o-transition: all 0s;
517
+ transition: all 0s;
518
+ }
519
+ .vjs-default-skin .vjs-big-play-button:before {
520
+ content: "\e001";
521
+ font-family: VideoJS;
522
+ /* In order to center the play icon vertically we need to set the line height
523
+ to the same as the button height */
524
+
525
+ line-height: 2.6em;
526
+ text-shadow: 0.05em 0.05em 0.1em #000;
527
+ text-align: center /* Needed for IE8 */;
528
+ position: absolute;
529
+ left: 0;
530
+ width: 100%;
531
+ height: 100%;
532
+ }
533
+ .vjs-error .vjs-big-play-button {
534
+ display: none;
535
+ }
536
+ /* Error Display
537
+ --------------------------------------------------------------------------------
538
+ */
539
+ .vjs-error-display {
540
+ display: none;
541
+ }
542
+ .vjs-error .vjs-error-display {
543
+ display: block;
544
+ position: absolute;
545
+ left: 0;
546
+ top: 0;
547
+ width: 100%;
548
+ height: 100%;
549
+ }
550
+ .vjs-error .vjs-error-display:before {
551
+ content: 'X';
552
+ font-family: Arial;
553
+ font-size: 4em;
554
+ color: #666666;
555
+ /* In order to center the play icon vertically we need to set the line height
556
+ to the same as the button height */
557
+
558
+ line-height: 1;
559
+ text-shadow: 0.05em 0.05em 0.1em #000;
560
+ text-align: center /* Needed for IE8 */;
561
+ vertical-align: middle;
562
+ position: absolute;
563
+ left: 0;
564
+ top: 50%;
565
+ margin-top: -0.5em;
566
+ width: 100%;
567
+ }
568
+ .vjs-error-display div {
569
+ position: absolute;
570
+ bottom: 1em;
571
+ right: 0;
572
+ left: 0;
573
+ font-size: 1.4em;
574
+ text-align: center;
575
+ padding: 3px;
576
+ background: #000000;
577
+ background: rgba(0, 0, 0, 0.5);
578
+ }
579
+ .vjs-error-display a,
580
+ .vjs-error-display a:visited {
581
+ color: #F4A460;
582
+ }
583
+ /* Loading Spinner
584
+ --------------------------------------------------------------------------------
585
+ */
586
+ .vjs-loading-spinner {
587
+ /* Should be hidden by default */
588
+ display: none;
589
+ position: absolute;
590
+ top: 50%;
591
+ left: 50%;
592
+ font-size: 4em;
593
+ line-height: 1;
594
+ width: 1em;
595
+ height: 1em;
596
+ margin-left: -0.5em;
597
+ margin-top: -0.5em;
598
+ opacity: 0.75;
599
+ }
600
+ /* Show the spinner when waiting for data and seeking to a new time */
601
+ .vjs-waiting .vjs-loading-spinner,
602
+ .vjs-seeking .vjs-loading-spinner {
603
+ display: block;
604
+ /* only animate when showing because it can be processor heavy */
605
+ /* animation */
606
+ -webkit-animation: spin 1.5s infinite linear;
607
+ -moz-animation: spin 1.5s infinite linear;
608
+ -o-animation: spin 1.5s infinite linear;
609
+ animation: spin 1.5s infinite linear;
610
+ }
611
+ /* Errors are unrecoverable without user interaction so hide the spinner */
612
+ .vjs-error .vjs-loading-spinner {
613
+ display: none;
614
+ /* ensure animation doesn't continue while hidden */
615
+ /* animation */
616
+ -webkit-animation: none;
617
+ -moz-animation: none;
618
+ -o-animation: none;
619
+ animation: none;
620
+ }
621
+ .vjs-default-skin .vjs-loading-spinner:before {
622
+ content: "\e01e";
623
+ font-family: VideoJS;
624
+ position: absolute;
625
+ top: 0;
626
+ left: 0;
627
+ width: 1em;
628
+ height: 1em;
629
+ text-align: center;
630
+ text-shadow: 0em 0em 0.1em #000;
631
+ }
632
+ @-moz-keyframes spin {
633
+ 0% {
634
+ -moz-transform: rotate(0deg);
635
+ }
636
+ 100% {
637
+ -moz-transform: rotate(359deg);
638
+ }
639
+ }
640
+ @-webkit-keyframes spin {
641
+ 0% {
642
+ -webkit-transform: rotate(0deg);
643
+ }
644
+ 100% {
645
+ -webkit-transform: rotate(359deg);
646
+ }
647
+ }
648
+ @-o-keyframes spin {
649
+ 0% {
650
+ -o-transform: rotate(0deg);
651
+ }
652
+ 100% {
653
+ -o-transform: rotate(359deg);
654
+ }
655
+ }
656
+ @keyframes spin {
657
+ 0% {
658
+ transform: rotate(0deg);
659
+ }
660
+ 100% {
661
+ transform: rotate(359deg);
662
+ }
663
+ }
664
+ /* Menu Buttons (Captions/Subtitles/etc.)
665
+ --------------------------------------------------------------------------------
666
+ */
667
+ .vjs-default-skin .vjs-menu-button {
668
+ float: right;
669
+ cursor: pointer;
670
+ }
671
+ .vjs-default-skin .vjs-menu {
672
+ display: none;
673
+ position: absolute;
674
+ bottom: 0;
675
+ left: 0em;
676
+ /* (Width of vjs-menu - width of button) / 2 */
677
+
678
+ width: 0em;
679
+ height: 0em;
680
+ margin-bottom: 3em;
681
+ border-left: 2em solid transparent;
682
+ border-right: 2em solid transparent;
683
+ border-top: 1.55em solid #000000;
684
+ /* Same width top as ul bottom */
685
+
686
+ border-top-color: rgba(7, 40, 50, 0.5);
687
+ /* Same as ul background */
688
+
689
+ }
690
+ /* Button Pop-up Menu */
691
+ .vjs-default-skin .vjs-menu-button .vjs-menu .vjs-menu-content {
692
+ display: block;
693
+ padding: 0;
694
+ margin: 0;
695
+ position: absolute;
696
+ width: 10em;
697
+ bottom: 1.5em;
698
+ /* Same bottom as vjs-menu border-top */
699
+
700
+ max-height: 15em;
701
+ overflow: auto;
702
+ left: -5em;
703
+ /* Width of menu - width of button / 2 */
704
+
705
+ /* background-color-with-alpha */
706
+ background-color: #07141e;
707
+ background-color: rgba(7, 20, 30, 0.7);
708
+ /* box-shadow */
709
+ -webkit-box-shadow: -0.2em -0.2em 0.3em rgba(255, 255, 255, 0.2);
710
+ -moz-box-shadow: -0.2em -0.2em 0.3em rgba(255, 255, 255, 0.2);
711
+ box-shadow: -0.2em -0.2em 0.3em rgba(255, 255, 255, 0.2);
712
+ }
713
+ .vjs-default-skin .vjs-menu-button:hover .vjs-control-content .vjs-menu,
714
+ .vjs-default-skin .vjs-control-content .vjs-menu.vjs-lock-showing {
715
+ display: block;
716
+ }
717
+ .vjs-default-skin .vjs-menu-button ul li {
718
+ list-style: none;
719
+ margin: 0;
720
+ padding: 0.3em 0 0.3em 0;
721
+ line-height: 1.4em;
722
+ font-size: 1.2em;
723
+ text-align: center;
724
+ text-transform: lowercase;
725
+ }
726
+ .vjs-default-skin .vjs-menu-button ul li.vjs-selected {
727
+ background-color: #000;
728
+ }
729
+ .vjs-default-skin .vjs-menu-button ul li:focus,
730
+ .vjs-default-skin .vjs-menu-button ul li:hover,
731
+ .vjs-default-skin .vjs-menu-button ul li.vjs-selected:focus,
732
+ .vjs-default-skin .vjs-menu-button ul li.vjs-selected:hover {
733
+ outline: 0;
734
+ color: #111;
735
+ /* background-color-with-alpha */
736
+ background-color: #ffffff;
737
+ background-color: rgba(255, 255, 255, 0.75);
738
+ /* box-shadow */
739
+ -webkit-box-shadow: 0 0 1em #ffffff;
740
+ -moz-box-shadow: 0 0 1em #ffffff;
741
+ box-shadow: 0 0 1em #ffffff;
742
+ }
743
+ .vjs-default-skin .vjs-menu-button ul li.vjs-menu-title {
744
+ text-align: center;
745
+ text-transform: uppercase;
746
+ font-size: 1em;
747
+ line-height: 2em;
748
+ padding: 0;
749
+ margin: 0 0 0.3em 0;
750
+ font-weight: bold;
751
+ cursor: default;
752
+ }
753
+ /* Subtitles Button */
754
+ .vjs-default-skin .vjs-subtitles-button:before {
755
+ content: "\e00c";
756
+ }
757
+ /* Captions Button */
758
+ .vjs-default-skin .vjs-captions-button:before {
759
+ content: "\e008";
760
+ }
761
+ /* Chapters Button */
762
+ .vjs-default-skin .vjs-chapters-button:before {
763
+ content: "\e00c";
764
+ }
765
+ .vjs-default-skin .vjs-chapters-button.vjs-menu-button .vjs-menu .vjs-menu-content {
766
+ width: 24em;
767
+ left: -12em;
768
+ }
769
+ /* Replacement for focus outline */
770
+ .vjs-default-skin .vjs-captions-button:focus .vjs-control-content:before,
771
+ .vjs-default-skin .vjs-captions-button:hover .vjs-control-content:before {
772
+ /* box-shadow */
773
+ -webkit-box-shadow: 0 0 1em #ffffff;
774
+ -moz-box-shadow: 0 0 1em #ffffff;
775
+ box-shadow: 0 0 1em #ffffff;
776
+ }
777
+ /*
778
+ REQUIRED STYLES (be careful overriding)
779
+ ================================================================================
780
+ When loading the player, the video tag is replaced with a DIV,
781
+ that will hold the video tag or object tag for other playback methods.
782
+ The div contains the video playback element (Flash or HTML5) and controls,
783
+ and sets the width and height of the video.
784
+
785
+ ** If you want to add some kind of border/padding (e.g. a frame), or special
786
+ positioning, use another containing element. Otherwise you risk messing up
787
+ control positioning and full window mode. **
788
+ */
789
+ .video-js {
790
+ background-color: #000;
791
+ position: relative;
792
+ padding: 0;
793
+ /* Start with 10px for base font size so other dimensions can be em based and
794
+ easily calculable. */
795
+
796
+ font-size: 10px;
797
+ /* Allow poster to be vertially aligned. */
798
+
799
+ vertical-align: middle;
800
+ /* display: table-cell; */
801
+ /*This works in Safari but not Firefox.*/
802
+
803
+ /* Provide some basic defaults for fonts */
804
+
805
+ font-weight: normal;
806
+ font-style: normal;
807
+ /* Avoiding helvetica: issue #376 */
808
+
809
+ font-family: Arial, sans-serif;
810
+ /* Turn off user selection (text highlighting) by default.
811
+ The majority of player components will not be text blocks.
812
+ Text areas will need to turn user selection back on. */
813
+
814
+ /* user-select */
815
+ -webkit-user-select: none;
816
+ -moz-user-select: none;
817
+ -ms-user-select: none;
818
+ user-select: none;
819
+ }
820
+ /* Playback technology elements expand to the width/height of the containing div
821
+ <video> or <object> */
822
+ .video-js .vjs-tech {
823
+ position: absolute;
824
+ top: 0;
825
+ left: 0;
826
+ width: 100%;
827
+ height: 100%;
828
+ }
829
+ /* Fix for Firefox 9 fullscreen (only if it is enabled). Not needed when
830
+ checking fullScreenEnabled. */
831
+ .video-js:-moz-full-screen {
832
+ position: absolute;
833
+ }
834
+ /* Fullscreen Styles */
835
+ body.vjs-full-window {
836
+ padding: 0;
837
+ margin: 0;
838
+ height: 100%;
839
+ /* Fix for IE6 full-window. http://www.cssplay.co.uk/layouts/fixed.html */
840
+ overflow-y: auto;
841
+ }
842
+ .video-js.vjs-fullscreen {
843
+ position: fixed;
844
+ overflow: hidden;
845
+ z-index: 1000;
846
+ left: 0;
847
+ top: 0;
848
+ bottom: 0;
849
+ right: 0;
850
+ width: 100% !important;
851
+ height: 100% !important;
852
+ /* IE6 full-window (underscore hack) */
853
+ _position: absolute;
854
+ }
855
+ .video-js:-webkit-full-screen {
856
+ width: 100% !important;
857
+ height: 100% !important;
858
+ }
859
+ .video-js.vjs-fullscreen.vjs-user-inactive {
860
+ cursor: none;
861
+ }
862
+ /* Poster Styles */
863
+ .vjs-poster {
864
+ background-repeat: no-repeat;
865
+ background-position: 50% 50%;
866
+ background-size: contain;
867
+ cursor: pointer;
868
+ margin: 0;
869
+ padding: 0;
870
+ position: absolute;
871
+ top: 0;
872
+ right: 0;
873
+ bottom: 0;
874
+ left: 0;
875
+ }
876
+ .vjs-poster img {
877
+ display: block;
878
+ margin: 0 auto;
879
+ max-height: 100%;
880
+ padding: 0;
881
+ width: 100%;
882
+ }
883
+ /* Hide the poster when native controls are used otherwise it covers them */
884
+ .video-js.vjs-using-native-controls .vjs-poster {
885
+ display: none;
886
+ }
887
+ /* Text Track Styles */
888
+ /* Overall track holder for both captions and subtitles */
889
+ .video-js .vjs-text-track-display {
890
+ text-align: center;
891
+ position: absolute;
892
+ bottom: 4em;
893
+ /* Leave padding on left and right */
894
+ left: 1em;
895
+ right: 1em;
896
+ }
897
+ /* Move captions down when controls aren't being shown */
898
+ .video-js.vjs-user-inactive.vjs-playing .vjs-text-track-display {
899
+ bottom: 1em;
900
+ }
901
+ /* Individual tracks */
902
+ .video-js .vjs-text-track {
903
+ display: none;
904
+ font-size: 1.4em;
905
+ text-align: center;
906
+ margin-bottom: 0.1em;
907
+ /* Transparent black background, or fallback to all black (oldIE) */
908
+ /* background-color-with-alpha */
909
+ background-color: #000000;
910
+ background-color: rgba(0, 0, 0, 0.5);
911
+ }
912
+ .video-js .vjs-subtitles {
913
+ color: #ffffff /* Subtitles are white */;
914
+ }
915
+ .video-js .vjs-captions {
916
+ color: #ffcc66 /* Captions are yellow */;
917
+ }
918
+ .vjs-tt-cue {
919
+ display: block;
920
+ }
921
+ /* Increase font-size when fullscreen */
922
+ .video-js.vjs-fullscreen .vjs-text-track {
923
+ font-size: 3em;
924
+ }
925
+ /* Hide disabled or unsupported controls */
926
+ .vjs-default-skin .vjs-hidden {
927
+ display: none;
928
+ }
929
+ .vjs-lock-showing {
930
+ display: block !important;
931
+ opacity: 1;
932
+ visibility: visible;
933
+ }
934
+ /* In IE8 w/ no JavaScript (no HTML5 shim), the video tag doesn't register.
935
+ The .video-js classname on the video tag also isn't considered.
936
+ This optional paragraph inside the video tag can provide a message to users
937
+ about what's required to play video. */
938
+ .vjs-no-js {
939
+ padding: 20px;
940
+ color: #ccc;
941
+ background-color: #333;
942
+ font-size: 18px;
943
+ font-family: Arial, sans-serif;
944
+ text-align: center;
945
+ width: 300px;
946
+ height: 150px;
947
+ margin: 0px auto;
948
+ }
949
+ .vjs-no-js a,
950
+ .vjs-no-js a:visited {
951
+ color: #F4A460;
952
+ }
953
+
954
+ /* Responsive Player for aspect ratio 16:9 */
955
+ .video-js {
956
+ padding-top: 56.25%
957
+ }
958
+
959
+ /* -----------------------------------------------------------------------------
960
+ The original source of this file lives at
961
+ https://github.com/videojs/video.js/blob/master/src/css/video-js.less */
js/clipvilla/video-js/video.js ADDED
@@ -0,0 +1,8567 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Main function src.
3
+ */
4
+
5
+ // HTML5 Shiv. Must be in <head> to support older browsers.
6
+ document.createElement('video');
7
+ document.createElement('audio');
8
+ document.createElement('track');
9
+
10
+ /**
11
+ * Doubles as the main function for users to create a player instance and also
12
+ * the main library object.
13
+ *
14
+ * **ALIASES** videojs, _V_ (deprecated)
15
+ *
16
+ * The `vjs` function can be used to initialize or retrieve a player.
17
+ *
18
+ * var myPlayer = vjs('my_video_id');
19
+ *
20
+ * @param {String|Element} id Video element or video element ID
21
+ * @param {Object=} options Optional options object for config/settings
22
+ * @param {Function=} ready Optional ready callback
23
+ * @return {vjs.Player} A player instance
24
+ * @namespace
25
+ */
26
+ var vjs = function(id, options, ready){
27
+ var tag; // Element of ID
28
+
29
+ // Allow for element or ID to be passed in
30
+ // String ID
31
+ if (typeof id === 'string') {
32
+
33
+ // Adjust for jQuery ID syntax
34
+ if (id.indexOf('#') === 0) {
35
+ id = id.slice(1);
36
+ }
37
+
38
+ // If a player instance has already been created for this ID return it.
39
+ if (vjs.players[id]) {
40
+ return vjs.players[id];
41
+
42
+ // Otherwise get element for ID
43
+ } else {
44
+ tag = vjs.el(id);
45
+ }
46
+
47
+ // ID is a media element
48
+ } else {
49
+ tag = id;
50
+ }
51
+
52
+ // Check for a useable element
53
+ if (!tag || !tag.nodeName) { // re: nodeName, could be a box div also
54
+ throw new TypeError('The element or ID supplied is not valid. (videojs)'); // Returns
55
+ }
56
+
57
+ // Element may have a player attr referring to an already created player instance.
58
+ // If not, set up a new player and return the instance.
59
+ return tag['player'] || new vjs.Player(tag, options, ready);
60
+ };
61
+
62
+ // Extended name, also available externally, window.videojs
63
+ var videojs = window['videojs'] = vjs;
64
+
65
+ // CDN Version. Used to target right flash swf.
66
+ vjs.CDN_VERSION = '4.10';
67
+ vjs.ACCESS_PROTOCOL = ('https:' == document.location.protocol ? 'https://' : 'http://');
68
+
69
+ /**
70
+ * Global Player instance options, surfaced from vjs.Player.prototype.options_
71
+ * vjs.options = vjs.Player.prototype.options_
72
+ * All options should use string keys so they avoid
73
+ * renaming by closure compiler
74
+ * @type {Object}
75
+ */
76
+ vjs.options = {
77
+ // Default order of fallback technology
78
+ 'techOrder': ['html5','flash'],
79
+ // techOrder: ['flash','html5'],
80
+
81
+ 'html5': {},
82
+ 'flash': {},
83
+
84
+ // Default of web browser is 300x150. Should rely on source width/height.
85
+ 'width': 300,
86
+ 'height': 150,
87
+ // defaultVolume: 0.85,
88
+ 'defaultVolume': 0.00, // The freakin seaguls are driving me crazy!
89
+
90
+ // default playback rates
91
+ 'playbackRates': [],
92
+ // Add playback rate selection by adding rates
93
+ // 'playbackRates': [0.5, 1, 1.5, 2],
94
+
95
+ // default inactivity timeout
96
+ 'inactivityTimeout': 2000,
97
+
98
+ // Included control sets
99
+ 'children': {
100
+ 'mediaLoader': {},
101
+ 'posterImage': {},
102
+ 'textTrackDisplay': {},
103
+ 'loadingSpinner': {},
104
+ 'bigPlayButton': {},
105
+ 'controlBar': {},
106
+ 'errorDisplay': {}
107
+ },
108
+
109
+ 'language': document.getElementsByTagName('html')[0].getAttribute('lang') || navigator.languages && navigator.languages[0] || navigator.userLanguage || navigator.language || 'en',
110
+
111
+ // locales and their language translations
112
+ 'languages': {},
113
+
114
+ // Default message to show when a video cannot be played.
115
+ 'notSupportedMessage': 'No compatible source was found for this video.'
116
+ };
117
+
118
+ // Set CDN Version of swf
119
+ // The added (+) blocks the replace from changing this 4.10 string
120
+ if (vjs.CDN_VERSION !== 'GENERATED'+'_CDN_VSN') {
121
+ videojs.options['flash']['swf'] = vjs.ACCESS_PROTOCOL + 'vjs.zencdn.net/'+vjs.CDN_VERSION+'/video-js.swf';
122
+ }
123
+
124
+ /**
125
+ * Utility function for adding languages to the default options. Useful for
126
+ * amending multiple language support at runtime.
127
+ *
128
+ * Example: vjs.addLanguage('es', {'Hello':'Hola'});
129
+ *
130
+ * @param {String} code The language code or dictionary property
131
+ * @param {Object} data The data values to be translated
132
+ * @return {Object} The resulting global languages dictionary object
133
+ */
134
+ vjs.addLanguage = function(code, data){
135
+ if(vjs.options['languages'][code] !== undefined) {
136
+ vjs.options['languages'][code] = vjs.util.mergeOptions(vjs.options['languages'][code], data);
137
+ } else {
138
+ vjs.options['languages'][code] = data;
139
+ }
140
+ return vjs.options['languages'];
141
+ };
142
+
143
+ /**
144
+ * Global player list
145
+ * @type {Object}
146
+ */
147
+ vjs.players = {};
148
+
149
+ /*!
150
+ * Custom Universal Module Definition (UMD)
151
+ *
152
+ * Video.js will never be a non-browser lib so we can simplify UMD a bunch and
153
+ * still support requirejs and browserify. This also needs to be closure
154
+ * compiler compatible, so string keys are used.
155
+ */
156
+ if (typeof define === 'function' && define['amd']) {
157
+ define([], function(){ return videojs; });
158
+
159
+ // checking that module is an object too because of umdjs/umd#35
160
+ } else if (typeof exports === 'object' && typeof module === 'object') {
161
+ module['exports'] = videojs;
162
+ }
163
+ /**
164
+ * Core Object/Class for objects that use inheritance + contstructors
165
+ *
166
+ * To create a class that can be subclassed itself, extend the CoreObject class.
167
+ *
168
+ * var Animal = CoreObject.extend();
169
+ * var Horse = Animal.extend();
170
+ *
171
+ * The constructor can be defined through the init property of an object argument.
172
+ *
173
+ * var Animal = CoreObject.extend({
174
+ * init: function(name, sound){
175
+ * this.name = name;
176
+ * }
177
+ * });
178
+ *
179
+ * Other methods and properties can be added the same way, or directly to the
180
+ * prototype.
181
+ *
182
+ * var Animal = CoreObject.extend({
183
+ * init: function(name){
184
+ * this.name = name;
185
+ * },
186
+ * getName: function(){
187
+ * return this.name;
188
+ * },
189
+ * sound: '...'
190
+ * });
191
+ *
192
+ * Animal.prototype.makeSound = function(){
193
+ * alert(this.sound);
194
+ * };
195
+ *
196
+ * To create an instance of a class, use the create method.
197
+ *
198
+ * var fluffy = Animal.create('Fluffy');
199
+ * fluffy.getName(); // -> Fluffy
200
+ *
201
+ * Methods and properties can be overridden in subclasses.
202
+ *
203
+ * var Horse = Animal.extend({
204
+ * sound: 'Neighhhhh!'
205
+ * });
206
+ *
207
+ * var horsey = Horse.create('Horsey');
208
+ * horsey.getName(); // -> Horsey
209
+ * horsey.makeSound(); // -> Alert: Neighhhhh!
210
+ *
211
+ * @class
212
+ * @constructor
213
+ */
214
+ vjs.CoreObject = vjs['CoreObject'] = function(){};
215
+ // Manually exporting vjs['CoreObject'] here for Closure Compiler
216
+ // because of the use of the extend/create class methods
217
+ // If we didn't do this, those functions would get flattend to something like
218
+ // `a = ...` and `this.prototype` would refer to the global object instead of
219
+ // CoreObject
220
+
221
+ /**
222
+ * Create a new object that inherits from this Object
223
+ *
224
+ * var Animal = CoreObject.extend();
225
+ * var Horse = Animal.extend();
226
+ *
227
+ * @param {Object} props Functions and properties to be applied to the
228
+ * new object's prototype
229
+ * @return {vjs.CoreObject} An object that inherits from CoreObject
230
+ * @this {*}
231
+ */
232
+ vjs.CoreObject.extend = function(props){
233
+ var init, subObj;
234
+
235
+ props = props || {};
236
+ // Set up the constructor using the supplied init method
237
+ // or using the init of the parent object
238
+ // Make sure to check the unobfuscated version for external libs
239
+ init = props['init'] || props.init || this.prototype['init'] || this.prototype.init || function(){};
240
+ // In Resig's simple class inheritance (previously used) the constructor
241
+ // is a function that calls `this.init.apply(arguments)`
242
+ // However that would prevent us from using `ParentObject.call(this);`
243
+ // in a Child constuctor because the `this` in `this.init`
244
+ // would still refer to the Child and cause an inifinite loop.
245
+ // We would instead have to do
246
+ // `ParentObject.prototype.init.apply(this, argumnents);`
247
+ // Bleh. We're not creating a _super() function, so it's good to keep
248
+ // the parent constructor reference simple.
249
+ subObj = function(){
250
+ init.apply(this, arguments);
251
+ };
252
+
253
+ // Inherit from this object's prototype
254
+ subObj.prototype = vjs.obj.create(this.prototype);
255
+ // Reset the constructor property for subObj otherwise
256
+ // instances of subObj would have the constructor of the parent Object
257
+ subObj.prototype.constructor = subObj;
258
+
259
+ // Make the class extendable
260
+ subObj.extend = vjs.CoreObject.extend;
261
+ // Make a function for creating instances
262
+ subObj.create = vjs.CoreObject.create;
263
+
264
+ // Extend subObj's prototype with functions and other properties from props
265
+ for (var name in props) {
266
+ if (props.hasOwnProperty(name)) {
267
+ subObj.prototype[name] = props[name];
268
+ }
269
+ }
270
+
271
+ return subObj;
272
+ };
273
+
274
+ /**
275
+ * Create a new instace of this Object class
276
+ *
277
+ * var myAnimal = Animal.create();
278
+ *
279
+ * @return {vjs.CoreObject} An instance of a CoreObject subclass
280
+ * @this {*}
281
+ */
282
+ vjs.CoreObject.create = function(){
283
+ // Create a new object that inherits from this object's prototype
284
+ var inst = vjs.obj.create(this.prototype);
285
+
286
+ // Apply this constructor function to the new object
287
+ this.apply(inst, arguments);
288
+
289
+ // Return the new object
290
+ return inst;
291
+ };
292
+ /**
293
+ * @fileoverview Event System (John Resig - Secrets of a JS Ninja http://jsninja.com/)
294
+ * (Original book version wasn't completely usable, so fixed some things and made Closure Compiler compatible)
295
+ * This should work very similarly to jQuery's events, however it's based off the book version which isn't as
296
+ * robust as jquery's, so there's probably some differences.
297
+ */
298
+
299
+ /**
300
+ * Add an event listener to element
301
+ * It stores the handler function in a separate cache object
302
+ * and adds a generic handler to the element's event,
303
+ * along with a unique id (guid) to the element.
304
+ * @param {Element|Object} elem Element or object to bind listeners to
305
+ * @param {String|Array} type Type of event to bind to.
306
+ * @param {Function} fn Event listener.
307
+ * @private
308
+ */
309
+ vjs.on = function(elem, type, fn){
310
+ if (vjs.obj.isArray(type)) {
311
+ return _handleMultipleEvents(vjs.on, elem, type, fn);
312
+ }
313
+
314
+ var data = vjs.getData(elem);
315
+
316
+ // We need a place to store all our handler data
317
+ if (!data.handlers) data.handlers = {};
318
+
319
+ if (!data.handlers[type]) data.handlers[type] = [];
320
+
321
+ if (!fn.guid) fn.guid = vjs.guid++;
322
+
323
+ data.handlers[type].push(fn);
324
+
325
+ if (!data.dispatcher) {
326
+ data.disabled = false;
327
+
328
+ data.dispatcher = function (event){
329
+
330
+ if (data.disabled) return;
331
+ event = vjs.fixEvent(event);
332
+
333
+ var handlers = data.handlers[event.type];
334
+
335
+ if (handlers) {
336
+ // Copy handlers so if handlers are added/removed during the process it doesn't throw everything off.
337
+ var handlersCopy = handlers.slice(0);
338
+
339
+ for (var m = 0, n = handlersCopy.length; m < n; m++) {
340
+ if (event.isImmediatePropagationStopped()) {
341
+ break;
342
+ } else {
343
+ handlersCopy[m].call(elem, event);
344
+ }
345
+ }
346
+ }
347
+ };
348
+ }
349
+
350
+ if (data.handlers[type].length == 1) {
351
+ if (elem.addEventListener) {
352
+ elem.addEventListener(type, data.dispatcher, false);
353
+ } else if (elem.attachEvent) {
354
+ elem.attachEvent('on' + type, data.dispatcher);
355
+ }
356
+ }
357
+ };
358
+
359
+ /**
360
+ * Removes event listeners from an element
361
+ * @param {Element|Object} elem Object to remove listeners from
362
+ * @param {String|Array=} type Type of listener to remove. Don't include to remove all events from element.
363
+ * @param {Function} fn Specific listener to remove. Don't include to remove listeners for an event type.
364
+ * @private
365
+ */
366
+ vjs.off = function(elem, type, fn) {
367
+ // Don't want to add a cache object through getData if not needed
368
+ if (!vjs.hasData(elem)) return;
369
+
370
+ var data = vjs.getData(elem);
371
+
372
+ // If no events exist, nothing to unbind
373
+ if (!data.handlers) { return; }
374
+
375
+ if (vjs.obj.isArray(type)) {
376
+ return _handleMultipleEvents(vjs.off, elem, type, fn);
377
+ }
378
+
379
+ // Utility function
380
+ var removeType = function(t){
381
+ data.handlers[t] = [];
382
+ vjs.cleanUpEvents(elem,t);
383
+ };
384
+
385
+ // Are we removing all bound events?
386
+ if (!type) {
387
+ for (var t in data.handlers) removeType(t);
388
+ return;
389
+ }
390
+
391
+ var handlers = data.handlers[type];
392
+
393
+ // If no handlers exist, nothing to unbind
394
+ if (!handlers) return;
395
+
396
+ // If no listener was provided, remove all listeners for type
397
+ if (!fn) {
398
+ removeType(type);
399
+ return;
400
+ }
401
+
402
+ // We're only removing a single handler
403
+ if (fn.guid) {
404
+ for (var n = 0; n < handlers.length; n++) {
405
+ if (handlers[n].guid === fn.guid) {
406
+ handlers.splice(n--, 1);
407
+ }
408
+ }
409
+ }
410
+
411
+ vjs.cleanUpEvents(elem, type);
412
+ };
413
+
414
+ /**
415
+ * Clean up the listener cache and dispatchers
416
+ * @param {Element|Object} elem Element to clean up
417
+ * @param {String} type Type of event to clean up
418
+ * @private
419
+ */
420
+ vjs.cleanUpEvents = function(elem, type) {
421
+ var data = vjs.getData(elem);
422
+
423
+ // Remove the events of a particular type if there are none left
424
+ if (data.handlers[type].length === 0) {
425
+ delete data.handlers[type];
426
+ // data.handlers[type] = null;
427
+ // Setting to null was causing an error with data.handlers
428
+
429
+ // Remove the meta-handler from the element
430
+ if (elem.removeEventListener) {
431
+ elem.removeEventListener(type, data.dispatcher, false);
432
+ } else if (elem.detachEvent) {
433
+ elem.detachEvent('on' + type, data.dispatcher);
434
+ }
435
+ }
436
+
437
+ // Remove the events object if there are no types left
438
+ if (vjs.isEmpty(data.handlers)) {
439
+ delete data.handlers;
440
+ delete data.dispatcher;
441
+ delete data.disabled;
442
+
443
+ // data.handlers = null;
444
+ // data.dispatcher = null;
445
+ // data.disabled = null;
446
+ }
447
+
448
+ // Finally remove the expando if there is no data left
449
+ if (vjs.isEmpty(data)) {
450
+ vjs.removeData(elem);
451
+ }
452
+ };
453
+
454
+ /**
455
+ * Fix a native event to have standard property values
456
+ * @param {Object} event Event object to fix
457
+ * @return {Object}
458
+ * @private
459
+ */
460
+ vjs.fixEvent = function(event) {
461
+
462
+ function returnTrue() { return true; }
463
+ function returnFalse() { return false; }
464
+
465
+ // Test if fixing up is needed
466
+ // Used to check if !event.stopPropagation instead of isPropagationStopped
467
+ // But native events return true for stopPropagation, but don't have
468
+ // other expected methods like isPropagationStopped. Seems to be a problem
469
+ // with the Javascript Ninja code. So we're just overriding all events now.
470
+ if (!event || !event.isPropagationStopped) {
471
+ var old = event || window.event;
472
+
473
+ event = {};
474
+ // Clone the old object so that we can modify the values event = {};
475
+ // IE8 Doesn't like when you mess with native event properties
476
+ // Firefox returns false for event.hasOwnProperty('type') and other props
477
+ // which makes copying more difficult.
478
+ // TODO: Probably best to create a whitelist of event props
479
+ for (var key in old) {
480
+ // Safari 6.0.3 warns you if you try to copy deprecated layerX/Y
481
+ // Chrome warns you if you try to copy deprecated keyboardEvent.keyLocation
482
+ if (key !== 'layerX' && key !== 'layerY' && key !== 'keyLocation') {
483
+ // Chrome 32+ warns if you try to copy deprecated returnValue, but
484
+ // we still want to if preventDefault isn't supported (IE8).
485
+ if (!(key == 'returnValue' && old.preventDefault)) {
486
+ event[key] = old[key];
487
+ }
488
+ }
489
+ }
490
+
491
+ // The event occurred on this element
492
+ if (!event.target) {
493
+ event.target = event.srcElement || document;
494
+ }
495
+
496
+ // Handle which other element the event is related to
497
+ event.relatedTarget = event.fromElement === event.target ?
498
+ event.toElement :
499
+ event.fromElement;
500
+
501
+ // Stop the default browser action
502
+ event.preventDefault = function () {
503
+ if (old.preventDefault) {
504
+ old.preventDefault();
505
+ }
506
+ event.returnValue = false;
507
+ event.isDefaultPrevented = returnTrue;
508
+ event.defaultPrevented = true;
509
+ };
510
+
511
+ event.isDefaultPrevented = returnFalse;
512
+ event.defaultPrevented = false;
513
+
514
+ // Stop the event from bubbling
515
+ event.stopPropagation = function () {
516
+ if (old.stopPropagation) {
517
+ old.stopPropagation();
518
+ }
519
+ event.cancelBubble = true;
520
+ event.isPropagationStopped = returnTrue;
521
+ };
522
+
523
+ event.isPropagationStopped = returnFalse;
524
+
525
+ // Stop the event from bubbling and executing other handlers
526
+ event.stopImmediatePropagation = function () {
527
+ if (old.stopImmediatePropagation) {
528
+ old.stopImmediatePropagation();
529
+ }
530
+ event.isImmediatePropagationStopped = returnTrue;
531
+ event.stopPropagation();
532
+ };
533
+
534
+ event.isImmediatePropagationStopped = returnFalse;
535
+
536
+ // Handle mouse position
537
+ if (event.clientX != null) {
538
+ var doc = document.documentElement, body = document.body;
539
+
540
+ event.pageX = event.clientX +
541
+ (doc && doc.scrollLeft || body && body.scrollLeft || 0) -
542
+ (doc && doc.clientLeft || body && body.clientLeft || 0);
543
+ event.pageY = event.clientY +
544
+ (doc && doc.scrollTop || body && body.scrollTop || 0) -
545
+ (doc && doc.clientTop || body && body.clientTop || 0);
546
+ }
547
+
548
+ // Handle key presses
549
+ event.which = event.charCode || event.keyCode;
550
+
551
+ // Fix button for mouse clicks:
552
+ // 0 == left; 1 == middle; 2 == right
553
+ if (event.button != null) {
554
+ event.button = (event.button & 1 ? 0 :
555
+ (event.button & 4 ? 1 :
556
+ (event.button & 2 ? 2 : 0)));
557
+ }
558
+ }
559
+
560
+ // Returns fixed-up instance
561
+ return event;
562
+ };
563
+
564
+ /**
565
+ * Trigger an event for an element
566
+ * @param {Element|Object} elem Element to trigger an event on
567
+ * @param {Event|Object|String} event A string (the type) or an event object with a type attribute
568
+ * @private
569
+ */
570
+ vjs.trigger = function(elem, event) {
571
+ // Fetches element data and a reference to the parent (for bubbling).
572
+ // Don't want to add a data object to cache for every parent,
573
+ // so checking hasData first.
574
+ var elemData = (vjs.hasData(elem)) ? vjs.getData(elem) : {};
575
+ var parent = elem.parentNode || elem.ownerDocument;
576
+ // type = event.type || event,
577
+ // handler;
578
+
579
+ // If an event name was passed as a string, creates an event out of it
580
+ if (typeof event === 'string') {
581
+ event = { type:event, target:elem };
582
+ }
583
+ // Normalizes the event properties.
584
+ event = vjs.fixEvent(event);
585
+
586
+ // If the passed element has a dispatcher, executes the established handlers.
587
+ if (elemData.dispatcher) {
588
+ elemData.dispatcher.call(elem, event);
589
+ }
590
+
591
+ // Unless explicitly stopped or the event does not bubble (e.g. media events)
592
+ // recursively calls this function to bubble the event up the DOM.
593
+ if (parent && !event.isPropagationStopped() && event.bubbles !== false) {
594
+ vjs.trigger(parent, event);
595
+
596
+ // If at the top of the DOM, triggers the default action unless disabled.
597
+ } else if (!parent && !event.defaultPrevented) {
598
+ var targetData = vjs.getData(event.target);
599
+
600
+ // Checks if the target has a default action for this event.
601
+ if (event.target[event.type]) {
602
+ // Temporarily disables event dispatching on the target as we have already executed the handler.
603
+ targetData.disabled = true;
604
+ // Executes the default action.
605
+ if (typeof event.target[event.type] === 'function') {
606
+ event.target[event.type]();
607
+ }
608
+ // Re-enables event dispatching.
609
+ targetData.disabled = false;
610
+ }
611
+ }
612
+
613
+ // Inform the triggerer if the default was prevented by returning false
614
+ return !event.defaultPrevented;
615
+ /* Original version of js ninja events wasn't complete.
616
+ * We've since updated to the latest version, but keeping this around
617
+ * for now just in case.
618
+ */
619
+ // // Added in attion to book. Book code was broke.
620
+ // event = typeof event === 'object' ?
621
+ // event[vjs.expando] ?
622
+ // event :
623
+ // new vjs.Event(type, event) :
624
+ // new vjs.Event(type);
625
+
626
+ // event.type = type;
627
+ // if (handler) {
628
+ // handler.call(elem, event);
629
+ // }
630
+
631
+ // // Clean up the event in case it is being reused
632
+ // event.result = undefined;
633
+ // event.target = elem;
634
+ };
635
+
636
+ /**
637
+ * Trigger a listener only once for an event
638
+ * @param {Element|Object} elem Element or object to
639
+ * @param {String|Array} type
640
+ * @param {Function} fn
641
+ * @private
642
+ */
643
+ vjs.one = function(elem, type, fn) {
644
+ if (vjs.obj.isArray(type)) {
645
+ return _handleMultipleEvents(vjs.one, elem, type, fn);
646
+ }
647
+ var func = function(){
648
+ vjs.off(elem, type, func);
649
+ fn.apply(this, arguments);
650
+ };
651
+ // copy the guid to the new function so it can removed using the original function's ID
652
+ func.guid = fn.guid = fn.guid || vjs.guid++;
653
+ vjs.on(elem, type, func);
654
+ };
655
+
656
+ /**
657
+ * Loops through an array of event types and calls the requested method for each type.
658
+ * @param {Function} fn The event method we want to use.
659
+ * @param {Element|Object} elem Element or object to bind listeners to
660
+ * @param {String} type Type of event to bind to.
661
+ * @param {Function} callback Event listener.
662
+ * @private
663
+ */
664
+ function _handleMultipleEvents(fn, elem, type, callback) {
665
+ vjs.arr.forEach(type, function(type) {
666
+ fn(elem, type, callback); //Call the event method for each one of the types
667
+ });
668
+ }
669
+ var hasOwnProp = Object.prototype.hasOwnProperty;
670
+
671
+ /**
672
+ * Creates an element and applies properties.
673
+ * @param {String=} tagName Name of tag to be created.
674
+ * @param {Object=} properties Element properties to be applied.
675
+ * @return {Element}
676
+ * @private
677
+ */
678
+ vjs.createEl = function(tagName, properties){
679
+ var el;
680
+
681
+ tagName = tagName || 'div';
682
+ properties = properties || {};
683
+
684
+ el = document.createElement(tagName);
685
+
686
+ vjs.obj.each(properties, function(propName, val){
687
+ // Not remembering why we were checking for dash
688
+ // but using setAttribute means you have to use getAttribute
689
+
690
+ // The check for dash checks for the aria-* attributes, like aria-label, aria-valuemin.
691
+ // The additional check for "role" is because the default method for adding attributes does not
692
+ // add the attribute "role". My guess is because it's not a valid attribute in some namespaces, although
693
+ // browsers handle the attribute just fine. The W3C allows for aria-* attributes to be used in pre-HTML5 docs.
694
+ // http://www.w3.org/TR/wai-aria-primer/#ariahtml. Using setAttribute gets around this problem.
695
+ if (propName.indexOf('aria-') !== -1 || propName == 'role') {
696
+ el.setAttribute(propName, val);
697
+ } else {
698
+ el[propName] = val;
699
+ }
700
+ });
701
+
702
+ return el;
703
+ };
704
+
705
+ /**
706
+ * Uppercase the first letter of a string
707
+ * @param {String} string String to be uppercased
708
+ * @return {String}
709
+ * @private
710
+ */
711
+ vjs.capitalize = function(string){
712
+ return string.charAt(0).toUpperCase() + string.slice(1);
713
+ };
714
+
715
+ /**
716
+ * Object functions container
717
+ * @type {Object}
718
+ * @private
719
+ */
720
+ vjs.obj = {};
721
+
722
+ /**
723
+ * Object.create shim for prototypal inheritance
724
+ *
725
+ * https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/create
726
+ *
727
+ * @function
728
+ * @param {Object} obj Object to use as prototype
729
+ * @private
730
+ */
731
+ vjs.obj.create = Object.create || function(obj){
732
+ //Create a new function called 'F' which is just an empty object.
733
+ function F() {}
734
+
735
+ //the prototype of the 'F' function should point to the
736
+ //parameter of the anonymous function.
737
+ F.prototype = obj;
738
+
739
+ //create a new constructor function based off of the 'F' function.
740
+ return new F();
741
+ };
742
+
743
+ /**
744
+ * Loop through each property in an object and call a function
745
+ * whose arguments are (key,value)
746
+ * @param {Object} obj Object of properties
747
+ * @param {Function} fn Function to be called on each property.
748
+ * @this {*}
749
+ * @private
750
+ */
751
+ vjs.obj.each = function(obj, fn, context){
752
+ for (var key in obj) {
753
+ if (hasOwnProp.call(obj, key)) {
754
+ fn.call(context || this, key, obj[key]);
755
+ }
756
+ }
757
+ };
758
+
759
+ /**
760
+ * Merge two objects together and return the original.
761
+ * @param {Object} obj1
762
+ * @param {Object} obj2
763
+ * @return {Object}
764
+ * @private
765
+ */
766
+ vjs.obj.merge = function(obj1, obj2){
767
+ if (!obj2) { return obj1; }
768
+ for (var key in obj2){
769
+ if (hasOwnProp.call(obj2, key)) {
770
+ obj1[key] = obj2[key];
771
+ }
772
+ }
773
+ return obj1;
774
+ };
775
+
776
+ /**
777
+ * Merge two objects, and merge any properties that are objects
778
+ * instead of just overwriting one. Uses to merge options hashes
779
+ * where deeper default settings are important.
780
+ * @param {Object} obj1 Object to override
781
+ * @param {Object} obj2 Overriding object
782
+ * @return {Object} New object. Obj1 and Obj2 will be untouched.
783
+ * @private
784
+ */
785
+ vjs.obj.deepMerge = function(obj1, obj2){
786
+ var key, val1, val2;
787
+
788
+ // make a copy of obj1 so we're not ovewriting original values.
789
+ // like prototype.options_ and all sub options objects
790
+ obj1 = vjs.obj.copy(obj1);
791
+
792
+ for (key in obj2){
793
+ if (hasOwnProp.call(obj2, key)) {
794
+ val1 = obj1[key];
795
+ val2 = obj2[key];
796
+
797
+ // Check if both properties are pure objects and do a deep merge if so
798
+ if (vjs.obj.isPlain(val1) && vjs.obj.isPlain(val2)) {
799
+ obj1[key] = vjs.obj.deepMerge(val1, val2);
800
+ } else {
801
+ obj1[key] = obj2[key];
802
+ }
803
+ }
804
+ }
805
+ return obj1;
806
+ };
807
+
808
+ /**
809
+ * Make a copy of the supplied object
810
+ * @param {Object} obj Object to copy
811
+ * @return {Object} Copy of object
812
+ * @private
813
+ */
814
+ vjs.obj.copy = function(obj){
815
+ return vjs.obj.merge({}, obj);
816
+ };
817
+
818
+ /**
819
+ * Check if an object is plain, and not a dom node or any object sub-instance
820
+ * @param {Object} obj Object to check
821
+ * @return {Boolean} True if plain, false otherwise
822
+ * @private
823
+ */
824
+ vjs.obj.isPlain = function(obj){
825
+ return !!obj
826
+ && typeof obj === 'object'
827
+ && obj.toString() === '[object Object]'
828
+ && obj.constructor === Object;
829
+ };
830
+
831
+ /**
832
+ * Check if an object is Array
833
+ * Since instanceof Array will not work on arrays created in another frame we need to use Array.isArray, but since IE8 does not support Array.isArray we need this shim
834
+ * @param {Object} obj Object to check
835
+ * @return {Boolean} True if plain, false otherwise
836
+ * @private
837
+ */
838
+ vjs.obj.isArray = Array.isArray || function(arr) {
839
+ return Object.prototype.toString.call(arr) === '[object Array]';
840
+ };
841
+
842
+ /**
843
+ * Check to see whether the input is NaN or not.
844
+ * NaN is the only JavaScript construct that isn't equal to itself
845
+ * @param {Number} num Number to check
846
+ * @return {Boolean} True if NaN, false otherwise
847
+ * @private
848
+ */
849
+ vjs.isNaN = function(num) {
850
+ return num !== num;
851
+ };
852
+
853
+ /**
854
+ * Bind (a.k.a proxy or Context). A simple method for changing the context of a function
855
+ It also stores a unique id on the function so it can be easily removed from events
856
+ * @param {*} context The object to bind as scope
857
+ * @param {Function} fn The function to be bound to a scope
858
+ * @param {Number=} uid An optional unique ID for the function to be set
859
+ * @return {Function}
860
+ * @private
861
+ */
862
+ vjs.bind = function(context, fn, uid) {
863
+ // Make sure the function has a unique ID
864
+ if (!fn.guid) { fn.guid = vjs.guid++; }
865
+
866
+ // Create the new function that changes the context
867
+ var ret = function() {
868
+ return fn.apply(context, arguments);
869
+ };
870
+
871
+ // Allow for the ability to individualize this function
872
+ // Needed in the case where multiple objects might share the same prototype
873
+ // IF both items add an event listener with the same function, then you try to remove just one
874
+ // it will remove both because they both have the same guid.
875
+ // when using this, you need to use the bind method when you remove the listener as well.
876
+ // currently used in text tracks
877
+ ret.guid = (uid) ? uid + '_' + fn.guid : fn.guid;
878
+
879
+ return ret;
880
+ };
881
+
882
+ /**
883
+ * Element Data Store. Allows for binding data to an element without putting it directly on the element.
884
+ * Ex. Event listneres are stored here.
885
+ * (also from jsninja.com, slightly modified and updated for closure compiler)
886
+ * @type {Object}
887
+ * @private
888
+ */
889
+ vjs.cache = {};
890
+
891
+ /**
892
+ * Unique ID for an element or function
893
+ * @type {Number}
894
+ * @private
895
+ */
896
+ vjs.guid = 1;
897
+
898
+ /**
899
+ * Unique attribute name to store an element's guid in
900
+ * @type {String}
901
+ * @constant
902
+ * @private
903
+ */
904
+ vjs.expando = 'vdata' + (new Date()).getTime();
905
+
906
+ /**
907
+ * Returns the cache object where data for an element is stored
908
+ * @param {Element} el Element to store data for.
909
+ * @return {Object}
910
+ * @private
911
+ */
912
+ vjs.getData = function(el){
913
+ var id = el[vjs.expando];
914
+ if (!id) {
915
+ id = el[vjs.expando] = vjs.guid++;
916
+ vjs.cache[id] = {};
917
+ }
918
+ return vjs.cache[id];
919
+ };
920
+
921
+ /**
922
+ * Returns the cache object where data for an element is stored
923
+ * @param {Element} el Element to store data for.
924
+ * @return {Object}
925
+ * @private
926
+ */
927
+ vjs.hasData = function(el){
928
+ var id = el[vjs.expando];
929
+ return !(!id || vjs.isEmpty(vjs.cache[id]));
930
+ };
931
+
932
+ /**
933
+ * Delete data for the element from the cache and the guid attr from getElementById
934
+ * @param {Element} el Remove data for an element
935
+ * @private
936
+ */
937
+ vjs.removeData = function(el){
938
+ var id = el[vjs.expando];
939
+ if (!id) { return; }
940
+ // Remove all stored data
941
+ // Changed to = null
942
+ // http://coding.smashingmagazine.com/2012/11/05/writing-fast-memory-efficient-javascript/
943
+ // vjs.cache[id] = null;
944
+ delete vjs.cache[id];
945
+
946
+ // Remove the expando property from the DOM node
947
+ try {
948
+ delete el[vjs.expando];
949
+ } catch(e) {
950
+ if (el.removeAttribute) {
951
+ el.removeAttribute(vjs.expando);
952
+ } else {
953
+ // IE doesn't appear to support removeAttribute on the document element
954
+ el[vjs.expando] = null;
955
+ }
956
+ }
957
+ };
958
+
959
+ /**
960
+ * Check if an object is empty
961
+ * @param {Object} obj The object to check for emptiness
962
+ * @return {Boolean}
963
+ * @private
964
+ */
965
+ vjs.isEmpty = function(obj) {
966
+ for (var prop in obj) {
967
+ // Inlude null properties as empty.
968
+ if (obj[prop] !== null) {
969
+ return false;
970
+ }
971
+ }
972
+ return true;
973
+ };
974
+
975
+ /**
976
+ * Check if an element has a CSS class
977
+ * @param {Element} element Element to check
978
+ * @param {String} classToCheck Classname to check
979
+ * @private
980
+ */
981
+ vjs.hasClass = function(element, classToCheck){
982
+ return ((' ' + element.className + ' ').indexOf(' ' + classToCheck + ' ') !== -1);
983
+ };
984
+
985
+
986
+ /**
987
+ * Add a CSS class name to an element
988
+ * @param {Element} element Element to add class name to
989
+ * @param {String} classToAdd Classname to add
990
+ * @private
991
+ */
992
+ vjs.addClass = function(element, classToAdd){
993
+ if (!vjs.hasClass(element, classToAdd)) {
994
+ element.className = element.className === '' ? classToAdd : element.className + ' ' + classToAdd;
995
+ }
996
+ };
997
+
998
+ /**
999
+ * Remove a CSS class name from an element
1000
+ * @param {Element} element Element to remove from class name
1001
+ * @param {String} classToAdd Classname to remove
1002
+ * @private
1003
+ */
1004
+ vjs.removeClass = function(element, classToRemove){
1005
+ var classNames, i;
1006
+
1007
+ if (!vjs.hasClass(element, classToRemove)) {return;}
1008
+
1009
+ classNames = element.className.split(' ');
1010
+
1011
+ // no arr.indexOf in ie8, and we don't want to add a big shim
1012
+ for (i = classNames.length - 1; i >= 0; i--) {
1013
+ if (classNames[i] === classToRemove) {
1014
+ classNames.splice(i,1);
1015
+ }
1016
+ }
1017
+
1018
+ element.className = classNames.join(' ');
1019
+ };
1020
+
1021
+ /**
1022
+ * Element for testing browser HTML5 video capabilities
1023
+ * @type {Element}
1024
+ * @constant
1025
+ * @private
1026
+ */
1027
+ vjs.TEST_VID = vjs.createEl('video');
1028
+
1029
+ /**
1030
+ * Useragent for browser testing.
1031
+ * @type {String}
1032
+ * @constant
1033
+ * @private
1034
+ */
1035
+ vjs.USER_AGENT = navigator.userAgent;
1036
+
1037
+ /**
1038
+ * Device is an iPhone
1039
+ * @type {Boolean}
1040
+ * @constant
1041
+ * @private
1042
+ */
1043
+ vjs.IS_IPHONE = (/iPhone/i).test(vjs.USER_AGENT);
1044
+ vjs.IS_IPAD = (/iPad/i).test(vjs.USER_AGENT);
1045
+ vjs.IS_IPOD = (/iPod/i).test(vjs.USER_AGENT);
1046
+ vjs.IS_IOS = vjs.IS_IPHONE || vjs.IS_IPAD || vjs.IS_IPOD;
1047
+
1048
+ vjs.IOS_VERSION = (function(){
1049
+ var match = vjs.USER_AGENT.match(/OS (\d+)_/i);
1050
+ if (match && match[1]) { return match[1]; }
1051
+ })();
1052
+
1053
+ vjs.IS_ANDROID = (/Android/i).test(vjs.USER_AGENT);
1054
+ vjs.ANDROID_VERSION = (function() {
1055
+ // This matches Android Major.Minor.Patch versions
1056
+ // ANDROID_VERSION is Major.Minor as a Number, if Minor isn't available, then only Major is returned
1057
+ var match = vjs.USER_AGENT.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i),
1058
+ major,
1059
+ minor;
1060
+
1061
+ if (!match) {
1062
+ return null;
1063
+ }
1064
+
1065
+ major = match[1] && parseFloat(match[1]);
1066
+ minor = match[2] && parseFloat(match[2]);
1067
+
1068
+ if (major && minor) {
1069
+ return parseFloat(match[1] + '.' + match[2]);
1070
+ } else if (major) {
1071
+ return major;
1072
+ } else {
1073
+ return null;
1074
+ }
1075
+ })();
1076
+ // Old Android is defined as Version older than 2.3, and requiring a webkit version of the android browser
1077
+ vjs.IS_OLD_ANDROID = vjs.IS_ANDROID && (/webkit/i).test(vjs.USER_AGENT) && vjs.ANDROID_VERSION < 2.3;
1078
+
1079
+ vjs.IS_FIREFOX = (/Firefox/i).test(vjs.USER_AGENT);
1080
+ vjs.IS_CHROME = (/Chrome/i).test(vjs.USER_AGENT);
1081
+
1082
+ vjs.TOUCH_ENABLED = !!(('ontouchstart' in window) || window.DocumentTouch && document instanceof window.DocumentTouch);
1083
+ vjs.BACKGROUND_SIZE_SUPPORTED = 'backgroundSize' in vjs.TEST_VID.style;
1084
+
1085
+ /**
1086
+ * Apply attributes to an HTML element.
1087
+ * @param {Element} el Target element.
1088
+ * @param {Object=} attributes Element attributes to be applied.
1089
+ * @private
1090
+ */
1091
+ vjs.setElementAttributes = function(el, attributes){
1092
+ vjs.obj.each(attributes, function(attrName, attrValue) {
1093
+ if (attrValue === null || typeof attrValue === 'undefined' || attrValue === false) {
1094
+ el.removeAttribute(attrName);
1095
+ } else {
1096
+ el.setAttribute(attrName, (attrValue === true ? '' : attrValue));
1097
+ }
1098
+ });
1099
+ };
1100
+
1101
+ /**
1102
+ * Get an element's attribute values, as defined on the HTML tag
1103
+ * Attributs are not the same as properties. They're defined on the tag
1104
+ * or with setAttribute (which shouldn't be used with HTML)
1105
+ * This will return true or false for boolean attributes.
1106
+ * @param {Element} tag Element from which to get tag attributes
1107
+ * @return {Object}
1108
+ * @private
1109
+ */
1110
+ vjs.getElementAttributes = function(tag){
1111
+ var obj, knownBooleans, attrs, attrName, attrVal;
1112
+
1113
+ obj = {};
1114
+
1115
+ // known boolean attributes
1116
+ // we can check for matching boolean properties, but older browsers
1117
+ // won't know about HTML5 boolean attributes that we still read from
1118
+ knownBooleans = ','+'autoplay,controls,loop,muted,default'+',';
1119
+
1120
+ if (tag && tag.attributes && tag.attributes.length > 0) {
1121
+ attrs = tag.attributes;
1122
+
1123
+ for (var i = attrs.length - 1; i >= 0; i--) {
1124
+ attrName = attrs[i].name;
1125
+ attrVal = attrs[i].value;
1126
+
1127
+ // check for known booleans
1128
+ // the matching element property will return a value for typeof
1129
+ if (typeof tag[attrName] === 'boolean' || knownBooleans.indexOf(','+attrName+',') !== -1) {
1130
+ // the value of an included boolean attribute is typically an empty
1131
+ // string ('') which would equal false if we just check for a false value.
1132
+ // we also don't want support bad code like autoplay='false'
1133
+ attrVal = (attrVal !== null) ? true : false;
1134
+ }
1135
+
1136
+ obj[attrName] = attrVal;
1137
+ }
1138
+ }
1139
+
1140
+ return obj;
1141
+ };
1142
+
1143
+ /**
1144
+ * Get the computed style value for an element
1145
+ * From http://robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/
1146
+ * @param {Element} el Element to get style value for
1147
+ * @param {String} strCssRule Style name
1148
+ * @return {String} Style value
1149
+ * @private
1150
+ */
1151
+ vjs.getComputedDimension = function(el, strCssRule){
1152
+ var strValue = '';
1153
+ if(document.defaultView && document.defaultView.getComputedStyle){
1154
+ strValue = document.defaultView.getComputedStyle(el, '').getPropertyValue(strCssRule);
1155
+
1156
+ } else if(el.currentStyle){
1157
+ // IE8 Width/Height support
1158
+ strValue = el['client'+strCssRule.substr(0,1).toUpperCase() + strCssRule.substr(1)] + 'px';
1159
+ }
1160
+ return strValue;
1161
+ };
1162
+
1163
+ /**
1164
+ * Insert an element as the first child node of another
1165
+ * @param {Element} child Element to insert
1166
+ * @param {[type]} parent Element to insert child into
1167
+ * @private
1168
+ */
1169
+ vjs.insertFirst = function(child, parent){
1170
+ if (parent.firstChild) {
1171
+ parent.insertBefore(child, parent.firstChild);
1172
+ } else {
1173
+ parent.appendChild(child);
1174
+ }
1175
+ };
1176
+
1177
+ /**
1178
+ * Object to hold browser support information
1179
+ * @type {Object}
1180
+ * @private
1181
+ */
1182
+ vjs.browser = {};
1183
+
1184
+ /**
1185
+ * Shorthand for document.getElementById()
1186
+ * Also allows for CSS (jQuery) ID syntax. But nothing other than IDs.
1187
+ * @param {String} id Element ID
1188
+ * @return {Element} Element with supplied ID
1189
+ * @private
1190
+ */
1191
+ vjs.el = function(id){
1192
+ if (id.indexOf('#') === 0) {
1193
+ id = id.slice(1);
1194
+ }
1195
+
1196
+ return document.getElementById(id);
1197
+ };
1198
+
1199
+ /**
1200
+ * Format seconds as a time string, H:MM:SS or M:SS
1201
+ * Supplying a guide (in seconds) will force a number of leading zeros
1202
+ * to cover the length of the guide
1203
+ * @param {Number} seconds Number of seconds to be turned into a string
1204
+ * @param {Number} guide Number (in seconds) to model the string after
1205
+ * @return {String} Time formatted as H:MM:SS or M:SS
1206
+ * @private
1207
+ */
1208
+ vjs.formatTime = function(seconds, guide) {
1209
+ // Default to using seconds as guide
1210
+ guide = guide || seconds;
1211
+ var s = Math.floor(seconds % 60),
1212
+ m = Math.floor(seconds / 60 % 60),
1213
+ h = Math.floor(seconds / 3600),
1214
+ gm = Math.floor(guide / 60 % 60),
1215
+ gh = Math.floor(guide / 3600);
1216
+
1217
+ // handle invalid times
1218
+ if (isNaN(seconds) || seconds === Infinity) {
1219
+ // '-' is false for all relational operators (e.g. <, >=) so this setting
1220
+ // will add the minimum number of fields specified by the guide
1221
+ h = m = s = '-';
1222
+ }
1223
+
1224
+ // Check if we need to show hours
1225
+ h = (h > 0 || gh > 0) ? h + ':' : '';
1226
+
1227
+ // If hours are showing, we may need to add a leading zero.
1228
+ // Always show at least one digit of minutes.
1229
+ m = (((h || gm >= 10) && m < 10) ? '0' + m : m) + ':';
1230
+
1231
+ // Check if leading zero is need for seconds
1232
+ s = (s < 10) ? '0' + s : s;
1233
+
1234
+ return h + m + s;
1235
+ };
1236
+
1237
+ // Attempt to block the ability to select text while dragging controls
1238
+ vjs.blockTextSelection = function(){
1239
+ document.body.focus();
1240
+ document.onselectstart = function () { return false; };
1241
+ };
1242
+ // Turn off text selection blocking
1243
+ vjs.unblockTextSelection = function(){ document.onselectstart = function () { return true; }; };
1244
+
1245
+ /**
1246
+ * Trim whitespace from the ends of a string.
1247
+ * @param {String} string String to trim
1248
+ * @return {String} Trimmed string
1249
+ * @private
1250
+ */
1251
+ vjs.trim = function(str){
1252
+ return (str+'').replace(/^\s+|\s+$/g, '');
1253
+ };
1254
+
1255
+ /**
1256
+ * Should round off a number to a decimal place
1257
+ * @param {Number} num Number to round
1258
+ * @param {Number} dec Number of decimal places to round to
1259
+ * @return {Number} Rounded number
1260
+ * @private
1261
+ */
1262
+ vjs.round = function(num, dec) {
1263
+ if (!dec) { dec = 0; }
1264
+ return Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
1265
+ };
1266
+
1267
+ /**
1268
+ * Should create a fake TimeRange object
1269
+ * Mimics an HTML5 time range instance, which has functions that
1270
+ * return the start and end times for a range
1271
+ * TimeRanges are returned by the buffered() method
1272
+ * @param {Number} start Start time in seconds
1273
+ * @param {Number} end End time in seconds
1274
+ * @return {Object} Fake TimeRange object
1275
+ * @private
1276
+ */
1277
+ vjs.createTimeRange = function(start, end){
1278
+ return {
1279
+ length: 1,
1280
+ start: function() { return start; },
1281
+ end: function() { return end; }
1282
+ };
1283
+ };
1284
+
1285
+ /**
1286
+ * Simple http request for retrieving external files (e.g. text tracks)
1287
+ * @param {String} url URL of resource
1288
+ * @param {Function} onSuccess Success callback
1289
+ * @param {Function=} onError Error callback
1290
+ * @param {Boolean=} withCredentials Flag which allow credentials
1291
+ * @private
1292
+ */
1293
+ vjs.get = function(url, onSuccess, onError, withCredentials){
1294
+ var fileUrl, request, urlInfo, winLoc, crossOrigin;
1295
+
1296
+ onError = onError || function(){};
1297
+
1298
+ if (typeof XMLHttpRequest === 'undefined') {
1299
+ // Shim XMLHttpRequest for older IEs
1300
+ window.XMLHttpRequest = function () {
1301
+ try { return new window.ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch (e) {}
1302
+ try { return new window.ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch (f) {}
1303
+ try { return new window.ActiveXObject('Msxml2.XMLHTTP'); } catch (g) {}
1304
+ throw new Error('This browser does not support XMLHttpRequest.');
1305
+ };
1306
+ }
1307
+
1308
+ request = new XMLHttpRequest();
1309
+
1310
+ urlInfo = vjs.parseUrl(url);
1311
+ winLoc = window.location;
1312
+ // check if url is for another domain/origin
1313
+ // ie8 doesn't know location.origin, so we won't rely on it here
1314
+ crossOrigin = (urlInfo.protocol + urlInfo.host) !== (winLoc.protocol + winLoc.host);
1315
+
1316
+ // Use XDomainRequest for IE if XMLHTTPRequest2 isn't available
1317
+ // 'withCredentials' is only available in XMLHTTPRequest2
1318
+ // Also XDomainRequest has a lot of gotchas, so only use if cross domain
1319
+ if(crossOrigin && window.XDomainRequest && !('withCredentials' in request)) {
1320
+ request = new window.XDomainRequest();
1321
+ request.onload = function() {
1322
+ onSuccess(request.responseText);
1323
+ };
1324
+ request.onerror = onError;
1325
+ // these blank handlers need to be set to fix ie9 http://cypressnorth.com/programming/internet-explorer-aborting-ajax-requests-fixed/
1326
+ request.onprogress = function() {};
1327
+ request.ontimeout = onError;
1328
+
1329
+ // XMLHTTPRequest
1330
+ } else {
1331
+ fileUrl = (urlInfo.protocol == 'file:' || winLoc.protocol == 'file:');
1332
+
1333
+ request.onreadystatechange = function() {
1334
+ if (request.readyState === 4) {
1335
+ if (request.status === 200 || fileUrl && request.status === 0) {
1336
+ onSuccess(request.responseText);
1337
+ } else {
1338
+ onError(request.responseText);
1339
+ }
1340
+ }
1341
+ };
1342
+ }
1343
+
1344
+ // open the connection
1345
+ try {
1346
+ // Third arg is async, or ignored by XDomainRequest
1347
+ request.open('GET', url, true);
1348
+ // withCredentials only supported by XMLHttpRequest2
1349
+ if(withCredentials) {
1350
+ request.withCredentials = true;
1351
+ }
1352
+ } catch(e) {
1353
+ onError(e);
1354
+ return;
1355
+ }
1356
+
1357
+ // send the request
1358
+ try {
1359
+ request.send();
1360
+ } catch(e) {
1361
+ onError(e);
1362
+ }
1363
+ };
1364
+
1365
+ /**
1366
+ * Add to local storage (may removeable)
1367
+ * @private
1368
+ */
1369
+ vjs.setLocalStorage = function(key, value){
1370
+ try {
1371
+ // IE was throwing errors referencing the var anywhere without this
1372
+ var localStorage = window.localStorage || false;
1373
+ if (!localStorage) { return; }
1374
+ localStorage[key] = value;
1375
+ } catch(e) {
1376
+ if (e.code == 22 || e.code == 1014) { // Webkit == 22 / Firefox == 1014
1377
+ vjs.log('LocalStorage Full (VideoJS)', e);
1378
+ } else {
1379
+ if (e.code == 18) {
1380
+ vjs.log('LocalStorage not allowed (VideoJS)', e);
1381
+ } else {
1382
+ vjs.log('LocalStorage Error (VideoJS)', e);
1383
+ }
1384
+ }
1385
+ }
1386
+ };
1387
+
1388
+ /**
1389
+ * Get abosolute version of relative URL. Used to tell flash correct URL.
1390
+ * http://stackoverflow.com/questions/470832/getting-an-absolute-url-from-a-relative-one-ie6-issue
1391
+ * @param {String} url URL to make absolute
1392
+ * @return {String} Absolute URL
1393
+ * @private
1394
+ */
1395
+ vjs.getAbsoluteURL = function(url){
1396
+
1397
+ // Check if absolute URL
1398
+ if (!url.match(/^https?:\/\//)) {
1399
+ // Convert to absolute URL. Flash hosted off-site needs an absolute URL.
1400
+ url = vjs.createEl('div', {
1401
+ innerHTML: '<a href="'+url+'">x</a>'
1402
+ }).firstChild.href;
1403
+ }
1404
+
1405
+ return url;
1406
+ };
1407
+
1408
+
1409
+ /**
1410
+ * Resolve and parse the elements of a URL
1411
+ * @param {String} url The url to parse
1412
+ * @return {Object} An object of url details
1413
+ */
1414
+ vjs.parseUrl = function(url) {
1415
+ var div, a, addToBody, props, details;
1416
+
1417
+ props = ['protocol', 'hostname', 'port', 'pathname', 'search', 'hash', 'host'];
1418
+
1419
+ // add the url to an anchor and let the browser parse the URL
1420
+ a = vjs.createEl('a', { href: url });
1421
+
1422
+ // IE8 (and 9?) Fix
1423
+ // ie8 doesn't parse the URL correctly until the anchor is actually
1424
+ // added to the body, and an innerHTML is needed to trigger the parsing
1425
+ addToBody = (a.host === '' && a.protocol !== 'file:');
1426
+ if (addToBody) {
1427
+ div = vjs.createEl('div');
1428
+ div.innerHTML = '<a href="'+url+'"></a>';
1429
+ a = div.firstChild;
1430
+ // prevent the div from affecting layout
1431
+ div.setAttribute('style', 'display:none; position:absolute;');
1432
+ document.body.appendChild(div);
1433
+ }
1434
+
1435
+ // Copy the specific URL properties to a new object
1436
+ // This is also needed for IE8 because the anchor loses its
1437
+ // properties when it's removed from the dom
1438
+ details = {};
1439
+ for (var i = 0; i < props.length; i++) {
1440
+ details[props[i]] = a[props[i]];
1441
+ }
1442
+
1443
+ if (addToBody) {
1444
+ document.body.removeChild(div);
1445
+ }
1446
+
1447
+ return details;
1448
+ };
1449
+
1450
+ /**
1451
+ * Log messags to the console and history based on the type of message
1452
+ *
1453
+ * @param {String} type The type of message, or `null` for `log`
1454
+ * @param {[type]} args The args to be passed to the log
1455
+ * @private
1456
+ */
1457
+ function _logType(type, args){
1458
+ var argsArray, noop, console;
1459
+
1460
+ // convert args to an array to get array functions
1461
+ argsArray = Array.prototype.slice.call(args);
1462
+ // if there's no console then don't try to output messages
1463
+ // they will still be stored in vjs.log.history
1464
+ // Was setting these once outside of this function, but containing them
1465
+ // in the function makes it easier to test cases where console doesn't exist
1466
+ noop = function(){};
1467
+ console = window['console'] || {
1468
+ 'log': noop,
1469
+ 'warn': noop,
1470
+ 'error': noop
1471
+ };
1472
+
1473
+ if (type) {
1474
+ // add the type to the front of the message
1475
+ argsArray.unshift(type.toUpperCase()+':');
1476
+ } else {
1477
+ // default to log with no prefix
1478
+ type = 'log';
1479
+ }
1480
+
1481
+ // add to history
1482
+ vjs.log.history.push(argsArray);
1483
+
1484
+ // add console prefix after adding to history
1485
+ argsArray.unshift('VIDEOJS:');
1486
+
1487
+ // call appropriate log function
1488
+ if (console[type].apply) {
1489
+ console[type].apply(console, argsArray);
1490
+ } else {
1491
+ // ie8 doesn't allow error.apply, but it will just join() the array anyway
1492
+ console[type](argsArray.join(' '));
1493
+ }
1494
+ }
1495
+
1496
+ /**
1497
+ * Log plain debug messages
1498
+ */
1499
+ vjs.log = function(){
1500
+ _logType(null, arguments);
1501
+ };
1502
+
1503
+ /**
1504
+ * Keep a history of log messages
1505
+ * @type {Array}
1506
+ */
1507
+ vjs.log.history = [];
1508
+
1509
+ /**
1510
+ * Log error messages
1511
+ */
1512
+ vjs.log.error = function(){
1513
+ _logType('error', arguments);
1514
+ };
1515
+
1516
+ /**
1517
+ * Log warning messages
1518
+ */
1519
+ vjs.log.warn = function(){
1520
+ _logType('warn', arguments);
1521
+ };
1522
+
1523
+ // Offset Left
1524
+ // getBoundingClientRect technique from John Resig http://ejohn.org/blog/getboundingclientrect-is-awesome/
1525
+ vjs.findPosition = function(el) {
1526
+ var box, docEl, body, clientLeft, scrollLeft, left, clientTop, scrollTop, top;
1527
+
1528
+ if (el.getBoundingClientRect && el.parentNode) {
1529
+ box = el.getBoundingClientRect();
1530
+ }
1531
+
1532
+ if (!box) {
1533
+ return {
1534
+ left: 0,
1535
+ top: 0
1536
+ };
1537
+ }
1538
+
1539
+ docEl = document.documentElement;
1540
+ body = document.body;
1541
+
1542
+ clientLeft = docEl.clientLeft || body.clientLeft || 0;
1543
+ scrollLeft = window.pageXOffset || body.scrollLeft;
1544
+ left = box.left + scrollLeft - clientLeft;
1545
+
1546
+ clientTop = docEl.clientTop || body.clientTop || 0;
1547
+ scrollTop = window.pageYOffset || body.scrollTop;
1548
+ top = box.top + scrollTop - clientTop;
1549
+
1550
+ // Android sometimes returns slightly off decimal values, so need to round
1551
+ return {
1552
+ left: vjs.round(left),
1553
+ top: vjs.round(top)
1554
+ };
1555
+ };
1556
+
1557
+ /**
1558
+ * Array functions container
1559
+ * @type {Object}
1560
+ * @private
1561
+ */
1562
+ vjs.arr = {};
1563
+
1564
+ /*
1565
+ * Loops through an array and runs a function for each item inside it.
1566
+ * @param {Array} array The array
1567
+ * @param {Function} callback The function to be run for each item
1568
+ * @param {*} thisArg The `this` binding of callback
1569
+ * @returns {Array} The array
1570
+ * @private
1571
+ */
1572
+ vjs.arr.forEach = function(array, callback, thisArg) {
1573
+ if (vjs.obj.isArray(array) && callback instanceof Function) {
1574
+ for (var i = 0, len = array.length; i < len; ++i) {
1575
+ callback.call(thisArg || vjs, array[i], i, array);
1576
+ }
1577
+ }
1578
+
1579
+ return array;
1580
+ };
1581
+ /**
1582
+ * Utility functions namespace
1583
+ * @namespace
1584
+ * @type {Object}
1585
+ */
1586
+ vjs.util = {};
1587
+
1588
+ /**
1589
+ * Merge two options objects, recursively merging any plain object properties as
1590
+ * well. Previously `deepMerge`
1591
+ *
1592
+ * @param {Object} obj1 Object to override values in
1593
+ * @param {Object} obj2 Overriding object
1594
+ * @return {Object} New object -- obj1 and obj2 will be untouched
1595
+ */
1596
+ vjs.util.mergeOptions = function(obj1, obj2){
1597
+ var key, val1, val2;
1598
+
1599
+ // make a copy of obj1 so we're not overwriting original values.
1600
+ // like prototype.options_ and all sub options objects
1601
+ obj1 = vjs.obj.copy(obj1);
1602
+
1603
+ for (key in obj2){
1604
+ if (obj2.hasOwnProperty(key)) {
1605
+ val1 = obj1[key];
1606
+ val2 = obj2[key];
1607
+
1608
+ // Check if both properties are pure objects and do a deep merge if so
1609
+ if (vjs.obj.isPlain(val1) && vjs.obj.isPlain(val2)) {
1610
+ obj1[key] = vjs.util.mergeOptions(val1, val2);
1611
+ } else {
1612
+ obj1[key] = obj2[key];
1613
+ }
1614
+ }
1615
+ }
1616
+ return obj1;
1617
+ };/**
1618
+ * @fileoverview Player Component - Base class for all UI objects
1619
+ *
1620
+ */
1621
+
1622
+ /**
1623
+ * Base UI Component class
1624
+ *
1625
+ * Components are embeddable UI objects that are represented by both a
1626
+ * javascript object and an element in the DOM. They can be children of other
1627
+ * components, and can have many children themselves.
1628
+ *
1629
+ * // adding a button to the player
1630
+ * var button = player.addChild('button');
1631
+ * button.el(); // -> button element
1632
+ *
1633
+ * <div class="video-js">
1634
+ * <div class="vjs-button">Button</div>
1635
+ * </div>
1636
+ *
1637
+ * Components are also event emitters.
1638
+ *
1639
+ * button.on('click', function(){
1640
+ * console.log('Button Clicked!');
1641
+ * });
1642
+ *
1643
+ * button.trigger('customevent');
1644
+ *
1645
+ * @param {Object} player Main Player
1646
+ * @param {Object=} options
1647
+ * @class
1648
+ * @constructor
1649
+ * @extends vjs.CoreObject
1650
+ */
1651
+ vjs.Component = vjs.CoreObject.extend({
1652
+ /**
1653
+ * the constructor function for the class
1654
+ *
1655
+ * @constructor
1656
+ */
1657
+ init: function(player, options, ready){
1658
+ this.player_ = player;
1659
+
1660
+ // Make a copy of prototype.options_ to protect against overriding global defaults
1661
+ this.options_ = vjs.obj.copy(this.options_);
1662
+
1663
+ // Updated options with supplied options
1664
+ options = this.options(options);
1665
+
1666
+ // Get ID from options or options element if one is supplied
1667
+ this.id_ = options['id'] || (options['el'] && options['el']['id']);
1668
+
1669
+ // If there was no ID from the options, generate one
1670
+ if (!this.id_) {
1671
+ // Don't require the player ID function in the case of mock players
1672
+ this.id_ = ((player.id && player.id()) || 'no_player') + '_component_' + vjs.guid++;
1673
+ }
1674
+
1675
+ this.name_ = options['name'] || null;
1676
+
1677
+ // Create element if one wasn't provided in options
1678
+ this.el_ = options['el'] || this.createEl();
1679
+
1680
+ this.children_ = [];
1681
+ this.childIndex_ = {};
1682
+ this.childNameIndex_ = {};
1683
+
1684
+ // Add any child components in options
1685
+ this.initChildren();
1686
+
1687
+ this.ready(ready);
1688
+ // Don't want to trigger ready here or it will before init is actually
1689
+ // finished for all children that run this constructor
1690
+
1691
+ if (options.reportTouchActivity !== false) {
1692
+ this.enableTouchActivity();
1693
+ }
1694
+ }
1695
+ });
1696
+
1697
+ /**
1698
+ * Dispose of the component and all child components
1699
+ */
1700
+ vjs.Component.prototype.dispose = function(){
1701
+ this.trigger({ type: 'dispose', 'bubbles': false });
1702
+
1703
+ // Dispose all children.
1704
+ if (this.children_) {
1705
+ for (var i = this.children_.length - 1; i >= 0; i--) {
1706
+ if (this.children_[i].dispose) {
1707
+ this.children_[i].dispose();
1708
+ }
1709
+ }
1710
+ }
1711
+
1712
+ // Delete child references
1713
+ this.children_ = null;
1714
+ this.childIndex_ = null;
1715
+ this.childNameIndex_ = null;
1716
+
1717
+ // Remove all event listeners.
1718
+ this.off();
1719
+
1720
+ // Remove element from DOM
1721
+ if (this.el_.parentNode) {
1722
+ this.el_.parentNode.removeChild(this.el_);
1723
+ }
1724
+
1725
+ vjs.removeData(this.el_);
1726
+ this.el_ = null;
1727
+ };
1728
+
1729
+ /**
1730
+ * Reference to main player instance
1731
+ *
1732
+ * @type {vjs.Player}
1733
+ * @private
1734
+ */
1735
+ vjs.Component.prototype.player_ = true;
1736
+
1737
+ /**
1738
+ * Return the component's player
1739
+ *
1740
+ * @return {vjs.Player}
1741
+ */
1742
+ vjs.Component.prototype.player = function(){
1743
+ return this.player_;
1744
+ };
1745
+
1746
+ /**
1747
+ * The component's options object
1748
+ *
1749
+ * @type {Object}
1750
+ * @private
1751
+ */
1752
+ vjs.Component.prototype.options_;
1753
+
1754
+ /**
1755
+ * Deep merge of options objects
1756
+ *
1757
+ * Whenever a property is an object on both options objects
1758
+ * the two properties will be merged using vjs.obj.deepMerge.
1759
+ *
1760
+ * This is used for merging options for child components. We
1761
+ * want it to be easy to override individual options on a child
1762
+ * component without having to rewrite all the other default options.
1763
+ *
1764
+ * Parent.prototype.options_ = {
1765
+ * children: {
1766
+ * 'childOne': { 'foo': 'bar', 'asdf': 'fdsa' },
1767
+ * 'childTwo': {},
1768
+ * 'childThree': {}
1769
+ * }
1770
+ * }
1771
+ * newOptions = {
1772
+ * children: {
1773
+ * 'childOne': { 'foo': 'baz', 'abc': '123' }
1774
+ * 'childTwo': null,
1775
+ * 'childFour': {}
1776
+ * }
1777
+ * }
1778
+ *
1779
+ * this.options(newOptions);
1780
+ *
1781
+ * RESULT
1782
+ *
1783
+ * {
1784
+ * children: {
1785
+ * 'childOne': { 'foo': 'baz', 'asdf': 'fdsa', 'abc': '123' },
1786
+ * 'childTwo': null, // Disabled. Won't be initialized.
1787
+ * 'childThree': {},
1788
+ * 'childFour': {}
1789
+ * }
1790
+ * }
1791
+ *
1792
+ * @param {Object} obj Object of new option values
1793
+ * @return {Object} A NEW object of this.options_ and obj merged
1794
+ */
1795
+ vjs.Component.prototype.options = function(obj){
1796
+ if (obj === undefined) return this.options_;
1797
+
1798
+ return this.options_ = vjs.util.mergeOptions(this.options_, obj);
1799
+ };
1800
+
1801
+ /**
1802
+ * The DOM element for the component
1803
+ *
1804
+ * @type {Element}
1805
+ * @private
1806
+ */
1807
+ vjs.Component.prototype.el_;
1808
+
1809
+ /**
1810
+ * Create the component's DOM element
1811
+ *
1812
+ * @param {String=} tagName Element's node type. e.g. 'div'
1813
+ * @param {Object=} attributes An object of element attributes that should be set on the element
1814
+ * @return {Element}
1815
+ */
1816
+ vjs.Component.prototype.createEl = function(tagName, attributes){
1817
+ return vjs.createEl(tagName, attributes);
1818
+ };
1819
+
1820
+ vjs.Component.prototype.localize = function(string){
1821
+ var lang = this.player_.language(),
1822
+ languages = this.player_.languages();
1823
+ if (languages && languages[lang] && languages[lang][string]) {
1824
+ return languages[lang][string];
1825
+ }
1826
+ return string;
1827
+ };
1828
+
1829
+ /**
1830
+ * Get the component's DOM element
1831
+ *
1832
+ * var domEl = myComponent.el();
1833
+ *
1834
+ * @return {Element}
1835
+ */
1836
+ vjs.Component.prototype.el = function(){
1837
+ return this.el_;
1838
+ };
1839
+
1840
+ /**
1841
+ * An optional element where, if defined, children will be inserted instead of
1842
+ * directly in `el_`
1843
+ *
1844
+ * @type {Element}
1845
+ * @private
1846
+ */
1847
+ vjs.Component.prototype.contentEl_;
1848
+
1849
+ /**
1850
+ * Return the component's DOM element for embedding content.
1851
+ * Will either be el_ or a new element defined in createEl.
1852
+ *
1853
+ * @return {Element}
1854
+ */
1855
+ vjs.Component.prototype.contentEl = function(){
1856
+ return this.contentEl_ || this.el_;
1857
+ };
1858
+
1859
+ /**
1860
+ * The ID for the component
1861
+ *
1862
+ * @type {String}
1863
+ * @private
1864
+ */
1865
+ vjs.Component.prototype.id_;
1866
+
1867
+ /**
1868
+ * Get the component's ID
1869
+ *
1870
+ * var id = myComponent.id();
1871
+ *
1872
+ * @return {String}
1873
+ */
1874
+ vjs.Component.prototype.id = function(){
1875
+ return this.id_;
1876
+ };
1877
+
1878
+ /**
1879
+ * The name for the component. Often used to reference the component.
1880
+ *
1881
+ * @type {String}
1882
+ * @private
1883
+ */
1884
+ vjs.Component.prototype.name_;
1885
+
1886
+ /**
1887
+ * Get the component's name. The name is often used to reference the component.
1888
+ *
1889
+ * var name = myComponent.name();
1890
+ *
1891
+ * @return {String}
1892
+ */
1893
+ vjs.Component.prototype.name = function(){
1894
+ return this.name_;
1895
+ };
1896
+
1897
+ /**
1898
+ * Array of child components
1899
+ *
1900
+ * @type {Array}
1901
+ * @private
1902
+ */
1903
+ vjs.Component.prototype.children_;
1904
+
1905
+ /**
1906
+ * Get an array of all child components
1907
+ *
1908
+ * var kids = myComponent.children();
1909
+ *
1910
+ * @return {Array} The children
1911
+ */
1912
+ vjs.Component.prototype.children = function(){
1913
+ return this.children_;
1914
+ };
1915
+
1916
+ /**
1917
+ * Object of child components by ID
1918
+ *
1919
+ * @type {Object}
1920
+ * @private
1921
+ */
1922
+ vjs.Component.prototype.childIndex_;
1923
+
1924
+ /**
1925
+ * Returns a child component with the provided ID
1926
+ *
1927
+ * @return {vjs.Component}
1928
+ */
1929
+ vjs.Component.prototype.getChildById = function(id){
1930
+ return this.childIndex_[id];
1931
+ };
1932
+
1933
+ /**
1934
+ * Object of child components by name
1935
+ *
1936
+ * @type {Object}
1937
+ * @private
1938
+ */
1939
+ vjs.Component.prototype.childNameIndex_;
1940
+
1941
+ /**
1942
+ * Returns a child component with the provided name
1943
+ *
1944
+ * @return {vjs.Component}
1945
+ */
1946
+ vjs.Component.prototype.getChild = function(name){
1947
+ return this.childNameIndex_[name];
1948
+ };
1949
+
1950
+ /**
1951
+ * Adds a child component inside this component
1952
+ *
1953
+ * myComponent.el();
1954
+ * // -> <div class='my-component'></div>
1955
+ * myComonent.children();
1956
+ * // [empty array]
1957
+ *
1958
+ * var myButton = myComponent.addChild('MyButton');
1959
+ * // -> <div class='my-component'><div class="my-button">myButton<div></div>
1960
+ * // -> myButton === myComonent.children()[0];
1961
+ *
1962
+ * Pass in options for child constructors and options for children of the child
1963
+ *
1964
+ * var myButton = myComponent.addChild('MyButton', {
1965
+ * text: 'Press Me',
1966
+ * children: {
1967
+ * buttonChildExample: {
1968
+ * buttonChildOption: true
1969
+ * }
1970
+ * }
1971
+ * });
1972
+ *
1973
+ * @param {String|vjs.Component} child The class name or instance of a child to add
1974
+ * @param {Object=} options Options, including options to be passed to children of the child.
1975
+ * @return {vjs.Component} The child component (created by this process if a string was used)
1976
+ * @suppress {accessControls|checkRegExp|checkTypes|checkVars|const|constantProperty|deprecated|duplicate|es5Strict|fileoverviewTags|globalThis|invalidCasts|missingProperties|nonStandardJsDocs|strictModuleDepCheck|undefinedNames|undefinedVars|unknownDefines|uselessCode|visibility}
1977
+ */
1978
+ vjs.Component.prototype.addChild = function(child, options){
1979
+ var component, componentClass, componentName;
1980
+
1981
+ // If child is a string, create new component with options
1982
+ if (typeof child === 'string') {
1983
+ componentName = child;
1984
+
1985
+ // Make sure options is at least an empty object to protect against errors
1986
+ options = options || {};
1987
+
1988
+ // If no componentClass in options, assume componentClass is the name lowercased
1989
+ // (e.g. playButton)
1990
+ componentClass = options['componentClass'] || vjs.capitalize(componentName);
1991
+
1992
+ // Set name through options
1993
+ options['name'] = componentName;
1994
+
1995
+ // Create a new object & element for this controls set
1996
+ // If there's no .player_, this is a player
1997
+ // Closure Compiler throws an 'incomplete alias' warning if we use the vjs variable directly.
1998
+ // Every class should be exported, so this should never be a problem here.
1999
+ component = new window['videojs'][componentClass](this.player_ || this, options);
2000
+
2001
+ // child is a component instance
2002
+ } else {
2003
+ component = child;
2004
+ }
2005
+
2006
+ this.children_.push(component);
2007
+
2008
+ if (typeof component.id === 'function') {
2009
+ this.childIndex_[component.id()] = component;
2010
+ }
2011
+
2012
+ // If a name wasn't used to create the component, check if we can use the
2013
+ // name function of the component
2014
+ componentName = componentName || (component.name && component.name());
2015
+
2016
+ if (componentName) {
2017
+ this.childNameIndex_[componentName] = component;
2018
+ }
2019
+
2020
+ // Add the UI object's element to the container div (box)
2021
+ // Having an element is not required
2022
+ if (typeof component['el'] === 'function' && component['el']()) {
2023
+ this.contentEl().appendChild(component['el']());
2024
+ }
2025
+
2026
+ // Return so it can stored on parent object if desired.
2027
+ return component;
2028
+ };
2029
+
2030
+ /**
2031
+ * Remove a child component from this component's list of children, and the
2032
+ * child component's element from this component's element
2033
+ *
2034
+ * @param {vjs.Component} component Component to remove
2035
+ */
2036
+ vjs.Component.prototype.removeChild = function(component){
2037
+ if (typeof component === 'string') {
2038
+ component = this.getChild(component);
2039
+ }
2040
+
2041
+ if (!component || !this.children_) return;
2042
+
2043
+ var childFound = false;
2044
+ for (var i = this.children_.length - 1; i >= 0; i--) {
2045
+ if (this.children_[i] === component) {
2046
+ childFound = true;
2047
+ this.children_.splice(i,1);
2048
+ break;
2049
+ }
2050
+ }
2051
+
2052
+ if (!childFound) return;
2053
+
2054
+ this.childIndex_[component.id] = null;
2055
+ this.childNameIndex_[component.name] = null;
2056
+
2057
+ var compEl = component.el();
2058
+ if (compEl && compEl.parentNode === this.contentEl()) {
2059
+ this.contentEl().removeChild(component.el());
2060
+ }
2061
+ };
2062
+
2063
+ /**
2064
+ * Add and initialize default child components from options
2065
+ *
2066
+ * // when an instance of MyComponent is created, all children in options
2067
+ * // will be added to the instance by their name strings and options
2068
+ * MyComponent.prototype.options_.children = {
2069
+ * myChildComponent: {
2070
+ * myChildOption: true
2071
+ * }
2072
+ * }
2073
+ *
2074
+ * // Or when creating the component
2075
+ * var myComp = new MyComponent(player, {
2076
+ * children: {
2077
+ * myChildComponent: {
2078
+ * myChildOption: true
2079
+ * }
2080
+ * }
2081
+ * });
2082
+ *
2083
+ * The children option can also be an Array of child names or
2084
+ * child options objects (that also include a 'name' key).
2085
+ *
2086
+ * var myComp = new MyComponent(player, {
2087
+ * children: [
2088
+ * 'button',
2089
+ * {
2090
+ * name: 'button',
2091
+ * someOtherOption: true
2092
+ * }
2093
+ * ]
2094
+ * });
2095
+ *
2096
+ */
2097
+ vjs.Component.prototype.initChildren = function(){
2098
+ var parent, parentOptions, children, child, name, opts, handleAdd;
2099
+
2100
+ parent = this;
2101
+ parentOptions = parent.options();
2102
+ children = parentOptions['children'];
2103
+
2104
+ if (children) {
2105
+ handleAdd = function(name, opts){
2106
+ // Allow options for children to be set at the parent options
2107
+ // e.g. videojs(id, { controlBar: false });
2108
+ // instead of videojs(id, { children: { controlBar: false });
2109
+ if (parentOptions[name] !== undefined) {
2110
+ opts = parentOptions[name];
2111
+ }
2112
+
2113
+ // Allow for disabling default components
2114
+ // e.g. vjs.options['children']['posterImage'] = false
2115
+ if (opts === false) return;
2116
+
2117
+ // Create and add the child component.
2118
+ // Add a direct reference to the child by name on the parent instance.
2119
+ // If two of the same component are used, different names should be supplied
2120
+ // for each
2121
+ parent[name] = parent.addChild(name, opts);
2122
+ };
2123
+
2124
+ // Allow for an array of children details to passed in the options
2125
+ if (vjs.obj.isArray(children)) {
2126
+ for (var i = 0; i < children.length; i++) {
2127
+ child = children[i];
2128
+
2129
+ if (typeof child == 'string') {
2130
+ // ['myComponent']
2131
+ name = child;
2132
+ opts = {};
2133
+ } else {
2134
+ // [{ name: 'myComponent', otherOption: true }]
2135
+ name = child.name;
2136
+ opts = child;
2137
+ }
2138
+
2139
+ handleAdd(name, opts);
2140
+ }
2141
+ } else {
2142
+ vjs.obj.each(children, handleAdd);
2143
+ }
2144
+ }
2145
+ };
2146
+
2147
+ /**
2148
+ * Allows sub components to stack CSS class names
2149
+ *
2150
+ * @return {String} The constructed class name
2151
+ */
2152
+ vjs.Component.prototype.buildCSSClass = function(){
2153
+ // Child classes can include a function that does:
2154
+ // return 'CLASS NAME' + this._super();
2155
+ return '';
2156
+ };
2157
+
2158
+ /* Events
2159
+ ============================================================================= */
2160
+
2161
+ /**
2162
+ * Add an event listener to this component's element
2163
+ *
2164
+ * var myFunc = function(){
2165
+ * var myComponent = this;
2166
+ * // Do something when the event is fired
2167
+ * };
2168
+ *
2169
+ * myComponent.on('eventType', myFunc);
2170
+ *
2171
+ * The context of myFunc will be myComponent unless previously bound.
2172
+ *
2173
+ * Alternatively, you can add a listener to another element or component.
2174
+ *
2175
+ * myComponent.on(otherElement, 'eventName', myFunc);
2176
+ * myComponent.on(otherComponent, 'eventName', myFunc);
2177
+ *
2178
+ * The benefit of using this over `vjs.on(otherElement, 'eventName', myFunc)`
2179
+ * and `otherComponent.on('eventName', myFunc)` is that this way the listeners
2180
+ * will be automatically cleaned up when either component is diposed.
2181
+ * It will also bind myComponent as the context of myFunc.
2182
+ *
2183
+ * **NOTE**: When using this on elements in the page other than window
2184
+ * and document (both permanent), if you remove the element from the DOM
2185
+ * you need to call `vjs.trigger(el, 'dispose')` on it to clean up
2186
+ * references to it and allow the browser to garbage collect it.
2187
+ *
2188
+ * @param {String|vjs.Component} first The event type or other component
2189
+ * @param {Function|String} second The event handler or event type
2190
+ * @param {Function} third The event handler
2191
+ * @return {vjs.Component} self
2192
+ */
2193
+ vjs.Component.prototype.on = function(first, second, third){
2194
+ var target, type, fn, removeOnDispose, cleanRemover, thisComponent;
2195
+
2196
+ if (typeof first === 'string' || vjs.obj.isArray(first)) {
2197
+ vjs.on(this.el_, first, vjs.bind(this, second));
2198
+
2199
+ // Targeting another component or element
2200
+ } else {
2201
+ target = first;
2202
+ type = second;
2203
+ fn = vjs.bind(this, third);
2204
+ thisComponent = this;
2205
+
2206
+ // When this component is disposed, remove the listener from the other component
2207
+ removeOnDispose = function(){
2208
+ thisComponent.off(target, type, fn);
2209
+ };
2210
+ // Use the same function ID so we can remove it later it using the ID
2211
+ // of the original listener
2212
+ removeOnDispose.guid = fn.guid;
2213
+ this.on('dispose', removeOnDispose);
2214
+
2215
+ // If the other component is disposed first we need to clean the reference
2216
+ // to the other component in this component's removeOnDispose listener
2217
+ // Otherwise we create a memory leak.
2218
+ cleanRemover = function(){
2219
+ thisComponent.off('dispose', removeOnDispose);
2220
+ };
2221
+ // Add the same function ID so we can easily remove it later
2222
+ cleanRemover.guid = fn.guid;
2223
+
2224
+ // Check if this is a DOM node
2225
+ if (first.nodeName) {
2226
+ // Add the listener to the other element
2227
+ vjs.on(target, type, fn);
2228
+ vjs.on(target, 'dispose', cleanRemover);
2229
+
2230
+ // Should be a component
2231
+ // Not using `instanceof vjs.Component` because it makes mock players difficult
2232
+ } else if (typeof first.on === 'function') {
2233
+ // Add the listener to the other component
2234
+ target.on(type, fn);
2235
+ target.on('dispose', cleanRemover);
2236
+ }
2237
+ }
2238
+
2239
+ return this;
2240
+ };
2241
+
2242
+ /**
2243
+ * Remove an event listener from this component's element
2244
+ *
2245
+ * myComponent.off('eventType', myFunc);
2246
+ *
2247
+ * If myFunc is excluded, ALL listeners for the event type will be removed.
2248
+ * If eventType is excluded, ALL listeners will be removed from the component.
2249
+ *
2250
+ * Alternatively you can use `off` to remove listeners that were added to other
2251
+ * elements or components using `myComponent.on(otherComponent...`.
2252
+ * In this case both the event type and listener function are REQUIRED.
2253
+ *
2254
+ * myComponent.off(otherElement, 'eventType', myFunc);
2255
+ * myComponent.off(otherComponent, 'eventType', myFunc);
2256
+ *
2257
+ * @param {String=|vjs.Component} first The event type or other component
2258
+ * @param {Function=|String} second The listener function or event type
2259
+ * @param {Function=} third The listener for other component
2260
+ * @return {vjs.Component}
2261
+ */
2262
+ vjs.Component.prototype.off = function(first, second, third){
2263
+ var target, otherComponent, type, fn, otherEl;
2264
+
2265
+ if (!first || typeof first === 'string' || vjs.obj.isArray(first)) {
2266
+ vjs.off(this.el_, first, second);
2267
+ } else {
2268
+ target = first;
2269
+ type = second;
2270
+ // Ensure there's at least a guid, even if the function hasn't been used
2271
+ fn = vjs.bind(this, third);
2272
+
2273
+ // Remove the dispose listener on this component,
2274
+ // which was given the same guid as the event listener
2275
+ this.off('dispose', fn);
2276
+
2277
+ if (first.nodeName) {
2278
+ // Remove the listener
2279
+ vjs.off(target, type, fn);
2280
+ // Remove the listener for cleaning the dispose listener
2281
+ vjs.off(target, 'dispose', fn);
2282
+ } else {
2283
+ target.off(type, fn);
2284
+ target.off('dispose', fn);
2285
+ }
2286
+ }
2287
+
2288
+ return this;
2289
+ };
2290
+
2291
+ /**
2292
+ * Add an event listener to be triggered only once and then removed
2293
+ *
2294
+ * myComponent.one('eventName', myFunc);
2295
+ *
2296
+ * Alternatively you can add a listener to another element or component
2297
+ * that will be triggered only once.
2298
+ *
2299
+ * myComponent.one(otherElement, 'eventName', myFunc);
2300
+ * myComponent.one(otherComponent, 'eventName', myFunc);
2301
+ *
2302
+ * @param {String|vjs.Component} first The event type or other component
2303
+ * @param {Function|String} second The listener function or event type
2304
+ * @param {Function=} third The listener function for other component
2305
+ * @return {vjs.Component}
2306
+ */
2307
+ vjs.Component.prototype.one = function(first, second, third) {
2308
+ var target, type, fn, thisComponent, newFunc;
2309
+
2310
+ if (typeof first === 'string' || vjs.obj.isArray(first)) {
2311
+ vjs.one(this.el_, first, vjs.bind(this, second));
2312
+ } else {
2313
+ target = first;
2314
+ type = second;
2315
+ fn = vjs.bind(this, third);
2316
+ thisComponent = this;
2317
+
2318
+ newFunc = function(){
2319
+ thisComponent.off(target, type, newFunc);
2320
+ fn.apply(this, arguments);
2321
+ };
2322
+ // Keep the same function ID so we can remove it later
2323
+ newFunc.guid = fn.guid;
2324
+
2325
+ this.on(target, type, newFunc);
2326
+ }
2327
+
2328
+ return this;
2329
+ };
2330
+
2331
+ /**
2332
+ * Trigger an event on an element
2333
+ *
2334
+ * myComponent.trigger('eventName');
2335
+ * myComponent.trigger({'type':'eventName'});
2336
+ *
2337
+ * @param {Event|Object|String} event A string (the type) or an event object with a type attribute
2338
+ * @return {vjs.Component} self
2339
+ */
2340
+ vjs.Component.prototype.trigger = function(event){
2341
+ vjs.trigger(this.el_, event);
2342
+ return this;
2343
+ };
2344
+
2345
+ /* Ready
2346
+ ================================================================================ */
2347
+ /**
2348
+ * Is the component loaded
2349
+ * This can mean different things depending on the component.
2350
+ *
2351
+ * @private
2352
+ * @type {Boolean}
2353
+ */
2354
+ vjs.Component.prototype.isReady_;
2355
+
2356
+ /**
2357
+ * Trigger ready as soon as initialization is finished
2358
+ *
2359
+ * Allows for delaying ready. Override on a sub class prototype.
2360
+ * If you set this.isReadyOnInitFinish_ it will affect all components.
2361
+ * Specially used when waiting for the Flash player to asynchrnously load.
2362
+ *
2363
+ * @type {Boolean}
2364
+ * @private
2365
+ */
2366
+ vjs.Component.prototype.isReadyOnInitFinish_ = true;
2367
+
2368
+ /**
2369
+ * List of ready listeners
2370
+ *
2371
+ * @type {Array}
2372
+ * @private
2373
+ */
2374
+ vjs.Component.prototype.readyQueue_;
2375
+
2376
+ /**
2377
+ * Bind a listener to the component's ready state
2378
+ *
2379
+ * Different from event listeners in that if the ready event has already happend
2380
+ * it will trigger the function immediately.
2381
+ *
2382
+ * @param {Function} fn Ready listener
2383
+ * @return {vjs.Component}
2384
+ */
2385
+ vjs.Component.prototype.ready = function(fn){
2386
+ if (fn) {
2387
+ if (this.isReady_) {
2388
+ fn.call(this);
2389
+ } else {
2390
+ if (this.readyQueue_ === undefined) {
2391
+ this.readyQueue_ = [];
2392
+ }
2393
+ this.readyQueue_.push(fn);
2394
+ }
2395
+ }
2396
+ return this;
2397
+ };
2398
+
2399
+ /**
2400
+ * Trigger the ready listeners
2401
+ *
2402
+ * @return {vjs.Component}
2403
+ */
2404
+ vjs.Component.prototype.triggerReady = function(){
2405
+ this.isReady_ = true;
2406
+
2407
+ var readyQueue = this.readyQueue_;
2408
+
2409
+ if (readyQueue && readyQueue.length > 0) {
2410
+
2411
+ for (var i = 0, j = readyQueue.length; i < j; i++) {
2412
+ readyQueue[i].call(this);
2413
+ }
2414
+
2415
+ // Reset Ready Queue
2416
+ this.readyQueue_ = [];
2417
+
2418
+ // Allow for using event listeners also, in case you want to do something everytime a source is ready.
2419
+ this.trigger('ready');
2420
+ }
2421
+ };
2422
+
2423
+ /* Display
2424
+ ============================================================================= */
2425
+
2426
+ /**
2427
+ * Check if a component's element has a CSS class name
2428
+ *
2429
+ * @param {String} classToCheck Classname to check
2430
+ * @return {vjs.Component}
2431
+ */
2432
+ vjs.Component.prototype.hasClass = function(classToCheck){
2433
+ return vjs.hasClass(this.el_, classToCheck);
2434
+ };
2435
+
2436
+ /**
2437
+ * Add a CSS class name to the component's element
2438
+ *
2439
+ * @param {String} classToAdd Classname to add
2440
+ * @return {vjs.Component}
2441
+ */
2442
+ vjs.Component.prototype.addClass = function(classToAdd){
2443
+ vjs.addClass(this.el_, classToAdd);
2444
+ return this;
2445
+ };
2446
+
2447
+ /**
2448
+ * Remove a CSS class name from the component's element
2449
+ *
2450
+ * @param {String} classToRemove Classname to remove
2451
+ * @return {vjs.Component}
2452
+ */
2453
+ vjs.Component.prototype.removeClass = function(classToRemove){
2454
+ vjs.removeClass(this.el_, classToRemove);
2455
+ return this;
2456
+ };
2457
+
2458
+ /**
2459
+ * Show the component element if hidden
2460
+ *
2461
+ * @return {vjs.Component}
2462
+ */
2463
+ vjs.Component.prototype.show = function(){
2464
+ this.el_.style.display = 'block';
2465
+ return this;
2466
+ };
2467
+
2468
+ /**
2469
+ * Hide the component element if currently showing
2470
+ *
2471
+ * @return {vjs.Component}
2472
+ */
2473
+ vjs.Component.prototype.hide = function(){
2474
+ this.el_.style.display = 'none';
2475
+ return this;
2476
+ };
2477
+
2478
+ /**
2479
+ * Lock an item in its visible state
2480
+ * To be used with fadeIn/fadeOut.
2481
+ *
2482
+ * @return {vjs.Component}
2483
+ * @private
2484
+ */
2485
+ vjs.Component.prototype.lockShowing = function(){
2486
+ this.addClass('vjs-lock-showing');
2487
+ return this;
2488
+ };
2489
+
2490
+ /**
2491
+ * Unlock an item to be hidden
2492
+ * To be used with fadeIn/fadeOut.
2493
+ *
2494
+ * @return {vjs.Component}
2495
+ * @private
2496
+ */
2497
+ vjs.Component.prototype.unlockShowing = function(){
2498
+ this.removeClass('vjs-lock-showing');
2499
+ return this;
2500
+ };
2501
+
2502
+ /**
2503
+ * Disable component by making it unshowable
2504
+ *
2505
+ * Currently private because we're movign towards more css-based states.
2506
+ * @private
2507
+ */
2508
+ vjs.Component.prototype.disable = function(){
2509
+ this.hide();
2510
+ this.show = function(){};
2511
+ };
2512
+
2513
+ /**
2514
+ * Set or get the width of the component (CSS values)
2515
+ *
2516
+ * Setting the video tag dimension values only works with values in pixels.
2517
+ * Percent values will not work.
2518
+ * Some percents can be used, but width()/height() will return the number + %,
2519
+ * not the actual computed width/height.
2520
+ *
2521
+ * @param {Number|String=} num Optional width number
2522
+ * @param {Boolean} skipListeners Skip the 'resize' event trigger
2523
+ * @return {vjs.Component} This component, when setting the width
2524
+ * @return {Number|String} The width, when getting
2525
+ */
2526
+ vjs.Component.prototype.width = function(num, skipListeners){
2527
+ return this.dimension('width', num, skipListeners);
2528
+ };
2529
+
2530
+ /**
2531
+ * Get or set the height of the component (CSS values)
2532
+ *
2533
+ * Setting the video tag dimension values only works with values in pixels.
2534
+ * Percent values will not work.
2535
+ * Some percents can be used, but width()/height() will return the number + %,
2536
+ * not the actual computed width/height.
2537
+ *
2538
+ * @param {Number|String=} num New component height
2539
+ * @param {Boolean=} skipListeners Skip the resize event trigger
2540
+ * @return {vjs.Component} This component, when setting the height
2541
+ * @return {Number|String} The height, when getting
2542
+ */
2543
+ vjs.Component.prototype.height = function(num, skipListeners){
2544
+ return this.dimension('height', num, skipListeners);
2545
+ };
2546
+
2547
+ /**
2548
+ * Set both width and height at the same time
2549
+ *
2550
+ * @param {Number|String} width
2551
+ * @param {Number|String} height
2552
+ * @return {vjs.Component} The component
2553
+ */
2554
+ vjs.Component.prototype.dimensions = function(width, height){
2555
+ // Skip resize listeners on width for optimization
2556
+ return this.width(width, true).height(height);
2557
+ };
2558
+
2559
+ /**
2560
+ * Get or set width or height
2561
+ *
2562
+ * This is the shared code for the width() and height() methods.
2563
+ * All for an integer, integer + 'px' or integer + '%';
2564
+ *
2565
+ * Known issue: Hidden elements officially have a width of 0. We're defaulting
2566
+ * to the style.width value and falling back to computedStyle which has the
2567
+ * hidden element issue. Info, but probably not an efficient fix:
2568
+ * http://www.foliotek.com/devblog/getting-the-width-of-a-hidden-element-with-jquery-using-width/
2569
+ *
2570
+ * @param {String} widthOrHeight 'width' or 'height'
2571
+ * @param {Number|String=} num New dimension
2572
+ * @param {Boolean=} skipListeners Skip resize event trigger
2573
+ * @return {vjs.Component} The component if a dimension was set
2574
+ * @return {Number|String} The dimension if nothing was set
2575
+ * @private
2576
+ */
2577
+ vjs.Component.prototype.dimension = function(widthOrHeight, num, skipListeners){
2578
+ if (num !== undefined) {
2579
+ if (num === null || vjs.isNaN(num)) {
2580
+ num = 0;
2581
+ }
2582
+
2583
+ // Check if using css width/height (% or px) and adjust
2584
+ if ((''+num).indexOf('%') !== -1 || (''+num).indexOf('px') !== -1) {
2585
+ this.el_.style[widthOrHeight] = num;
2586
+ } else if (num === 'auto') {
2587
+ this.el_.style[widthOrHeight] = '';
2588
+ } else {
2589
+ this.el_.style[widthOrHeight] = num+'px';
2590
+ }
2591
+
2592
+ // skipListeners allows us to avoid triggering the resize event when setting both width and height
2593
+ if (!skipListeners) { this.trigger('resize'); }
2594
+
2595
+ // Return component
2596
+ return this;
2597
+ }
2598
+
2599
+ // Not setting a value, so getting it
2600
+ // Make sure element exists
2601
+ if (!this.el_) return 0;
2602
+
2603
+ // Get dimension value from style
2604
+ var val = this.el_.style[widthOrHeight];
2605
+ var pxIndex = val.indexOf('px');
2606
+ if (pxIndex !== -1) {
2607
+ // Return the pixel value with no 'px'
2608
+ return parseInt(val.slice(0,pxIndex), 10);
2609
+
2610
+ // No px so using % or no style was set, so falling back to offsetWidth/height
2611
+ // If component has display:none, offset will return 0
2612
+ // TODO: handle display:none and no dimension style using px
2613
+ } else {
2614
+
2615
+ return parseInt(this.el_['offset'+vjs.capitalize(widthOrHeight)], 10);
2616
+
2617
+ // ComputedStyle version.
2618
+ // Only difference is if the element is hidden it will return
2619
+ // the percent value (e.g. '100%'')
2620
+ // instead of zero like offsetWidth returns.
2621
+ // var val = vjs.getComputedStyleValue(this.el_, widthOrHeight);
2622
+ // var pxIndex = val.indexOf('px');
2623
+
2624
+ // if (pxIndex !== -1) {
2625
+ // return val.slice(0, pxIndex);
2626
+ // } else {
2627
+ // return val;
2628
+ // }
2629
+ }
2630
+ };
2631
+
2632
+ /**
2633
+ * Fired when the width and/or height of the component changes
2634
+ * @event resize
2635
+ */
2636
+ vjs.Component.prototype.onResize;
2637
+
2638
+ /**
2639
+ * Emit 'tap' events when touch events are supported
2640
+ *
2641
+ * This is used to support toggling the controls through a tap on the video.
2642
+ *
2643
+ * We're requireing them to be enabled because otherwise every component would
2644
+ * have this extra overhead unnecessarily, on mobile devices where extra
2645
+ * overhead is especially bad.
2646
+ * @private
2647
+ */
2648
+ vjs.Component.prototype.emitTapEvents = function(){
2649
+ var touchStart, firstTouch, touchTime, couldBeTap, noTap,
2650
+ xdiff, ydiff, touchDistance, tapMovementThreshold;
2651
+
2652
+ // Track the start time so we can determine how long the touch lasted
2653
+ touchStart = 0;
2654
+ firstTouch = null;
2655
+
2656
+ // Maximum movement allowed during a touch event to still be considered a tap
2657
+ tapMovementThreshold = 22;
2658
+
2659
+ this.on('touchstart', function(event) {
2660
+ // If more than one finger, don't consider treating this as a click
2661
+ if (event.touches.length === 1) {
2662
+ firstTouch = event.touches[0];
2663
+ // Record start time so we can detect a tap vs. "touch and hold"
2664
+ touchStart = new Date().getTime();
2665
+ // Reset couldBeTap tracking
2666
+ couldBeTap = true;
2667
+ }
2668
+ });
2669
+
2670
+ this.on('touchmove', function(event) {
2671
+ // If more than one finger, don't consider treating this as a click
2672
+ if (event.touches.length > 1) {
2673
+ couldBeTap = false;
2674
+ } else if (firstTouch) {
2675
+ // Some devices will throw touchmoves for all but the slightest of taps.
2676
+ // So, if we moved only a small distance, this could still be a tap
2677
+ xdiff = event.touches[0].pageX - firstTouch.pageX;
2678
+ ydiff = event.touches[0].pageY - firstTouch.pageY;
2679
+ touchDistance = Math.sqrt(xdiff * xdiff + ydiff * ydiff);
2680
+ if (touchDistance > tapMovementThreshold) {
2681
+ couldBeTap = false;
2682
+ }
2683
+ }
2684
+ });
2685
+
2686
+ noTap = function(){
2687
+ couldBeTap = false;
2688
+ };
2689
+ // TODO: Listen to the original target. http://youtu.be/DujfpXOKUp8?t=13m8s
2690
+ this.on('touchleave', noTap);
2691
+ this.on('touchcancel', noTap);
2692
+
2693
+ // When the touch ends, measure how long it took and trigger the appropriate
2694
+ // event
2695
+ this.on('touchend', function(event) {
2696
+ firstTouch = null;
2697
+ // Proceed only if the touchmove/leave/cancel event didn't happen
2698
+ if (couldBeTap === true) {
2699
+ // Measure how long the touch lasted
2700
+ touchTime = new Date().getTime() - touchStart;
2701
+ // The touch needs to be quick in order to consider it a tap
2702
+ if (touchTime < 250) {
2703
+ event.preventDefault(); // Don't let browser turn this into a click
2704
+ this.trigger('tap');
2705
+ // It may be good to copy the touchend event object and change the
2706
+ // type to tap, if the other event properties aren't exact after
2707
+ // vjs.fixEvent runs (e.g. event.target)
2708
+ }
2709
+ }
2710
+ });
2711
+ };
2712
+
2713
+ /**
2714
+ * Report user touch activity when touch events occur
2715
+ *
2716
+ * User activity is used to determine when controls should show/hide. It's
2717
+ * relatively simple when it comes to mouse events, because any mouse event
2718
+ * should show the controls. So we capture mouse events that bubble up to the
2719
+ * player and report activity when that happens.
2720
+ *
2721
+ * With touch events it isn't as easy. We can't rely on touch events at the
2722
+ * player level, because a tap (touchstart + touchend) on the video itself on
2723
+ * mobile devices is meant to turn controls off (and on). User activity is
2724
+ * checked asynchronously, so what could happen is a tap event on the video
2725
+ * turns the controls off, then the touchend event bubbles up to the player,
2726
+ * which if it reported user activity, would turn the controls right back on.
2727
+ * (We also don't want to completely block touch events from bubbling up)
2728
+ *
2729
+ * Also a touchmove, touch+hold, and anything other than a tap is not supposed
2730
+ * to turn the controls back on on a mobile device.
2731
+ *
2732
+ * Here we're setting the default component behavior to report user activity
2733
+ * whenever touch events happen, and this can be turned off by components that
2734
+ * want touch events to act differently.
2735
+ */
2736
+ vjs.Component.prototype.enableTouchActivity = function() {
2737
+ var report, touchHolding, touchEnd;
2738
+
2739
+ // Don't continue if the root player doesn't support reporting user activity
2740
+ if (!this.player().reportUserActivity) {
2741
+ return;
2742
+ }
2743
+
2744
+ // listener for reporting that the user is active
2745
+ report = vjs.bind(this.player(), this.player().reportUserActivity);
2746
+
2747
+ this.on('touchstart', function() {
2748
+ report();
2749
+ // For as long as the they are touching the device or have their mouse down,
2750
+ // we consider them active even if they're not moving their finger or mouse.
2751
+ // So we want to continue to update that they are active
2752
+ clearInterval(touchHolding);
2753
+ // report at the same interval as activityCheck
2754
+ touchHolding = setInterval(report, 250);
2755
+ });
2756
+
2757
+ touchEnd = function(event) {
2758
+ report();
2759
+ // stop the interval that maintains activity if the touch is holding
2760
+ clearInterval(touchHolding);
2761
+ };
2762
+
2763
+ this.on('touchmove', report);
2764
+ this.on('touchend', touchEnd);
2765
+ this.on('touchcancel', touchEnd);
2766
+ };
2767
+
2768
+ /* Button - Base class for all buttons
2769
+ ================================================================================ */
2770
+ /**
2771
+ * Base class for all buttons
2772
+ * @param {vjs.Player|Object} player
2773
+ * @param {Object=} options
2774
+ * @class
2775
+ * @constructor
2776
+ */
2777
+ vjs.Button = vjs.Component.extend({
2778
+ /**
2779
+ * @constructor
2780
+ * @inheritDoc
2781
+ */
2782
+ init: function(player, options){
2783
+ vjs.Component.call(this, player, options);
2784
+
2785
+ this.emitTapEvents();
2786
+
2787
+ this.on('tap', this.onClick);
2788
+ this.on('click', this.onClick);
2789
+ this.on('focus', this.onFocus);
2790
+ this.on('blur', this.onBlur);
2791
+ }
2792
+ });
2793
+
2794
+ vjs.Button.prototype.createEl = function(type, props){
2795
+ var el;
2796
+
2797
+ // Add standard Aria and Tabindex info
2798
+ props = vjs.obj.merge({
2799
+ className: this.buildCSSClass(),
2800
+ 'role': 'button',
2801
+ 'aria-live': 'polite', // let the screen reader user know that the text of the button may change
2802
+ tabIndex: 0
2803
+ }, props);
2804
+
2805
+ el = vjs.Component.prototype.createEl.call(this, type, props);
2806
+
2807
+ // if innerHTML hasn't been overridden (bigPlayButton), add content elements
2808
+ if (!props.innerHTML) {
2809
+ this.contentEl_ = vjs.createEl('div', {
2810
+ className: 'vjs-control-content'
2811
+ });
2812
+
2813
+ this.controlText_ = vjs.createEl('span', {
2814
+ className: 'vjs-control-text',
2815
+ innerHTML: this.localize(this.buttonText) || 'Need Text'
2816
+ });
2817
+
2818
+ this.contentEl_.appendChild(this.controlText_);
2819
+ el.appendChild(this.contentEl_);
2820
+ }
2821
+
2822
+ return el;
2823
+ };
2824
+
2825
+ vjs.Button.prototype.buildCSSClass = function(){
2826
+ // TODO: Change vjs-control to vjs-button?
2827
+ return 'vjs-control ' + vjs.Component.prototype.buildCSSClass.call(this);
2828
+ };
2829
+
2830
+ // Click - Override with specific functionality for button
2831
+ vjs.Button.prototype.onClick = function(){};
2832
+
2833
+ // Focus - Add keyboard functionality to element
2834
+ vjs.Button.prototype.onFocus = function(){
2835
+ vjs.on(document, 'keydown', vjs.bind(this, this.onKeyPress));
2836
+ };
2837
+
2838
+ // KeyPress (document level) - Trigger click when keys are pressed
2839
+ vjs.Button.prototype.onKeyPress = function(event){
2840
+ // Check for space bar (32) or enter (13) keys
2841
+ if (event.which == 32 || event.which == 13) {
2842
+ event.preventDefault();
2843
+ this.onClick();
2844
+ }
2845
+ };
2846
+
2847
+ // Blur - Remove keyboard triggers
2848
+ vjs.Button.prototype.onBlur = function(){
2849
+ vjs.off(document, 'keydown', vjs.bind(this, this.onKeyPress));
2850
+ };
2851
+ /* Slider
2852
+ ================================================================================ */
2853
+ /**
2854
+ * The base functionality for sliders like the volume bar and seek bar
2855
+ *
2856
+ * @param {vjs.Player|Object} player
2857
+ * @param {Object=} options
2858
+ * @constructor
2859
+ */
2860
+ vjs.Slider = vjs.Component.extend({
2861
+ /** @constructor */
2862
+ init: function(player, options){
2863
+ vjs.Component.call(this, player, options);
2864
+
2865
+ // Set property names to bar and handle to match with the child Slider class is looking for
2866
+ this.bar = this.getChild(this.options_['barName']);
2867
+ this.handle = this.getChild(this.options_['handleName']);
2868
+
2869
+ this.on('mousedown', this.onMouseDown);
2870
+ this.on('touchstart', this.onMouseDown);
2871
+ this.on('focus', this.onFocus);
2872
+ this.on('blur', this.onBlur);
2873
+ this.on('click', this.onClick);
2874
+
2875
+ this.on(player, 'controlsvisible', this.update);
2876
+ this.on(player, this.playerEvent, this.update);
2877
+
2878
+ this.boundEvents = {};
2879
+ this.boundEvents.move = vjs.bind(this, this.onMouseMove);
2880
+ this.boundEvents.end = vjs.bind(this, this.onMouseUp);
2881
+ }
2882
+ });
2883
+
2884
+ vjs.Slider.prototype.dispose = function() {
2885
+ vjs.off(document, 'mousemove', this.boundEvents.move, false);
2886
+ vjs.off(document, 'mouseup', this.boundEvents.end, false);
2887
+ vjs.off(document, 'touchmove', this.boundEvents.move, false);
2888
+ vjs.off(document, 'touchend', this.boundEvents.end, false);
2889
+
2890
+ vjs.off(document, 'keyup', vjs.bind(this, this.onKeyPress));
2891
+
2892
+ vjs.Component.prototype.dispose.call(this);
2893
+ };
2894
+
2895
+ vjs.Slider.prototype.createEl = function(type, props) {
2896
+ props = props || {};
2897
+ // Add the slider element class to all sub classes
2898
+ props.className = props.className + ' vjs-slider';
2899
+ props = vjs.obj.merge({
2900
+ 'role': 'slider',
2901
+ 'aria-valuenow': 0,
2902
+ 'aria-valuemin': 0,
2903
+ 'aria-valuemax': 100,
2904
+ tabIndex: 0
2905
+ }, props);
2906
+
2907
+ return vjs.Component.prototype.createEl.call(this, type, props);
2908
+ };
2909
+
2910
+ vjs.Slider.prototype.onMouseDown = function(event){
2911
+ event.preventDefault();
2912
+ vjs.blockTextSelection();
2913
+ this.addClass('vjs-sliding');
2914
+
2915
+ vjs.on(document, 'mousemove', this.boundEvents.move);
2916
+ vjs.on(document, 'mouseup', this.boundEvents.end);
2917
+ vjs.on(document, 'touchmove', this.boundEvents.move);
2918
+ vjs.on(document, 'touchend', this.boundEvents.end);
2919
+
2920
+ this.onMouseMove(event);
2921
+ };
2922
+
2923
+ // To be overridden by a subclass
2924
+ vjs.Slider.prototype.onMouseMove = function(){};
2925
+
2926
+ vjs.Slider.prototype.onMouseUp = function() {
2927
+ vjs.unblockTextSelection();
2928
+ this.removeClass('vjs-sliding');
2929
+
2930
+ vjs.off(document, 'mousemove', this.boundEvents.move, false);
2931
+ vjs.off(document, 'mouseup', this.boundEvents.end, false);
2932
+ vjs.off(document, 'touchmove', this.boundEvents.move, false);
2933
+ vjs.off(document, 'touchend', this.boundEvents.end, false);
2934
+
2935
+ this.update();
2936
+ };
2937
+
2938
+ vjs.Slider.prototype.update = function(){
2939
+ // In VolumeBar init we have a setTimeout for update that pops and update to the end of the
2940
+ // execution stack. The player is destroyed before then update will cause an error
2941
+ if (!this.el_) return;
2942
+
2943
+ // If scrubbing, we could use a cached value to make the handle keep up with the user's mouse.
2944
+ // On HTML5 browsers scrubbing is really smooth, but some flash players are slow, so we might want to utilize this later.
2945
+ // var progress = (this.player_.scrubbing) ? this.player_.getCache().currentTime / this.player_.duration() : this.player_.currentTime() / this.player_.duration();
2946
+
2947
+ var barProgress,
2948
+ progress = this.getPercent(),
2949
+ handle = this.handle,
2950
+ bar = this.bar;
2951
+
2952
+ // Protect against no duration and other division issues
2953
+ if (isNaN(progress)) { progress = 0; }
2954
+
2955
+ barProgress = progress;
2956
+
2957
+ // If there is a handle, we need to account for the handle in our calculation for progress bar
2958
+ // so that it doesn't fall short of or extend past the handle.
2959
+ if (handle) {
2960
+
2961
+ var box = this.el_,
2962
+ boxWidth = box.offsetWidth,
2963
+
2964
+ handleWidth = handle.el().offsetWidth,
2965
+
2966
+ // The width of the handle in percent of the containing box
2967
+ // In IE, widths may not be ready yet causing NaN
2968
+ handlePercent = (handleWidth) ? handleWidth / boxWidth : 0,
2969
+
2970
+ // Get the adjusted size of the box, considering that the handle's center never touches the left or right side.
2971
+ // There is a margin of half the handle's width on both sides.
2972
+ boxAdjustedPercent = 1 - handlePercent,
2973
+
2974
+ // Adjust the progress that we'll use to set widths to the new adjusted box width
2975
+ adjustedProgress = progress * boxAdjustedPercent;
2976
+
2977
+ // The bar does reach the left side, so we need to account for this in the bar's width
2978
+ barProgress = adjustedProgress + (handlePercent / 2);
2979
+
2980
+ // Move the handle from the left based on the adjected progress
2981
+ handle.el().style.left = vjs.round(adjustedProgress * 100, 2) + '%';
2982
+ }
2983
+
2984
+ // Set the new bar width
2985
+ if (bar) {
2986
+ bar.el().style.width = vjs.round(barProgress * 100, 2) + '%';
2987
+ }
2988
+ };
2989
+
2990
+ vjs.Slider.prototype.calculateDistance = function(event){
2991
+ var el, box, boxX, boxY, boxW, boxH, handle, pageX, pageY;
2992
+
2993
+ el = this.el_;
2994
+ box = vjs.findPosition(el);
2995
+ boxW = boxH = el.offsetWidth;
2996
+ handle = this.handle;
2997
+
2998
+ if (this.options()['vertical']) {
2999
+ boxY = box.top;
3000
+
3001
+ if (event.changedTouches) {
3002
+ pageY = event.changedTouches[0].pageY;
3003
+ } else {
3004
+ pageY = event.pageY;
3005
+ }
3006
+
3007
+ if (handle) {
3008
+ var handleH = handle.el().offsetHeight;
3009
+ // Adjusted X and Width, so handle doesn't go outside the bar
3010
+ boxY = boxY + (handleH / 2);
3011
+ boxH = boxH - handleH;
3012
+ }
3013
+
3014
+ // Percent that the click is through the adjusted area
3015
+ return Math.max(0, Math.min(1, ((boxY - pageY) + boxH) / boxH));
3016
+
3017
+ } else {
3018
+ boxX = box.left;
3019
+
3020
+ if (event.changedTouches) {
3021
+ pageX = event.changedTouches[0].pageX;
3022
+ } else {
3023
+ pageX = event.pageX;
3024
+ }
3025
+
3026
+ if (handle) {
3027
+ var handleW = handle.el().offsetWidth;
3028
+
3029
+ // Adjusted X and Width, so handle doesn't go outside the bar
3030
+ boxX = boxX + (handleW / 2);
3031
+ boxW = boxW - handleW;
3032
+ }
3033
+
3034
+ // Percent that the click is through the adjusted area
3035
+ return Math.max(0, Math.min(1, (pageX - boxX) / boxW));
3036
+ }
3037
+ };
3038
+
3039
+ vjs.Slider.prototype.onFocus = function(){
3040
+ vjs.on(document, 'keyup', vjs.bind(this, this.onKeyPress));
3041
+ };
3042
+
3043
+ vjs.Slider.prototype.onKeyPress = function(event){
3044
+ if (event.which == 37 || event.which == 40) { // Left and Down Arrows
3045
+ event.preventDefault();
3046
+ this.stepBack();
3047
+ } else if (event.which == 38 || event.which == 39) { // Up and Right Arrows
3048
+ event.preventDefault();
3049
+ this.stepForward();
3050
+ }
3051
+ };
3052
+
3053
+ vjs.Slider.prototype.onBlur = function(){
3054
+ vjs.off(document, 'keyup', vjs.bind(this, this.onKeyPress));
3055
+ };
3056
+
3057
+ /**
3058
+ * Listener for click events on slider, used to prevent clicks
3059
+ * from bubbling up to parent elements like button menus.
3060
+ * @param {Object} event Event object
3061
+ */
3062
+ vjs.Slider.prototype.onClick = function(event){
3063
+ event.stopImmediatePropagation();
3064
+ event.preventDefault();
3065
+ };
3066
+
3067
+ /**
3068
+ * SeekBar Behavior includes play progress bar, and seek handle
3069
+ * Needed so it can determine seek position based on handle position/size
3070
+ * @param {vjs.Player|Object} player
3071
+ * @param {Object=} options
3072
+ * @constructor
3073
+ */
3074
+ vjs.SliderHandle = vjs.Component.extend();
3075
+
3076
+ /**
3077
+ * Default value of the slider
3078
+ *
3079
+ * @type {Number}
3080
+ * @private
3081
+ */
3082
+ vjs.SliderHandle.prototype.defaultValue = 0;
3083
+
3084
+ /** @inheritDoc */
3085
+ vjs.SliderHandle.prototype.createEl = function(type, props) {
3086
+ props = props || {};
3087
+ // Add the slider element class to all sub classes
3088
+ props.className = props.className + ' vjs-slider-handle';
3089
+ props = vjs.obj.merge({
3090
+ innerHTML: '<span class="vjs-control-text">'+this.defaultValue+'</span>'
3091
+ }, props);
3092
+
3093
+ return vjs.Component.prototype.createEl.call(this, 'div', props);
3094
+ };
3095
+ /* Menu
3096
+ ================================================================================ */
3097
+ /**
3098
+ * The Menu component is used to build pop up menus, including subtitle and
3099
+ * captions selection menus.
3100
+ *
3101
+ * @param {vjs.Player|Object} player
3102
+ * @param {Object=} options
3103
+ * @class
3104
+ * @constructor
3105
+ */
3106
+ vjs.Menu = vjs.Component.extend();
3107
+
3108
+ /**
3109
+ * Add a menu item to the menu
3110
+ * @param {Object|String} component Component or component type to add
3111
+ */
3112
+ vjs.Menu.prototype.addItem = function(component){
3113
+ this.addChild(component);
3114
+ component.on('click', vjs.bind(this, function(){
3115
+ this.unlockShowing();
3116
+ }));
3117
+ };
3118
+
3119
+ /** @inheritDoc */
3120
+ vjs.Menu.prototype.createEl = function(){
3121
+ var contentElType = this.options().contentElType || 'ul';
3122
+ this.contentEl_ = vjs.createEl(contentElType, {
3123
+ className: 'vjs-menu-content'
3124
+ });
3125
+ var el = vjs.Component.prototype.createEl.call(this, 'div', {
3126
+ append: this.contentEl_,
3127
+ className: 'vjs-menu'
3128
+ });
3129
+ el.appendChild(this.contentEl_);
3130
+
3131
+ // Prevent clicks from bubbling up. Needed for Menu Buttons,
3132
+ // where a click on the parent is significant
3133
+ vjs.on(el, 'click', function(event){
3134
+ event.preventDefault();
3135
+ event.stopImmediatePropagation();
3136
+ });
3137
+
3138
+ return el;
3139
+ };
3140
+
3141
+ /**
3142
+ * The component for a menu item. `<li>`
3143
+ *
3144
+ * @param {vjs.Player|Object} player
3145
+ * @param {Object=} options
3146
+ * @class
3147
+ * @constructor
3148
+ */
3149
+ vjs.MenuItem = vjs.Button.extend({
3150
+ /** @constructor */
3151
+ init: function(player, options){
3152
+ vjs.Button.call(this, player, options);
3153
+ this.selected(options['selected']);
3154
+ }
3155
+ });
3156
+
3157
+ /** @inheritDoc */
3158
+ vjs.MenuItem.prototype.createEl = function(type, props){
3159
+ return vjs.Button.prototype.createEl.call(this, 'li', vjs.obj.merge({
3160
+ className: 'vjs-menu-item',
3161
+ innerHTML: this.localize(this.options_['label'])
3162
+ }, props));
3163
+ };
3164
+
3165
+ /**
3166
+ * Handle a click on the menu item, and set it to selected
3167
+ */
3168
+ vjs.MenuItem.prototype.onClick = function(){
3169
+ this.selected(true);
3170
+ };
3171
+
3172
+ /**
3173
+ * Set this menu item as selected or not
3174
+ * @param {Boolean} selected
3175
+ */
3176
+ vjs.MenuItem.prototype.selected = function(selected){
3177
+ if (selected) {
3178
+ this.addClass('vjs-selected');
3179
+ this.el_.setAttribute('aria-selected',true);
3180
+ } else {
3181
+ this.removeClass('vjs-selected');
3182
+ this.el_.setAttribute('aria-selected',false);
3183
+ }
3184
+ };
3185
+
3186
+
3187
+ /**
3188
+ * A button class with a popup menu
3189
+ * @param {vjs.Player|Object} player
3190
+ * @param {Object=} options
3191
+ * @constructor
3192
+ */
3193
+ vjs.MenuButton = vjs.Button.extend({
3194
+ /** @constructor */
3195
+ init: function(player, options){
3196
+ vjs.Button.call(this, player, options);
3197
+
3198
+ this.menu = this.createMenu();
3199
+
3200
+ // Add list to element
3201
+ this.addChild(this.menu);
3202
+
3203
+ // Automatically hide empty menu buttons
3204
+ if (this.items && this.items.length === 0) {
3205
+ this.hide();
3206
+ }
3207
+
3208
+ this.on('keyup', this.onKeyPress);
3209
+ this.el_.setAttribute('aria-haspopup', true);
3210
+ this.el_.setAttribute('role', 'button');
3211
+ }
3212
+ });
3213
+
3214
+ /**
3215
+ * Track the state of the menu button
3216
+ * @type {Boolean}
3217
+ * @private
3218
+ */
3219
+ vjs.MenuButton.prototype.buttonPressed_ = false;
3220
+
3221
+ vjs.MenuButton.prototype.createMenu = function(){
3222
+ var menu = new vjs.Menu(this.player_);
3223
+
3224
+ // Add a title list item to the top
3225
+ if (this.options().title) {
3226
+ menu.contentEl().appendChild(vjs.createEl('li', {
3227
+ className: 'vjs-menu-title',
3228
+ innerHTML: vjs.capitalize(this.options().title),
3229
+ tabindex: -1
3230
+ }));
3231
+ }
3232
+
3233
+ this.items = this['createItems']();
3234
+
3235
+ if (this.items) {
3236
+ // Add menu items to the menu
3237
+ for (var i = 0; i < this.items.length; i++) {
3238
+ menu.addItem(this.items[i]);
3239
+ }
3240
+ }
3241
+
3242
+ return menu;
3243
+ };
3244
+
3245
+ /**
3246
+ * Create the list of menu items. Specific to each subclass.
3247
+ */
3248
+ vjs.MenuButton.prototype.createItems = function(){};
3249
+
3250
+ /** @inheritDoc */
3251
+ vjs.MenuButton.prototype.buildCSSClass = function(){
3252
+ return this.className + ' vjs-menu-button ' + vjs.Button.prototype.buildCSSClass.call(this);
3253
+ };
3254
+
3255
+ // Focus - Add keyboard functionality to element
3256
+ // This function is not needed anymore. Instead, the keyboard functionality is handled by
3257
+ // treating the button as triggering a submenu. When the button is pressed, the submenu
3258
+ // appears. Pressing the button again makes the submenu disappear.
3259
+ vjs.MenuButton.prototype.onFocus = function(){};
3260
+ // Can't turn off list display that we turned on with focus, because list would go away.
3261
+ vjs.MenuButton.prototype.onBlur = function(){};
3262
+
3263
+ vjs.MenuButton.prototype.onClick = function(){
3264
+ // When you click the button it adds focus, which will show the menu indefinitely.
3265
+ // So we'll remove focus when the mouse leaves the button.
3266
+ // Focus is needed for tab navigation.
3267
+ this.one('mouseout', vjs.bind(this, function(){
3268
+ this.menu.unlockShowing();
3269
+ this.el_.blur();
3270
+ }));
3271
+ if (this.buttonPressed_){
3272
+ this.unpressButton();
3273
+ } else {
3274
+ this.pressButton();
3275
+ }
3276
+ };
3277
+
3278
+ vjs.MenuButton.prototype.onKeyPress = function(event){
3279
+ event.preventDefault();
3280
+
3281
+ // Check for space bar (32) or enter (13) keys
3282
+ if (event.which == 32 || event.which == 13) {
3283
+ if (this.buttonPressed_){
3284
+ this.unpressButton();
3285
+ } else {
3286
+ this.pressButton();
3287
+ }
3288
+ // Check for escape (27) key
3289
+ } else if (event.which == 27){
3290
+ if (this.buttonPressed_){
3291
+ this.unpressButton();
3292
+ }
3293
+ }
3294
+ };
3295
+
3296
+ vjs.MenuButton.prototype.pressButton = function(){
3297
+ this.buttonPressed_ = true;
3298
+ this.menu.lockShowing();
3299
+ this.el_.setAttribute('aria-pressed', true);
3300
+ if (this.items && this.items.length > 0) {
3301
+ this.items[0].el().focus(); // set the focus to the title of the submenu
3302
+ }
3303
+ };
3304
+
3305
+ vjs.MenuButton.prototype.unpressButton = function(){
3306
+ this.buttonPressed_ = false;
3307
+ this.menu.unlockShowing();
3308
+ this.el_.setAttribute('aria-pressed', false);
3309
+ };
3310
+ /**
3311
+ * Custom MediaError to mimic the HTML5 MediaError
3312
+ * @param {Number} code The media error code
3313
+ */
3314
+ vjs.MediaError = function(code){
3315
+ if (typeof code === 'number') {
3316
+ this.code = code;
3317
+ } else if (typeof code === 'string') {
3318
+ // default code is zero, so this is a custom error
3319
+ this.message = code;
3320
+ } else if (typeof code === 'object') { // object
3321
+ vjs.obj.merge(this, code);
3322
+ }
3323
+
3324
+ if (!this.message) {
3325
+ this.message = vjs.MediaError.defaultMessages[this.code] || '';
3326
+ }
3327
+ };
3328
+
3329
+ /**
3330
+ * The error code that refers two one of the defined
3331
+ * MediaError types
3332
+ * @type {Number}
3333
+ */
3334
+ vjs.MediaError.prototype.code = 0;
3335
+
3336
+ /**
3337
+ * An optional message to be shown with the error.
3338
+ * Message is not part of the HTML5 video spec
3339
+ * but allows for more informative custom errors.
3340
+ * @type {String}
3341
+ */
3342
+ vjs.MediaError.prototype.message = '';
3343
+
3344
+ /**
3345
+ * An optional status code that can be set by plugins
3346
+ * to allow even more detail about the error.
3347
+ * For example the HLS plugin might provide the specific
3348
+ * HTTP status code that was returned when the error
3349
+ * occurred, then allowing a custom error overlay
3350
+ * to display more information.
3351
+ * @type {[type]}
3352
+ */
3353
+ vjs.MediaError.prototype.status = null;
3354
+
3355
+ vjs.MediaError.errorTypes = [
3356
+ 'MEDIA_ERR_CUSTOM', // = 0
3357
+ 'MEDIA_ERR_ABORTED', // = 1
3358
+ 'MEDIA_ERR_NETWORK', // = 2
3359
+ 'MEDIA_ERR_DECODE', // = 3
3360
+ 'MEDIA_ERR_SRC_NOT_SUPPORTED', // = 4
3361
+ 'MEDIA_ERR_ENCRYPTED' // = 5
3362
+ ];
3363
+
3364
+ vjs.MediaError.defaultMessages = {
3365
+ 1: 'You aborted the video playback',
3366
+ 2: 'A network error caused the video download to fail part-way.',
3367
+ 3: 'The video playback was aborted due to a corruption problem or because the video used features your browser did not support.',
3368
+ 4: 'The video could not be loaded, either because the server or network failed or because the format is not supported.',
3369
+ 5: 'The video is encrypted and we do not have the keys to decrypt it.'
3370
+ };
3371
+
3372
+ // Add types as properties on MediaError
3373
+ // e.g. MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED = 4;
3374
+ for (var errNum = 0; errNum < vjs.MediaError.errorTypes.length; errNum++) {
3375
+ vjs.MediaError[vjs.MediaError.errorTypes[errNum]] = errNum;
3376
+ // values should be accessible on both the class and instance
3377
+ vjs.MediaError.prototype[vjs.MediaError.errorTypes[errNum]] = errNum;
3378
+ }
3379
+ (function(){
3380
+ var apiMap, specApi, browserApi, i;
3381
+
3382
+ /**
3383
+ * Store the browser-specifc methods for the fullscreen API
3384
+ * @type {Object|undefined}
3385
+ * @private
3386
+ */
3387
+ vjs.browser.fullscreenAPI;
3388
+
3389
+ // browser API methods
3390
+ // map approach from Screenful.js - https://github.com/sindresorhus/screenfull.js
3391
+ apiMap = [
3392
+ // Spec: https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html
3393
+ [
3394
+ 'requestFullscreen',
3395
+ 'exitFullscreen',
3396
+ 'fullscreenElement',
3397
+ 'fullscreenEnabled',
3398
+ 'fullscreenchange',
3399
+ 'fullscreenerror'
3400
+ ],
3401
+ // WebKit
3402
+ [
3403
+ 'webkitRequestFullscreen',
3404
+ 'webkitExitFullscreen',
3405
+ 'webkitFullscreenElement',
3406
+ 'webkitFullscreenEnabled',
3407
+ 'webkitfullscreenchange',
3408
+ 'webkitfullscreenerror'
3409
+ ],
3410
+ // Old WebKit (Safari 5.1)
3411
+ [
3412
+ 'webkitRequestFullScreen',
3413
+ 'webkitCancelFullScreen',
3414
+ 'webkitCurrentFullScreenElement',
3415
+ 'webkitCancelFullScreen',
3416
+ 'webkitfullscreenchange',
3417
+ 'webkitfullscreenerror'
3418
+ ],
3419
+ // Mozilla
3420
+ [
3421
+ 'mozRequestFullScreen',
3422
+ 'mozCancelFullScreen',
3423
+ 'mozFullScreenElement',
3424
+ 'mozFullScreenEnabled',
3425
+ 'mozfullscreenchange',
3426
+ 'mozfullscreenerror'
3427
+ ],
3428
+ // Microsoft
3429
+ [
3430
+ 'msRequestFullscreen',
3431
+ 'msExitFullscreen',
3432
+ 'msFullscreenElement',
3433
+ 'msFullscreenEnabled',
3434
+ 'MSFullscreenChange',
3435
+ 'MSFullscreenError'
3436
+ ]
3437
+ ];
3438
+
3439
+ specApi = apiMap[0];
3440
+
3441
+ // determine the supported set of functions
3442
+ for (i=0; i<apiMap.length; i++) {
3443
+ // check for exitFullscreen function
3444
+ if (apiMap[i][1] in document) {
3445
+ browserApi = apiMap[i];
3446
+ break;
3447
+ }
3448
+ }
3449
+
3450
+ // map the browser API names to the spec API names
3451
+ // or leave vjs.browser.fullscreenAPI undefined
3452
+ if (browserApi) {
3453
+ vjs.browser.fullscreenAPI = {};
3454
+
3455
+ for (i=0; i<browserApi.length; i++) {
3456
+ vjs.browser.fullscreenAPI[specApi[i]] = browserApi[i];
3457
+ }
3458
+ }
3459
+
3460
+ })();
3461
+ /**
3462
+ * An instance of the `vjs.Player` class is created when any of the Video.js setup methods are used to initialize a video.
3463
+ *
3464
+ * ```js
3465
+ * var myPlayer = videojs('example_video_1');
3466
+ * ```
3467
+ *
3468
+ * In the following example, the `data-setup` attribute tells the Video.js library to create a player instance when the library is ready.
3469
+ *
3470
+ * ```html
3471
+ * <video id="example_video_1" data-setup='{}' controls>
3472
+ * <source src="my-source.mp4" type="video/mp4">
3473
+ * </video>
3474
+ * ```
3475
+ *
3476
+ * After an instance has been created it can be accessed globally using `Video('example_video_1')`.
3477
+ *
3478
+ * @class
3479
+ * @extends vjs.Component
3480
+ */
3481
+ vjs.Player = vjs.Component.extend({
3482
+
3483
+ /**
3484
+ * player's constructor function
3485
+ *
3486
+ * @constructs
3487
+ * @method init
3488
+ * @param {Element} tag The original video tag used for configuring options
3489
+ * @param {Object=} options Player options
3490
+ * @param {Function=} ready Ready callback function
3491
+ */
3492
+ init: function(tag, options, ready){
3493
+ this.tag = tag; // Store the original tag used to set options
3494
+
3495
+ // Make sure tag ID exists
3496
+ tag.id = tag.id || 'vjs_video_' + vjs.guid++;
3497
+
3498
+ // Store the tag attributes used to restore html5 element
3499
+ this.tagAttributes = tag && vjs.getElementAttributes(tag);
3500
+
3501
+ // Set Options
3502
+ // The options argument overrides options set in the video tag
3503
+ // which overrides globally set options.
3504
+ // This latter part coincides with the load order
3505
+ // (tag must exist before Player)
3506
+ options = vjs.obj.merge(this.getTagSettings(tag), options);
3507
+
3508
+ // Update Current Language
3509
+ this.language_ = options['language'] || vjs.options['language'];
3510
+
3511
+ // Update Supported Languages
3512
+ this.languages_ = options['languages'] || vjs.options['languages'];
3513
+
3514
+ // Cache for video property values.
3515
+ this.cache_ = {};
3516
+
3517
+ // Set poster
3518
+ this.poster_ = options['poster'] || '';
3519
+
3520
+ // Set controls
3521
+ this.controls_ = !!options['controls'];
3522
+ // Original tag settings stored in options
3523
+ // now remove immediately so native controls don't flash.
3524
+ // May be turned back on by HTML5 tech if nativeControlsForTouch is true
3525
+ tag.controls = false;
3526
+
3527
+ // we don't want the player to report touch activity on itself
3528
+ // see enableTouchActivity in Component
3529
+ options.reportTouchActivity = false;
3530
+
3531
+ // Set isAudio based on whether or not an audio tag was used
3532
+ this.isAudio(this.tag.nodeName.toLowerCase() === 'audio');
3533
+
3534
+ // Run base component initializing with new options.
3535
+ // Builds the element through createEl()
3536
+ // Inits and embeds any child components in opts
3537
+ vjs.Component.call(this, this, options, ready);
3538
+
3539
+ // Update controls className. Can't do this when the controls are initially
3540
+ // set because the element doesn't exist yet.
3541
+ if (this.controls()) {
3542
+ this.addClass('vjs-controls-enabled');
3543
+ } else {
3544
+ this.addClass('vjs-controls-disabled');
3545
+ }
3546
+
3547
+ if (this.isAudio()) {
3548
+ this.addClass('vjs-audio');
3549
+ }
3550
+
3551
+ // TODO: Make this smarter. Toggle user state between touching/mousing
3552
+ // using events, since devices can have both touch and mouse events.
3553
+ // if (vjs.TOUCH_ENABLED) {
3554
+ // this.addClass('vjs-touch-enabled');
3555
+ // }
3556
+
3557
+ // Make player easily findable by ID
3558
+ vjs.players[this.id_] = this;
3559
+
3560
+ if (options['plugins']) {
3561
+ vjs.obj.each(options['plugins'], function(key, val){
3562
+ this[key](val);
3563
+ }, this);
3564
+ }
3565
+
3566
+ this.listenForUserActivity();
3567
+ }
3568
+ });
3569
+
3570
+ /**
3571
+ * The players's stored language code
3572
+ *
3573
+ * @type {String}
3574
+ * @private
3575
+ */
3576
+ vjs.Player.prototype.language_;
3577
+
3578
+ /**
3579
+ * The player's language code
3580
+ * @param {String} languageCode The locale string
3581
+ * @return {String} The locale string when getting
3582
+ * @return {vjs.Player} self, when setting
3583
+ */
3584
+ vjs.Player.prototype.language = function (languageCode) {
3585
+ if (languageCode === undefined) {
3586
+ return this.language_;
3587
+ }
3588
+
3589
+ this.language_ = languageCode;
3590
+ return this;
3591
+ };
3592
+
3593
+ /**
3594
+ * The players's stored language dictionary
3595
+ *
3596
+ * @type {Object}
3597
+ * @private
3598
+ */
3599
+ vjs.Player.prototype.languages_;
3600
+
3601
+ vjs.Player.prototype.languages = function(){
3602
+ return this.languages_;
3603
+ };
3604
+
3605
+ /**
3606
+ * Player instance options, surfaced using vjs.options
3607
+ * vjs.options = vjs.Player.prototype.options_
3608
+ * Make changes in vjs.options, not here.
3609
+ * All options should use string keys so they avoid
3610
+ * renaming by closure compiler
3611
+ * @type {Object}
3612
+ * @private
3613
+ */
3614
+ vjs.Player.prototype.options_ = vjs.options;
3615
+
3616
+ /**
3617
+ * Destroys the video player and does any necessary cleanup
3618
+ *
3619
+ * myPlayer.dispose();
3620
+ *
3621
+ * This is especially helpful if you are dynamically adding and removing videos
3622
+ * to/from the DOM.
3623
+ */
3624
+ vjs.Player.prototype.dispose = function(){
3625
+ this.trigger('dispose');
3626
+ // prevent dispose from being called twice
3627
+ this.off('dispose');
3628
+
3629
+ // Kill reference to this player
3630
+ vjs.players[this.id_] = null;
3631
+ if (this.tag && this.tag['player']) { this.tag['player'] = null; }
3632
+ if (this.el_ && this.el_['player']) { this.el_['player'] = null; }
3633
+
3634
+ if (this.tech) { this.tech.dispose(); }
3635
+
3636
+ // Component dispose
3637
+ vjs.Component.prototype.dispose.call(this);
3638
+ };
3639
+
3640
+ vjs.Player.prototype.getTagSettings = function(tag){
3641
+ var tagOptions,
3642
+ dataSetup,
3643
+ options = {
3644
+ 'sources': [],
3645
+ 'tracks': []
3646
+ };
3647
+
3648
+ tagOptions = vjs.getElementAttributes(tag);
3649
+ dataSetup = tagOptions['data-setup'];
3650
+
3651
+ // Check if data-setup attr exists.
3652
+ if (dataSetup !== null){
3653
+ // Parse options JSON
3654
+ // If empty string, make it a parsable json object.
3655
+ vjs.obj.merge(tagOptions, vjs.JSON.parse(dataSetup || '{}'));
3656
+ }
3657
+
3658
+ vjs.obj.merge(options, tagOptions);
3659
+
3660
+ // Get tag children settings
3661
+ if (tag.hasChildNodes()) {
3662
+ var children, child, childName, i, j;
3663
+
3664
+ children = tag.childNodes;
3665
+
3666
+ for (i=0,j=children.length; i<j; i++) {
3667
+ child = children[i];
3668
+ // Change case needed: http://ejohn.org/blog/nodename-case-sensitivity/
3669
+ childName = child.nodeName.toLowerCase();
3670
+ if (childName === 'source') {
3671
+ options['sources'].push(vjs.getElementAttributes(child));
3672
+ } else if (childName === 'track') {
3673
+ options['tracks'].push(vjs.getElementAttributes(child));
3674
+ }
3675
+ }
3676
+ }
3677
+
3678
+ return options;
3679
+ };
3680
+
3681
+ vjs.Player.prototype.createEl = function(){
3682
+ var
3683
+ el = this.el_ = vjs.Component.prototype.createEl.call(this, 'div'),
3684
+ tag = this.tag,
3685
+ attrs;
3686
+
3687
+ // Remove width/height attrs from tag so CSS can make it 100% width/height
3688
+ tag.removeAttribute('width');
3689
+ tag.removeAttribute('height');
3690
+ // Empty video tag tracks so the built-in player doesn't use them also.
3691
+ // This may not be fast enough to stop HTML5 browsers from reading the tags
3692
+ // so we'll need to turn off any default tracks if we're manually doing
3693
+ // captions and subtitles. videoElement.textTracks
3694
+ if (tag.hasChildNodes()) {
3695
+ var nodes, nodesLength, i, node, nodeName, removeNodes;
3696
+
3697
+ nodes = tag.childNodes;
3698
+ nodesLength = nodes.length;
3699
+ removeNodes = [];
3700
+
3701
+ while (nodesLength--) {
3702
+ node = nodes[nodesLength];
3703
+ nodeName = node.nodeName.toLowerCase();
3704
+ if (nodeName === 'track') {
3705
+ removeNodes.push(node);
3706
+ }
3707
+ }
3708
+
3709
+ for (i=0; i<removeNodes.length; i++) {
3710
+ tag.removeChild(removeNodes[i]);
3711
+ }
3712
+ }
3713
+
3714
+ // Copy over all the attributes from the tag, including ID and class
3715
+ // ID will now reference player box, not the video tag
3716
+ attrs = vjs.getElementAttributes(tag);
3717
+ vjs.obj.each(attrs, function(attr) {
3718
+ // workaround so we don't totally break IE7
3719
+ // http://stackoverflow.com/questions/3653444/css-styles-not-applied-on-dynamic-elements-in-internet-explorer-7
3720
+ if (attr == 'class') {
3721
+ el.className = attrs[attr];
3722
+ } else {
3723
+ el.setAttribute(attr, attrs[attr]);
3724
+ }
3725
+ });
3726
+
3727
+ // Update tag id/class for use as HTML5 playback tech
3728
+ // Might think we should do this after embedding in container so .vjs-tech class
3729
+ // doesn't flash 100% width/height, but class only applies with .video-js parent
3730
+ tag.id += '_html5_api';
3731
+ tag.className = 'vjs-tech';
3732
+
3733
+ // Make player findable on elements
3734
+ tag['player'] = el['player'] = this;
3735
+ // Default state of video is paused
3736
+ this.addClass('vjs-paused');
3737
+
3738
+ // Make box use width/height of tag, or rely on default implementation
3739
+ // Enforce with CSS since width/height attrs don't work on divs
3740
+ this.width(this.options_['width'], true); // (true) Skip resize listener on load
3741
+ this.height(this.options_['height'], true);
3742
+
3743
+ // vjs.insertFirst seems to cause the networkState to flicker from 3 to 2, so
3744
+ // keep track of the original for later so we can know if the source originally failed
3745
+ tag.initNetworkState_ = tag.networkState;
3746
+
3747
+ // Wrap video tag in div (el/box) container
3748
+ if (tag.parentNode) {
3749
+ tag.parentNode.insertBefore(el, tag);
3750
+ }
3751
+ vjs.insertFirst(tag, el); // Breaks iPhone, fixed in HTML5 setup.
3752
+
3753
+ // The event listeners need to be added before the children are added
3754
+ // in the component init because the tech (loaded with mediaLoader) may
3755
+ // fire events, like loadstart, that these events need to capture.
3756
+ // Long term it might be better to expose a way to do this in component.init
3757
+ // like component.initEventListeners() that runs between el creation and
3758
+ // adding children
3759
+ this.el_ = el;
3760
+ this.on('loadstart', this.onLoadStart);
3761
+ this.on('waiting', this.onWaiting);
3762
+ this.on(['canplay', 'canplaythrough', 'playing', 'ended'], this.onWaitEnd);
3763
+ this.on('seeking', this.onSeeking);
3764
+ this.on('seeked', this.onSeeked);
3765
+ this.on('ended', this.onEnded);
3766
+ this.on('play', this.onPlay);
3767
+ this.on('firstplay', this.onFirstPlay);
3768
+ this.on('pause', this.onPause);
3769
+ this.on('progress', this.onProgress);
3770
+ this.on('durationchange', this.onDurationChange);
3771
+ this.on('fullscreenchange', this.onFullscreenChange);
3772
+
3773
+ return el;
3774
+ };
3775
+
3776
+ // /* Media Technology (tech)
3777
+ // ================================================================================ */
3778
+ // Load/Create an instance of playback technlogy including element and API methods
3779
+ // And append playback element in player div.
3780
+ vjs.Player.prototype.loadTech = function(techName, source){
3781
+
3782
+ // Pause and remove current playback technology
3783
+ if (this.tech) {
3784
+ this.unloadTech();
3785
+ }
3786
+
3787
+ // get rid of the HTML5 video tag as soon as we are using another tech
3788
+ if (techName !== 'Html5' && this.tag) {
3789
+ vjs.Html5.disposeMediaElement(this.tag);
3790
+ this.tag = null;
3791
+ }
3792
+
3793
+ this.techName = techName;
3794
+
3795
+ // Turn off API access because we're loading a new tech that might load asynchronously
3796
+ this.isReady_ = false;
3797
+
3798
+ var techReady = function(){
3799
+ this.player_.triggerReady();
3800
+ };
3801
+
3802
+ // Grab tech-specific options from player options and add source and parent element to use.
3803
+ var techOptions = vjs.obj.merge({ 'source': source, 'parentEl': this.el_ }, this.options_[techName.toLowerCase()]);
3804
+
3805
+ if (source) {
3806
+ this.currentType_ = source.type;
3807
+ if (source.src == this.cache_.src && this.cache_.currentTime > 0) {
3808
+ techOptions['startTime'] = this.cache_.currentTime;
3809
+ }
3810
+
3811
+ this.cache_.src = source.src;
3812
+ }
3813
+
3814
+ // Initialize tech instance
3815
+ this.tech = new window['videojs'][techName](this, techOptions);
3816
+
3817
+ this.tech.ready(techReady);
3818
+ };
3819
+
3820
+ vjs.Player.prototype.unloadTech = function(){
3821
+ this.isReady_ = false;
3822
+
3823
+ this.tech.dispose();
3824
+
3825
+ this.tech = false;
3826
+ };
3827
+
3828
+ // There's many issues around changing the size of a Flash (or other plugin) object.
3829
+ // First is a plugin reload issue in Firefox that has been around for 11 years: https://bugzilla.mozilla.org/show_bug.cgi?id=90268
3830
+ // Then with the new fullscreen API, Mozilla and webkit browsers will reload the flash object after going to fullscreen.
3831
+ // To get around this, we're unloading the tech, caching source and currentTime values, and reloading the tech once the plugin is resized.
3832
+ // reloadTech: function(betweenFn){
3833
+ // vjs.log('unloadingTech')
3834
+ // this.unloadTech();
3835
+ // vjs.log('unloadedTech')
3836
+ // if (betweenFn) { betweenFn.call(); }
3837
+ // vjs.log('LoadingTech')
3838
+ // this.loadTech(this.techName, { src: this.cache_.src })
3839
+ // vjs.log('loadedTech')
3840
+ // },
3841
+
3842
+ // /* Player event handlers (how the player reacts to certain events)
3843
+ // ================================================================================ */
3844
+
3845
+ /**
3846
+ * Fired when the user agent begins looking for media data
3847
+ * @event loadstart
3848
+ */
3849
+ vjs.Player.prototype.onLoadStart = function() {
3850
+ // TODO: Update to use `emptied` event instead. See #1277.
3851
+
3852
+ // reset the error state
3853
+ this.error(null);
3854
+
3855
+ // If it's already playing we want to trigger a firstplay event now.
3856
+ // The firstplay event relies on both the play and loadstart events
3857
+ // which can happen in any order for a new source
3858
+ if (!this.paused()) {
3859
+ this.trigger('firstplay');
3860
+ } else {
3861
+ // reset the hasStarted state
3862
+ this.hasStarted(false);
3863
+ this.one('play', function(){
3864
+ this.hasStarted(true);
3865
+ });
3866
+ }
3867
+ };
3868
+
3869
+ vjs.Player.prototype.hasStarted_ = false;
3870
+
3871
+ vjs.Player.prototype.hasStarted = function(hasStarted){
3872
+ if (hasStarted !== undefined) {
3873
+ // only update if this is a new value
3874
+ if (this.hasStarted_ !== hasStarted) {
3875
+ this.hasStarted_ = hasStarted;
3876
+ if (hasStarted) {
3877
+ this.addClass('vjs-has-started');
3878
+ // trigger the firstplay event if this newly has played
3879
+ this.trigger('firstplay');
3880
+ } else {
3881
+ this.removeClass('vjs-has-started');
3882
+ }
3883
+ }
3884
+ return this;
3885
+ }
3886
+ return this.hasStarted_;
3887
+ };
3888
+
3889
+ /**
3890
+ * Fired when the player has initial duration and dimension information
3891
+ * @event loadedmetadata
3892
+ */
3893
+ vjs.Player.prototype.onLoadedMetaData;
3894
+
3895
+ /**
3896
+ * Fired when the player has downloaded data at the current playback position
3897
+ * @event loadeddata
3898
+ */
3899
+ vjs.Player.prototype.onLoadedData;
3900
+
3901
+ /**
3902
+ * Fired when the player has finished downloading the source data
3903
+ * @event loadedalldata
3904
+ */
3905
+ vjs.Player.prototype.onLoadedAllData;
3906
+
3907
+ /**
3908
+ * Fired whenever the media begins or resumes playback
3909
+ * @event play
3910
+ */
3911
+ vjs.Player.prototype.onPlay = function(){
3912
+ this.removeClass('vjs-paused');
3913
+ this.addClass('vjs-playing');
3914
+ };
3915
+
3916
+ /**
3917
+ * Fired whenever the media begins wating
3918
+ * @event waiting
3919
+ */
3920
+ vjs.Player.prototype.onWaiting = function(){
3921
+ this.addClass('vjs-waiting');
3922
+ };
3923
+
3924
+ /**
3925
+ * A handler for events that signal that waiting has eneded
3926
+ * which is not consistent between browsers. See #1351
3927
+ * @private
3928
+ */
3929
+ vjs.Player.prototype.onWaitEnd = function(){
3930
+ this.removeClass('vjs-waiting');
3931
+ };
3932
+
3933
+ /**
3934
+ * Fired whenever the player is jumping to a new time
3935
+ * @event seeking
3936
+ */
3937
+ vjs.Player.prototype.onSeeking = function(){
3938
+ this.addClass('vjs-seeking');
3939
+ };
3940
+
3941
+ /**
3942
+ * Fired when the player has finished jumping to a new time
3943
+ * @event seeked
3944
+ */
3945
+ vjs.Player.prototype.onSeeked = function(){
3946
+ this.removeClass('vjs-seeking');
3947
+ };
3948
+
3949
+ /**
3950
+ * Fired the first time a video is played
3951
+ *
3952
+ * Not part of the HLS spec, and we're not sure if this is the best
3953
+ * implementation yet, so use sparingly. If you don't have a reason to
3954
+ * prevent playback, use `myPlayer.one('play');` instead.
3955
+ *
3956
+ * @event firstplay
3957
+ */
3958
+ vjs.Player.prototype.onFirstPlay = function(){
3959
+ //If the first starttime attribute is specified
3960
+ //then we will start at the given offset in seconds
3961
+ if(this.options_['starttime']){
3962
+ this.currentTime(this.options_['starttime']);
3963
+ }
3964
+
3965
+ this.addClass('vjs-has-started');
3966
+ };
3967
+
3968
+ /**
3969
+ * Fired whenever the media has been paused
3970
+ * @event pause
3971
+ */
3972
+ vjs.Player.prototype.onPause = function(){
3973
+ this.removeClass('vjs-playing');
3974
+ this.addClass('vjs-paused');
3975
+ };
3976
+
3977
+ /**
3978
+ * Fired when the current playback position has changed
3979
+ *
3980
+ * During playback this is fired every 15-250 milliseconds, depending on the
3981
+ * playback technology in use.
3982
+ * @event timeupdate
3983
+ */
3984
+ vjs.Player.prototype.onTimeUpdate;
3985
+
3986
+ /**
3987
+ * Fired while the user agent is downloading media data
3988
+ * @event progress
3989
+ */
3990
+ vjs.Player.prototype.onProgress = function(){
3991
+ // Add custom event for when source is finished downloading.
3992
+ if (this.bufferedPercent() == 1) {
3993
+ this.trigger('loadedalldata');
3994
+ }
3995
+ };
3996
+
3997
+ /**
3998
+ * Fired when the end of the media resource is reached (currentTime == duration)
3999
+ * @event ended
4000
+ */
4001
+ vjs.Player.prototype.onEnded = function(){
4002
+ if (this.options_['loop']) {
4003
+ this.currentTime(0);
4004
+ this.play();
4005
+ } else if (!this.paused()) {
4006
+ this.pause();
4007
+ }
4008
+ };
4009
+
4010
+ /**
4011
+ * Fired when the duration of the media resource is first known or changed
4012
+ * @event durationchange
4013
+ */
4014
+ vjs.Player.prototype.onDurationChange = function(){
4015
+ // Allows for cacheing value instead of asking player each time.
4016
+ // We need to get the techGet response and check for a value so we don't
4017
+ // accidentally cause the stack to blow up.
4018
+ var duration = this.techGet('duration');
4019
+ if (duration) {
4020
+ if (duration < 0) {
4021
+ duration = Infinity;
4022
+ }
4023
+ this.duration(duration);
4024
+ // Determine if the stream is live and propagate styles down to UI.
4025
+ if (duration === Infinity) {
4026
+ this.addClass('vjs-live');
4027
+ } else {
4028
+ this.removeClass('vjs-live');
4029
+ }
4030
+ }
4031
+ };
4032
+
4033
+ /**
4034
+ * Fired when the volume changes
4035
+ * @event volumechange
4036
+ */
4037
+ vjs.Player.prototype.onVolumeChange;
4038
+
4039
+ /**
4040
+ * Fired when the player switches in or out of fullscreen mode
4041
+ * @event fullscreenchange
4042
+ */
4043
+ vjs.Player.prototype.onFullscreenChange = function() {
4044
+ if (this.isFullscreen()) {
4045
+ this.addClass('vjs-fullscreen');
4046
+ } else {
4047
+ this.removeClass('vjs-fullscreen');
4048
+ }
4049
+ };
4050
+
4051
+ // /* Player API
4052
+ // ================================================================================ */
4053
+
4054
+ /**
4055
+ * Object for cached values.
4056
+ * @private
4057
+ */
4058
+ vjs.Player.prototype.cache_;
4059
+
4060
+ vjs.Player.prototype.getCache = function(){
4061
+ return this.cache_;
4062
+ };
4063
+
4064
+ // Pass values to the playback tech
4065
+ vjs.Player.prototype.techCall = function(method, arg){
4066
+ // If it's not ready yet, call method when it is
4067
+ if (this.tech && !this.tech.isReady_) {
4068
+ this.tech.ready(function(){
4069
+ this[method](arg);
4070
+ });
4071
+
4072
+ // Otherwise call method now
4073
+ } else {
4074
+ try {
4075
+ this.tech[method](arg);
4076
+ } catch(e) {
4077
+ vjs.log(e);
4078
+ throw e;
4079
+ }
4080
+ }
4081
+ };
4082
+
4083
+ // Get calls can't wait for the tech, and sometimes don't need to.
4084
+ vjs.Player.prototype.techGet = function(method){
4085
+ if (this.tech && this.tech.isReady_) {
4086
+
4087
+ // Flash likes to die and reload when you hide or reposition it.
4088
+ // In these cases the object methods go away and we get errors.
4089
+ // When that happens we'll catch the errors and inform tech that it's not ready any more.
4090
+ try {
4091
+ return this.tech[method]();
4092
+ } catch(e) {
4093
+ // When building additional tech libs, an expected method may not be defined yet
4094
+ if (this.tech[method] === undefined) {
4095
+ vjs.log('Video.js: ' + method + ' method not defined for '+this.techName+' playback technology.', e);
4096
+ } else {
4097
+ // When a method isn't available on the object it throws a TypeError
4098
+ if (e.name == 'TypeError') {
4099
+ vjs.log('Video.js: ' + method + ' unavailable on '+this.techName+' playback technology element.', e);
4100
+ this.tech.isReady_ = false;
4101
+ } else {
4102
+ vjs.log(e);
4103
+ }
4104
+ }
4105
+ throw e;
4106
+ }
4107
+ }
4108
+
4109
+ return;
4110
+ };
4111
+
4112
+ /**
4113
+ * start media playback
4114
+ *
4115
+ * myPlayer.play();
4116
+ *
4117
+ * @return {vjs.Player} self
4118
+ */
4119
+ vjs.Player.prototype.play = function(){
4120
+ this.techCall('play');
4121
+ return this;
4122
+ };
4123
+
4124
+ /**
4125
+ * Pause the video playback
4126
+ *
4127
+ * myPlayer.pause();
4128
+ *
4129
+ * @return {vjs.Player} self
4130
+ */
4131
+ vjs.Player.prototype.pause = function(){
4132
+ this.techCall('pause');
4133
+ return this;
4134
+ };
4135
+
4136
+ /**
4137
+ * Check if the player is paused
4138
+ *
4139
+ * var isPaused = myPlayer.paused();
4140
+ * var isPlaying = !myPlayer.paused();
4141
+ *
4142
+ * @return {Boolean} false if the media is currently playing, or true otherwise
4143
+ */
4144
+ vjs.Player.prototype.paused = function(){
4145
+ // The initial state of paused should be true (in Safari it's actually false)
4146
+ return (this.techGet('paused') === false) ? false : true;
4147
+ };
4148
+
4149
+ /**
4150
+ * Get or set the current time (in seconds)
4151
+ *
4152
+ * // get
4153
+ * var whereYouAt = myPlayer.currentTime();
4154
+ *
4155
+ * // set
4156
+ * myPlayer.currentTime(120); // 2 minutes into the video
4157
+ *
4158
+ * @param {Number|String=} seconds The time to seek to
4159
+ * @return {Number} The time in seconds, when not setting
4160
+ * @return {vjs.Player} self, when the current time is set
4161
+ */
4162
+ vjs.Player.prototype.currentTime = function(seconds){
4163
+ if (seconds !== undefined) {
4164
+
4165
+ this.techCall('setCurrentTime', seconds);
4166
+
4167
+ return this;
4168
+ }
4169
+
4170
+ // cache last currentTime and return. default to 0 seconds
4171
+ //
4172
+ // Caching the currentTime is meant to prevent a massive amount of reads on the tech's
4173
+ // currentTime when scrubbing, but may not provide much performace benefit afterall.
4174
+ // Should be tested. Also something has to read the actual current time or the cache will
4175
+ // never get updated.
4176
+ return this.cache_.currentTime = (this.techGet('currentTime') || 0);
4177
+ };
4178
+
4179
+ /**
4180
+ * Get the length in time of the video in seconds
4181
+ *
4182
+ * var lengthOfVideo = myPlayer.duration();
4183
+ *
4184
+ * **NOTE**: The video must have started loading before the duration can be
4185
+ * known, and in the case of Flash, may not be known until the video starts
4186
+ * playing.
4187
+ *
4188
+ * @return {Number} The duration of the video in seconds
4189
+ */
4190
+ vjs.Player.prototype.duration = function(seconds){
4191
+ if (seconds !== undefined) {
4192
+
4193
+ // cache the last set value for optimiized scrubbing (esp. Flash)
4194
+ this.cache_.duration = parseFloat(seconds);
4195
+
4196
+ return this;
4197
+ }
4198
+
4199
+ if (this.cache_.duration === undefined) {
4200
+ this.onDurationChange();
4201
+ }
4202
+
4203
+ return this.cache_.duration || 0;
4204
+ };
4205
+
4206
+ /**
4207
+ * Calculates how much time is left.
4208
+ *
4209
+ * var timeLeft = myPlayer.remainingTime();
4210
+ *
4211
+ * Not a native video element function, but useful
4212
+ * @return {Number} The time remaining in seconds
4213
+ */
4214
+ vjs.Player.prototype.remainingTime = function(){
4215
+ return this.duration() - this.currentTime();
4216
+ };
4217
+
4218
+ // http://dev.w3.org/html5/spec/video.html#dom-media-buffered
4219
+ // Buffered returns a timerange object.
4220
+ // Kind of like an array of portions of the video that have been downloaded.
4221
+
4222
+ /**
4223
+ * Get a TimeRange object with the times of the video that have been downloaded
4224
+ *
4225
+ * If you just want the percent of the video that's been downloaded,
4226
+ * use bufferedPercent.
4227
+ *
4228
+ * // Number of different ranges of time have been buffered. Usually 1.
4229
+ * numberOfRanges = bufferedTimeRange.length,
4230
+ *
4231
+ * // Time in seconds when the first range starts. Usually 0.
4232
+ * firstRangeStart = bufferedTimeRange.start(0),
4233
+ *
4234
+ * // Time in seconds when the first range ends
4235
+ * firstRangeEnd = bufferedTimeRange.end(0),
4236
+ *
4237
+ * // Length in seconds of the first time range
4238
+ * firstRangeLength = firstRangeEnd - firstRangeStart;
4239
+ *
4240
+ * @return {Object} A mock TimeRange object (following HTML spec)
4241
+ */
4242
+ vjs.Player.prototype.buffered = function(){
4243
+ var buffered = this.techGet('buffered');
4244
+
4245
+ if (!buffered || !buffered.length) {
4246
+ buffered = vjs.createTimeRange(0,0);
4247
+ }
4248
+
4249
+ return buffered;
4250
+ };
4251
+
4252
+ /**
4253
+ * Get the percent (as a decimal) of the video that's been downloaded
4254
+ *
4255
+ * var howMuchIsDownloaded = myPlayer.bufferedPercent();
4256
+ *
4257
+ * 0 means none, 1 means all.
4258
+ * (This method isn't in the HTML5 spec, but it's very convenient)
4259
+ *
4260
+ * @return {Number} A decimal between 0 and 1 representing the percent
4261
+ */
4262
+ vjs.Player.prototype.bufferedPercent = function(){
4263
+ var duration = this.duration(),
4264
+ buffered = this.buffered(),
4265
+ bufferedDuration = 0,
4266
+ start, end;
4267
+
4268
+ if (!duration) {
4269
+ return 0;
4270
+ }
4271
+
4272
+ for (var i=0; i<buffered.length; i++){
4273
+ start = buffered.start(i);
4274
+ end = buffered.end(i);
4275
+
4276
+ // buffered end can be bigger than duration by a very small fraction
4277
+ if (end > duration) {
4278
+ end = duration;
4279
+ }
4280
+
4281
+ bufferedDuration += end - start;
4282
+ }
4283
+
4284
+ return bufferedDuration / duration;
4285
+ };
4286
+
4287
+ /**
4288
+ * Get the ending time of the last buffered time range
4289
+ *
4290
+ * This is used in the progress bar to encapsulate all time ranges.
4291
+ * @return {Number} The end of the last buffered time range
4292
+ */
4293
+ vjs.Player.prototype.bufferedEnd = function(){
4294
+ var buffered = this.buffered(),
4295
+ duration = this.duration(),
4296
+ end = buffered.end(buffered.length-1);
4297
+
4298
+ if (end > duration) {
4299
+ end = duration;
4300
+ }
4301
+
4302
+ return end;
4303
+ };
4304
+
4305
+ /**
4306
+ * Get or set the current volume of the media
4307
+ *
4308
+ * // get
4309
+ * var howLoudIsIt = myPlayer.volume();
4310
+ *
4311
+ * // set
4312
+ * myPlayer.volume(0.5); // Set volume to half
4313
+ *
4314
+ * 0 is off (muted), 1.0 is all the way up, 0.5 is half way.
4315
+ *
4316
+ * @param {Number} percentAsDecimal The new volume as a decimal percent
4317
+ * @return {Number} The current volume, when getting
4318
+ * @return {vjs.Player} self, when setting
4319
+ */
4320
+ vjs.Player.prototype.volume = function(percentAsDecimal){
4321
+ var vol;
4322
+
4323
+ if (percentAsDecimal !== undefined) {
4324
+ vol = Math.max(0, Math.min(1, parseFloat(percentAsDecimal))); // Force value to between 0 and 1
4325
+ this.cache_.volume = vol;
4326
+ this.techCall('setVolume', vol);
4327
+ vjs.setLocalStorage('volume', vol);
4328
+ return this;
4329
+ }
4330
+
4331
+ // Default to 1 when returning current volume.
4332
+ vol = parseFloat(this.techGet('volume'));
4333
+ return (isNaN(vol)) ? 1 : vol;
4334
+ };
4335
+
4336
+
4337
+ /**
4338
+ * Get the current muted state, or turn mute on or off
4339
+ *
4340
+ * // get
4341
+ * var isVolumeMuted = myPlayer.muted();
4342
+ *
4343
+ * // set
4344
+ * myPlayer.muted(true); // mute the volume
4345
+ *
4346
+ * @param {Boolean=} muted True to mute, false to unmute
4347
+ * @return {Boolean} True if mute is on, false if not, when getting
4348
+ * @return {vjs.Player} self, when setting mute
4349
+ */
4350
+ vjs.Player.prototype.muted = function(muted){
4351
+ if (muted !== undefined) {
4352
+ this.techCall('setMuted', muted);
4353
+ return this;
4354
+ }
4355
+ return this.techGet('muted') || false; // Default to false
4356
+ };
4357
+
4358
+ // Check if current tech can support native fullscreen
4359
+ // (e.g. with built in controls lik iOS, so not our flash swf)
4360
+ vjs.Player.prototype.supportsFullScreen = function(){
4361
+ return this.techGet('supportsFullScreen') || false;
4362
+ };
4363
+
4364
+ /**
4365
+ * is the player in fullscreen
4366
+ * @type {Boolean}
4367
+ * @private
4368
+ */
4369
+ vjs.Player.prototype.isFullscreen_ = false;
4370
+
4371
+ /**
4372
+ * Check if the player is in fullscreen mode
4373
+ *
4374
+ * // get
4375
+ * var fullscreenOrNot = myPlayer.isFullscreen();
4376
+ *
4377
+ * // set
4378
+ * myPlayer.isFullscreen(true); // tell the player it's in fullscreen
4379
+ *
4380
+ * NOTE: As of the latest HTML5 spec, isFullscreen is no longer an official
4381
+ * property and instead document.fullscreenElement is used. But isFullscreen is
4382
+ * still a valuable property for internal player workings.
4383
+ *
4384
+ * @param {Boolean=} isFS Update the player's fullscreen state
4385
+ * @return {Boolean} true if fullscreen, false if not
4386
+ * @return {vjs.Player} self, when setting
4387
+ */
4388
+ vjs.Player.prototype.isFullscreen = function(isFS){
4389
+ if (isFS !== undefined) {
4390
+ this.isFullscreen_ = !!isFS;
4391
+ return this;
4392
+ }
4393
+ return this.isFullscreen_;
4394
+ };
4395
+
4396
+ /**
4397
+ * Old naming for isFullscreen()
4398
+ * @deprecated for lowercase 's' version
4399
+ */
4400
+ vjs.Player.prototype.isFullScreen = function(isFS){
4401
+ vjs.log.warn('player.isFullScreen() has been deprecated, use player.isFullscreen() with a lowercase "s")');
4402
+ return this.isFullscreen(isFS);
4403
+ };
4404
+
4405
+ /**
4406
+ * Increase the size of the video to full screen
4407
+ *
4408
+ * myPlayer.requestFullscreen();
4409
+ *
4410
+ * In some browsers, full screen is not supported natively, so it enters
4411
+ * "full window mode", where the video fills the browser window.
4412
+ * In browsers and devices that support native full screen, sometimes the
4413
+ * browser's default controls will be shown, and not the Video.js custom skin.
4414
+ * This includes most mobile devices (iOS, Android) and older versions of
4415
+ * Safari.
4416
+ *
4417
+ * @return {vjs.Player} self
4418
+ */
4419
+ vjs.Player.prototype.requestFullscreen = function(){
4420
+ var fsApi = vjs.browser.fullscreenAPI;
4421
+
4422
+ this.isFullscreen(true);
4423
+
4424
+ if (fsApi) {
4425
+ // the browser supports going fullscreen at the element level so we can
4426
+ // take the controls fullscreen as well as the video
4427
+
4428
+ // Trigger fullscreenchange event after change
4429
+ // We have to specifically add this each time, and remove
4430
+ // when cancelling fullscreen. Otherwise if there's multiple
4431
+ // players on a page, they would all be reacting to the same fullscreen
4432
+ // events
4433
+ vjs.on(document, fsApi['fullscreenchange'], vjs.bind(this, function(e){
4434
+ this.isFullscreen(document[fsApi.fullscreenElement]);
4435
+
4436
+ // If cancelling fullscreen, remove event listener.
4437
+ if (this.isFullscreen() === false) {
4438
+ vjs.off(document, fsApi['fullscreenchange'], arguments.callee);
4439
+ }
4440
+
4441
+ this.trigger('fullscreenchange');
4442
+ }));
4443
+
4444
+ this.el_[fsApi.requestFullscreen]();
4445
+
4446
+ } else if (this.tech.supportsFullScreen()) {
4447
+ // we can't take the video.js controls fullscreen but we can go fullscreen
4448
+ // with native controls
4449
+ this.techCall('enterFullScreen');
4450
+ } else {
4451
+ // fullscreen isn't supported so we'll just stretch the video element to
4452
+ // fill the viewport
4453
+ this.enterFullWindow();
4454
+ this.trigger('fullscreenchange');
4455
+ }
4456
+
4457
+ return this;
4458
+ };
4459
+
4460
+ /**
4461
+ * Old naming for requestFullscreen
4462
+ * @deprecated for lower case 's' version
4463
+ */
4464
+ vjs.Player.prototype.requestFullScreen = function(){
4465
+ vjs.log.warn('player.requestFullScreen() has been deprecated, use player.requestFullscreen() with a lowercase "s")');
4466
+ return this.requestFullscreen();
4467
+ };
4468
+
4469
+
4470
+ /**
4471
+ * Return the video to its normal size after having been in full screen mode
4472
+ *
4473
+ * myPlayer.exitFullscreen();
4474
+ *
4475
+ * @return {vjs.Player} self
4476
+ */
4477
+ vjs.Player.prototype.exitFullscreen = function(){
4478
+ var fsApi = vjs.browser.fullscreenAPI;
4479
+ this.isFullscreen(false);
4480
+
4481
+ // Check for browser element fullscreen support
4482
+ if (fsApi) {
4483
+ document[fsApi.exitFullscreen]();
4484
+ } else if (this.tech.supportsFullScreen()) {
4485
+ this.techCall('exitFullScreen');
4486
+ } else {
4487
+ this.exitFullWindow();
4488
+ this.trigger('fullscreenchange');
4489
+ }
4490
+
4491
+ return this;
4492
+ };
4493
+
4494
+ /**
4495
+ * Old naming for exitFullscreen
4496
+ * @deprecated for exitFullscreen
4497
+ */
4498
+ vjs.Player.prototype.cancelFullScreen = function(){
4499
+ vjs.log.warn('player.cancelFullScreen() has been deprecated, use player.exitFullscreen()');
4500
+ return this.exitFullscreen();
4501
+ };
4502
+
4503
+ // When fullscreen isn't supported we can stretch the video container to as wide as the browser will let us.
4504
+ vjs.Player.prototype.enterFullWindow = function(){
4505
+ this.isFullWindow = true;
4506
+
4507
+ // Storing original doc overflow value to return to when fullscreen is off
4508
+ this.docOrigOverflow = document.documentElement.style.overflow;
4509
+
4510
+ // Add listener for esc key to exit fullscreen
4511
+ vjs.on(document, 'keydown', vjs.bind(this, this.fullWindowOnEscKey));
4512
+
4513
+ // Hide any scroll bars
4514
+ document.documentElement.style.overflow = 'hidden';
4515
+
4516
+ // Apply fullscreen styles
4517
+ vjs.addClass(document.body, 'vjs-full-window');
4518
+
4519
+ this.trigger('enterFullWindow');
4520
+ };
4521
+ vjs.Player.prototype.fullWindowOnEscKey = function(event){
4522
+ if (event.keyCode === 27) {
4523
+ if (this.isFullscreen() === true) {
4524
+ this.exitFullscreen();
4525
+ } else {
4526
+ this.exitFullWindow();
4527
+ }
4528
+ }
4529
+ };
4530
+
4531
+ vjs.Player.prototype.exitFullWindow = function(){
4532
+ this.isFullWindow = false;
4533
+ vjs.off(document, 'keydown', this.fullWindowOnEscKey);
4534
+
4535
+ // Unhide scroll bars.
4536
+ document.documentElement.style.overflow = this.docOrigOverflow;
4537
+
4538
+ // Remove fullscreen styles
4539
+ vjs.removeClass(document.body, 'vjs-full-window');
4540
+
4541
+ // Resize the box, controller, and poster to original sizes
4542
+ // this.positionAll();
4543
+ this.trigger('exitFullWindow');
4544
+ };
4545
+
4546
+ vjs.Player.prototype.selectSource = function(sources){
4547
+
4548
+ // Loop through each playback technology in the options order
4549
+ for (var i=0,j=this.options_['techOrder'];i<j.length;i++) {
4550
+ var techName = vjs.capitalize(j[i]),
4551
+ tech = window['videojs'][techName];
4552
+
4553
+ // Check if the current tech is defined before continuing
4554
+ if (!tech) {
4555
+ vjs.log.error('The "' + techName + '" tech is undefined. Skipped browser support check for that tech.');
4556
+ continue;
4557
+ }
4558
+
4559
+ // Check if the browser supports this technology
4560
+ if (tech.isSupported()) {
4561
+ // Loop through each source object
4562
+ for (var a=0,b=sources;a<b.length;a++) {
4563
+ var source = b[a];
4564
+
4565
+ // Check if source can be played with this technology
4566
+ if (tech['canPlaySource'](source)) {
4567
+ return { source: source, tech: techName };
4568
+ }
4569
+ }
4570
+ }
4571
+ }
4572
+
4573
+ return false;
4574
+ };
4575
+
4576
+ /**
4577
+ * The source function updates the video source
4578
+ *
4579
+ * There are three types of variables you can pass as the argument.
4580
+ *
4581
+ * **URL String**: A URL to the the video file. Use this method if you are sure
4582
+ * the current playback technology (HTML5/Flash) can support the source you
4583
+ * provide. Currently only MP4 files can be used in both HTML5 and Flash.
4584
+ *
4585
+ * myPlayer.src("http://www.example.com/path/to/video.mp4");
4586
+ *
4587
+ * **Source Object (or element):** A javascript object containing information
4588
+ * about the source file. Use this method if you want the player to determine if
4589
+ * it can support the file using the type information.
4590
+ *
4591
+ * myPlayer.src({ type: "video/mp4", src: "http://www.example.com/path/to/video.mp4" });
4592
+ *
4593
+ * **Array of Source Objects:** To provide multiple versions of the source so
4594
+ * that it can be played using HTML5 across browsers you can use an array of
4595
+ * source objects. Video.js will detect which version is supported and load that
4596
+ * file.
4597
+ *
4598
+ * myPlayer.src([
4599
+ * { type: "video/mp4", src: "http://www.example.com/path/to/video.mp4" },
4600
+ * { type: "video/webm", src: "http://www.example.com/path/to/video.webm" },
4601
+ * { type: "video/ogg", src: "http://www.example.com/path/to/video.ogv" }
4602
+ * ]);
4603
+ *
4604
+ * @param {String|Object|Array=} source The source URL, object, or array of sources
4605
+ * @return {String} The current video source when getting
4606
+ * @return {String} The player when setting
4607
+ */
4608
+ vjs.Player.prototype.src = function(source){
4609
+ if (source === undefined) {
4610
+ return this.techGet('src');
4611
+ }
4612
+
4613
+ // case: Array of source objects to choose from and pick the best to play
4614
+ if (vjs.obj.isArray(source)) {
4615
+ this.sourceList_(source);
4616
+
4617
+ // case: URL String (http://myvideo...)
4618
+ } else if (typeof source === 'string') {
4619
+ // create a source object from the string
4620
+ this.src({ src: source });
4621
+
4622
+ // case: Source object { src: '', type: '' ... }
4623
+ } else if (source instanceof Object) {
4624
+ // check if the source has a type and the loaded tech cannot play the source
4625
+ // if there's no type we'll just try the current tech
4626
+ if (source.type && !window['videojs'][this.techName]['canPlaySource'](source)) {
4627
+ // create a source list with the current source and send through
4628
+ // the tech loop to check for a compatible technology
4629
+ this.sourceList_([source]);
4630
+ } else {
4631
+ this.cache_.src = source.src;
4632
+ this.currentType_ = source.type || '';
4633
+
4634
+ // wait until the tech is ready to set the source
4635
+ this.ready(function(){
4636
+ this.techCall('src', source.src);
4637
+
4638
+ if (this.options_['preload'] == 'auto') {
4639
+ this.load();
4640
+ }
4641
+
4642
+ if (this.options_['autoplay']) {
4643
+ this.play();
4644
+ }
4645
+ });
4646
+ }
4647
+ }
4648
+
4649
+ return this;
4650
+ };
4651
+
4652
+ /**
4653
+ * Handle an array of source objects
4654
+ * @param {[type]} sources Array of source objects
4655
+ * @private
4656
+ */
4657
+ vjs.Player.prototype.sourceList_ = function(sources){
4658
+ var sourceTech = this.selectSource(sources),
4659
+ errorTimeout;
4660
+
4661
+ if (sourceTech) {
4662
+ if (sourceTech.tech === this.techName) {
4663
+ // if this technology is already loaded, set the source
4664
+ this.src(sourceTech.source);
4665
+ } else {
4666
+ // load this technology with the chosen source
4667
+ this.loadTech(sourceTech.tech, sourceTech.source);
4668
+ }
4669
+ } else {
4670
+ // We need to wrap this in a timeout to give folks a chance to add error event handlers
4671
+ errorTimeout = setTimeout(vjs.bind(this, function() {
4672
+ this.error({ code: 4, message: this.localize(this.options()['notSupportedMessage']) });
4673
+ }), 0);
4674
+
4675
+ // we could not find an appropriate tech, but let's still notify the delegate that this is it
4676
+ // this needs a better comment about why this is needed
4677
+ this.triggerReady();
4678
+
4679
+ this.on('dispose', function() {
4680
+ clearTimeout(errorTimeout);
4681
+ });
4682
+ }
4683
+ };
4684
+
4685
+ /**
4686
+ * Begin loading the src data.
4687
+ * @return {vjs.Player} Returns the player
4688
+ */
4689
+ vjs.Player.prototype.load = function(){
4690
+ this.techCall('load');
4691
+ return this;
4692
+ };
4693
+
4694
+ /**
4695
+ * Returns the fully qualified URL of the current source value e.g. http://mysite.com/video.mp4
4696
+ * Can be used in conjuction with `currentType` to assist in rebuilding the current source object.
4697
+ * @return {String} The current source
4698
+ */
4699
+ vjs.Player.prototype.currentSrc = function(){
4700
+ return this.techGet('currentSrc') || this.cache_.src || '';
4701
+ };
4702
+
4703
+ /**
4704
+ * Get the current source type e.g. video/mp4
4705
+ * This can allow you rebuild the current source object so that you could load the same
4706
+ * source and tech later
4707
+ * @return {String} The source MIME type
4708
+ */
4709
+ vjs.Player.prototype.currentType = function(){
4710
+ return this.currentType_ || '';
4711
+ };
4712
+
4713
+ /**
4714
+ * Get or set the preload attribute.
4715
+ * @return {String} The preload attribute value when getting
4716
+ * @return {vjs.Player} Returns the player when setting
4717
+ */
4718
+ vjs.Player.prototype.preload = function(value){
4719
+ if (value !== undefined) {
4720
+ this.techCall('setPreload', value);
4721
+ this.options_['preload'] = value;
4722
+ return this;
4723
+ }
4724
+ return this.techGet('preload');
4725
+ };
4726
+
4727
+ /**
4728
+ * Get or set the autoplay attribute.
4729
+ * @return {String} The autoplay attribute value when getting
4730
+ * @return {vjs.Player} Returns the player when setting
4731
+ */
4732
+ vjs.Player.prototype.autoplay = function(value){
4733
+ if (value !== undefined) {
4734
+ this.techCall('setAutoplay', value);
4735
+ this.options_['autoplay'] = value;
4736
+ return this;
4737
+ }
4738
+ return this.techGet('autoplay', value);
4739
+ };
4740
+
4741
+ /**
4742
+ * Get or set the loop attribute on the video element.
4743
+ * @return {String} The loop attribute value when getting
4744
+ * @return {vjs.Player} Returns the player when setting
4745
+ */
4746
+ vjs.Player.prototype.loop = function(value){
4747
+ if (value !== undefined) {
4748
+ this.techCall('setLoop', value);
4749
+ this.options_['loop'] = value;
4750
+ return this;
4751
+ }
4752
+ return this.techGet('loop');
4753
+ };
4754
+
4755
+ /**
4756
+ * the url of the poster image source
4757
+ * @type {String}
4758
+ * @private
4759
+ */
4760
+ vjs.Player.prototype.poster_;
4761
+
4762
+ /**
4763
+ * get or set the poster image source url
4764
+ *
4765
+ * ##### EXAMPLE:
4766
+ *
4767
+ * // getting
4768
+ * var currentPoster = myPlayer.poster();
4769
+ *
4770
+ * // setting
4771
+ * myPlayer.poster('http://example.com/myImage.jpg');
4772
+ *
4773
+ * @param {String=} [src] Poster image source URL
4774
+ * @return {String} poster URL when getting
4775
+ * @return {vjs.Player} self when setting
4776
+ */
4777
+ vjs.Player.prototype.poster = function(src){
4778
+ if (src === undefined) {
4779
+ return this.poster_;
4780
+ }
4781
+
4782
+ // The correct way to remove a poster is to set as an empty string
4783
+ // other falsey values will throw errors
4784
+ if (!src) {
4785
+ src = '';
4786
+ }
4787
+
4788
+ // update the internal poster variable
4789
+ this.poster_ = src;
4790
+
4791
+ // update the tech's poster
4792
+ this.techCall('setPoster', src);
4793
+
4794
+ // alert components that the poster has been set
4795
+ this.trigger('posterchange');
4796
+
4797
+ return this;
4798
+ };
4799
+
4800
+ /**
4801
+ * Whether or not the controls are showing
4802
+ * @type {Boolean}
4803
+ * @private
4804
+ */
4805
+ vjs.Player.prototype.controls_;
4806
+
4807
+ /**
4808
+ * Get or set whether or not the controls are showing.
4809
+ * @param {Boolean} controls Set controls to showing or not
4810
+ * @return {Boolean} Controls are showing
4811
+ */
4812
+ vjs.Player.prototype.controls = function(bool){
4813
+ if (bool !== undefined) {
4814
+ bool = !!bool; // force boolean
4815
+ // Don't trigger a change event unless it actually changed
4816
+ if (this.controls_ !== bool) {
4817
+ this.controls_ = bool;
4818
+ if (bool) {
4819
+ this.removeClass('vjs-controls-disabled');
4820
+ this.addClass('vjs-controls-enabled');
4821
+ this.trigger('controlsenabled');
4822
+ } else {
4823
+ this.removeClass('vjs-controls-enabled');
4824
+ this.addClass('vjs-controls-disabled');
4825
+ this.trigger('controlsdisabled');
4826
+ }
4827
+ }
4828
+ return this;
4829
+ }
4830
+ return this.controls_;
4831
+ };
4832
+
4833
+ vjs.Player.prototype.usingNativeControls_;
4834
+
4835
+ /**
4836
+ * Toggle native controls on/off. Native controls are the controls built into
4837
+ * devices (e.g. default iPhone controls), Flash, or other techs
4838
+ * (e.g. Vimeo Controls)
4839
+ *
4840
+ * **This should only be set by the current tech, because only the tech knows
4841
+ * if it can support native controls**
4842
+ *
4843
+ * @param {Boolean} bool True signals that native controls are on
4844
+ * @return {vjs.Player} Returns the player
4845
+ * @private
4846
+ */
4847
+ vjs.Player.prototype.usingNativeControls = function(bool){
4848
+ if (bool !== undefined) {
4849
+ bool = !!bool; // force boolean
4850
+ // Don't trigger a change event unless it actually changed
4851
+ if (this.usingNativeControls_ !== bool) {
4852
+ this.usingNativeControls_ = bool;
4853
+ if (bool) {
4854
+ this.addClass('vjs-using-native-controls');
4855
+
4856
+ /**
4857
+ * player is using the native device controls
4858
+ *
4859
+ * @event usingnativecontrols
4860
+ * @memberof vjs.Player
4861
+ * @instance
4862
+ * @private
4863
+ */
4864
+ this.trigger('usingnativecontrols');
4865
+ } else {
4866
+ this.removeClass('vjs-using-native-controls');
4867
+
4868
+ /**
4869
+ * player is using the custom HTML controls
4870
+ *
4871
+ * @event usingcustomcontrols
4872
+ * @memberof vjs.Player
4873
+ * @instance
4874
+ * @private
4875
+ */
4876
+ this.trigger('usingcustomcontrols');
4877
+ }
4878
+ }
4879
+ return this;
4880
+ }
4881
+ return this.usingNativeControls_;
4882
+ };
4883
+
4884
+ /**
4885
+ * Store the current media error
4886
+ * @type {Object}
4887
+ * @private
4888
+ */
4889
+ vjs.Player.prototype.error_ = null;
4890
+
4891
+ /**
4892
+ * Set or get the current MediaError
4893
+ * @param {*} err A MediaError or a String/Number to be turned into a MediaError
4894
+ * @return {vjs.MediaError|null} when getting
4895
+ * @return {vjs.Player} when setting
4896
+ */
4897
+ vjs.Player.prototype.error = function(err){
4898
+ if (err === undefined) {
4899
+ return this.error_;
4900
+ }
4901
+
4902
+ // restoring to default
4903
+ if (err === null) {
4904
+ this.error_ = err;
4905
+ this.removeClass('vjs-error');
4906
+ return this;
4907
+ }
4908
+
4909
+ // error instance
4910
+ if (err instanceof vjs.MediaError) {
4911
+ this.error_ = err;
4912
+ } else {
4913
+ this.error_ = new vjs.MediaError(err);
4914
+ }
4915
+
4916
+ // fire an error event on the player
4917
+ this.trigger('error');
4918
+
4919
+ // add the vjs-error classname to the player
4920
+ this.addClass('vjs-error');
4921
+
4922
+ // log the name of the error type and any message
4923
+ // ie8 just logs "[object object]" if you just log the error object
4924
+ vjs.log.error('(CODE:'+this.error_.code+' '+vjs.MediaError.errorTypes[this.error_.code]+')', this.error_.message, this.error_);
4925
+
4926
+ return this;
4927
+ };
4928
+
4929
+ /**
4930
+ * Returns whether or not the player is in the "ended" state.
4931
+ * @return {Boolean} True if the player is in the ended state, false if not.
4932
+ */
4933
+ vjs.Player.prototype.ended = function(){ return this.techGet('ended'); };
4934
+
4935
+ /**
4936
+ * Returns whether or not the player is in the "seeking" state.
4937
+ * @return {Boolean} True if the player is in the seeking state, false if not.
4938
+ */
4939
+ vjs.Player.prototype.seeking = function(){ return this.techGet('seeking'); };
4940
+
4941
+ // When the player is first initialized, trigger activity so components
4942
+ // like the control bar show themselves if needed
4943
+ vjs.Player.prototype.userActivity_ = true;
4944
+ vjs.Player.prototype.reportUserActivity = function(event){
4945
+ this.userActivity_ = true;
4946
+ };
4947
+
4948
+ vjs.Player.prototype.userActive_ = true;
4949
+ vjs.Player.prototype.userActive = function(bool){
4950
+ if (bool !== undefined) {
4951
+ bool = !!bool;
4952
+ if (bool !== this.userActive_) {
4953
+ this.userActive_ = bool;
4954
+ if (bool) {
4955
+ // If the user was inactive and is now active we want to reset the
4956
+ // inactivity timer
4957
+ this.userActivity_ = true;
4958
+ this.removeClass('vjs-user-inactive');
4959
+ this.addClass('vjs-user-active');
4960
+ this.trigger('useractive');
4961
+ } else {
4962
+ // We're switching the state to inactive manually, so erase any other
4963
+ // activity
4964
+ this.userActivity_ = false;
4965
+
4966
+ // Chrome/Safari/IE have bugs where when you change the cursor it can
4967
+ // trigger a mousemove event. This causes an issue when you're hiding
4968
+ // the cursor when the user is inactive, and a mousemove signals user
4969
+ // activity. Making it impossible to go into inactive mode. Specifically
4970
+ // this happens in fullscreen when we really need to hide the cursor.
4971
+ //
4972
+ // When this gets resolved in ALL browsers it can be removed
4973
+ // https://code.google.com/p/chromium/issues/detail?id=103041
4974
+ if(this.tech) {
4975
+ this.tech.one('mousemove', function(e){
4976
+ e.stopPropagation();
4977
+ e.preventDefault();
4978
+ });
4979
+ }
4980
+
4981
+ this.removeClass('vjs-user-active');
4982
+ this.addClass('vjs-user-inactive');
4983
+ this.trigger('userinactive');
4984
+ }
4985
+ }
4986
+ return this;
4987
+ }
4988
+ return this.userActive_;
4989
+ };
4990
+
4991
+ vjs.Player.prototype.listenForUserActivity = function(){
4992
+ var onActivity, onMouseMove, onMouseDown, mouseInProgress, onMouseUp,
4993
+ activityCheck, inactivityTimeout, lastMoveX, lastMoveY;
4994
+
4995
+ onActivity = vjs.bind(this, this.reportUserActivity);
4996
+
4997
+ onMouseMove = function(e) {
4998
+ // #1068 - Prevent mousemove spamming
4999
+ // Chrome Bug: https://code.google.com/p/chromium/issues/detail?id=366970
5000
+ if(e.screenX != lastMoveX || e.screenY != lastMoveY) {
5001
+ lastMoveX = e.screenX;
5002
+ lastMoveY = e.screenY;
5003
+ onActivity();
5004
+ }
5005
+ };
5006
+
5007
+ onMouseDown = function() {
5008
+ onActivity();
5009
+ // For as long as the they are touching the device or have their mouse down,
5010
+ // we consider them active even if they're not moving their finger or mouse.
5011
+ // So we want to continue to update that they are active
5012
+ clearInterval(mouseInProgress);
5013
+ // Setting userActivity=true now and setting the interval to the same time
5014
+ // as the activityCheck interval (250) should ensure we never miss the
5015
+ // next activityCheck
5016
+ mouseInProgress = setInterval(onActivity, 250);
5017
+ };
5018
+
5019
+ onMouseUp = function(event) {
5020
+ onActivity();
5021
+ // Stop the interval that maintains activity if the mouse/touch is down
5022
+ clearInterval(mouseInProgress);
5023
+ };
5024
+
5025
+ // Any mouse movement will be considered user activity
5026
+ this.on('mousedown', onMouseDown);
5027
+ this.on('mousemove', onMouseMove);
5028
+ this.on('mouseup', onMouseUp);
5029
+
5030
+ // Listen for keyboard navigation
5031
+ // Shouldn't need to use inProgress interval because of key repeat
5032
+ this.on('keydown', onActivity);
5033
+ this.on('keyup', onActivity);
5034
+
5035
+ // Run an interval every 250 milliseconds instead of stuffing everything into
5036
+ // the mousemove/touchmove function itself, to prevent performance degradation.
5037
+ // `this.reportUserActivity` simply sets this.userActivity_ to true, which
5038
+ // then gets picked up by this loop
5039
+ // http://ejohn.org/blog/learning-from-twitter/
5040
+ activityCheck = setInterval(vjs.bind(this, function() {
5041
+ // Check to see if mouse/touch activity has happened
5042
+ if (this.userActivity_) {
5043
+ // Reset the activity tracker
5044
+ this.userActivity_ = false;
5045
+
5046
+ // If the user state was inactive, set the state to active
5047
+ this.userActive(true);
5048
+
5049
+ // Clear any existing inactivity timeout to start the timer over
5050
+ clearTimeout(inactivityTimeout);
5051
+
5052
+ var timeout = this.options()['inactivityTimeout'];
5053
+ if (timeout > 0) {
5054
+ // In <timeout> milliseconds, if no more activity has occurred the
5055
+ // user will be considered inactive
5056
+ inactivityTimeout = setTimeout(vjs.bind(this, function () {
5057
+ // Protect against the case where the inactivityTimeout can trigger just
5058
+ // before the next user activity is picked up by the activityCheck loop
5059
+ // causing a flicker
5060
+ if (!this.userActivity_) {
5061
+ this.userActive(false);
5062
+ }
5063
+ }), timeout);
5064
+ }
5065
+ }
5066
+ }), 250);
5067
+
5068
+ // Clean up the intervals when we kill the player
5069
+ this.on('dispose', function(){
5070
+ clearInterval(activityCheck);
5071
+ clearTimeout(inactivityTimeout);
5072
+ });
5073
+ };
5074
+
5075
+ /**
5076
+ * Gets or sets the current playback rate.
5077
+ * @param {Boolean} rate New playback rate to set.
5078
+ * @return {Number} Returns the new playback rate when setting
5079
+ * @return {Number} Returns the current playback rate when getting
5080
+ */
5081
+ vjs.Player.prototype.playbackRate = function(rate) {
5082
+ if (rate !== undefined) {
5083
+ this.techCall('setPlaybackRate', rate);
5084
+ return this;
5085
+ }
5086
+
5087
+ if (this.tech && this.tech['featuresPlaybackRate']) {
5088
+ return this.techGet('playbackRate');
5089
+ } else {
5090
+ return 1.0;
5091
+ }
5092
+
5093
+ };
5094
+
5095
+ /**
5096
+ * Store the current audio state
5097
+ * @type {Boolean}
5098
+ * @private
5099
+ */
5100
+ vjs.Player.prototype.isAudio_ = false;
5101
+
5102
+ /**
5103
+ * Gets or sets the audio flag
5104
+ *
5105
+ * @param {Boolean} bool True signals that this is an audio player.
5106
+ * @return {Boolean} Returns true if player is audio, false if not when getting
5107
+ * @return {vjs.Player} Returns the player if setting
5108
+ * @private
5109
+ */
5110
+ vjs.Player.prototype.isAudio = function(bool) {
5111
+ if (bool !== undefined) {
5112
+ this.isAudio_ = !!bool;
5113
+ return this;
5114
+ }
5115
+
5116
+ return this.isAudio_;
5117
+ };
5118
+
5119
+ // Methods to add support for
5120
+ // networkState: function(){ return this.techCall('networkState'); },
5121
+ // readyState: function(){ return this.techCall('readyState'); },
5122
+ // initialTime: function(){ return this.techCall('initialTime'); },
5123
+ // startOffsetTime: function(){ return this.techCall('startOffsetTime'); },
5124
+ // played: function(){ return this.techCall('played'); },
5125
+ // seekable: function(){ return this.techCall('seekable'); },
5126
+ // videoTracks: function(){ return this.techCall('videoTracks'); },
5127
+ // audioTracks: function(){ return this.techCall('audioTracks'); },
5128
+ // videoWidth: function(){ return this.techCall('videoWidth'); },
5129
+ // videoHeight: function(){ return this.techCall('videoHeight'); },
5130
+ // defaultPlaybackRate: function(){ return this.techCall('defaultPlaybackRate'); },
5131
+ // mediaGroup: function(){ return this.techCall('mediaGroup'); },
5132
+ // controller: function(){ return this.techCall('controller'); },
5133
+ // defaultMuted: function(){ return this.techCall('defaultMuted'); }
5134
+
5135
+ // TODO
5136
+ // currentSrcList: the array of sources including other formats and bitrates
5137
+ // playList: array of source lists in order of playback
5138
+ /**
5139
+ * Container of main controls
5140
+ * @param {vjs.Player|Object} player
5141
+ * @param {Object=} options
5142
+ * @class
5143
+ * @constructor
5144
+ * @extends vjs.Component
5145
+ */
5146
+ vjs.ControlBar = vjs.Component.extend();
5147
+
5148
+ vjs.ControlBar.prototype.options_ = {
5149
+ loadEvent: 'play',
5150
+ children: {
5151
+ 'playToggle': {},
5152
+ 'currentTimeDisplay': {},
5153
+ 'timeDivider': {},
5154
+ 'durationDisplay': {},
5155
+ 'remainingTimeDisplay': {},
5156
+ 'liveDisplay': {},
5157
+ 'progressControl': {},
5158
+ 'fullscreenToggle': {},
5159
+ 'volumeControl': {},
5160
+ 'muteToggle': {},
5161
+ // 'volumeMenuButton': {},
5162
+ 'playbackRateMenuButton': {}
5163
+ }
5164
+ };
5165
+
5166
+ vjs.ControlBar.prototype.createEl = function(){
5167
+ return vjs.createEl('div', {
5168
+ className: 'vjs-control-bar'
5169
+ });
5170
+ };
5171
+ /**
5172
+ * Displays the live indicator
5173
+ * TODO - Future make it click to snap to live
5174
+ * @param {vjs.Player|Object} player
5175
+ * @param {Object=} options
5176
+ * @constructor
5177
+ */
5178
+ vjs.LiveDisplay = vjs.Component.extend({
5179
+ init: function(player, options){
5180
+ vjs.Component.call(this, player, options);
5181
+ }
5182
+ });
5183
+
5184
+ vjs.LiveDisplay.prototype.createEl = function(){
5185
+ var el = vjs.Component.prototype.createEl.call(this, 'div', {
5186
+ className: 'vjs-live-controls vjs-control'
5187
+ });
5188
+
5189
+ this.contentEl_ = vjs.createEl('div', {
5190
+ className: 'vjs-live-display',
5191
+ innerHTML: '<span class="vjs-control-text">' + this.localize('Stream Type') + '</span>' + this.localize('LIVE'),
5192
+ 'aria-live': 'off'
5193
+ });
5194
+
5195
+ el.appendChild(this.contentEl_);
5196
+
5197
+ return el;
5198
+ };
5199
+ /**
5200
+ * Button to toggle between play and pause
5201
+ * @param {vjs.Player|Object} player
5202
+ * @param {Object=} options
5203
+ * @class
5204
+ * @constructor
5205
+ */
5206
+ vjs.PlayToggle = vjs.Button.extend({
5207
+ /** @constructor */
5208
+ init: function(player, options){
5209
+ vjs.Button.call(this, player, options);
5210
+
5211
+ this.on(player, 'play', this.onPlay);
5212
+ this.on(player, 'pause', this.onPause);
5213
+ }
5214
+ });
5215
+
5216
+ vjs.PlayToggle.prototype.buttonText = 'Play';
5217
+
5218
+ vjs.PlayToggle.prototype.buildCSSClass = function(){
5219
+ return 'vjs-play-control ' + vjs.Button.prototype.buildCSSClass.call(this);
5220
+ };
5221
+
5222
+ // OnClick - Toggle between play and pause
5223
+ vjs.PlayToggle.prototype.onClick = function(){
5224
+ if (this.player_.paused()) {
5225
+ this.player_.play();
5226
+ } else {
5227
+ this.player_.pause();
5228
+ }
5229
+ };
5230
+
5231
+ // OnPlay - Add the vjs-playing class to the element so it can change appearance
5232
+ vjs.PlayToggle.prototype.onPlay = function(){
5233
+ this.removeClass('vjs-paused');
5234
+ this.addClass('vjs-playing');
5235
+ this.el_.children[0].children[0].innerHTML = this.localize('Pause'); // change the button text to "Pause"
5236
+ };
5237
+
5238
+ // OnPause - Add the vjs-paused class to the element so it can change appearance
5239
+ vjs.PlayToggle.prototype.onPause = function(){
5240
+ this.removeClass('vjs-playing');
5241
+ this.addClass('vjs-paused');
5242
+ this.el_.children[0].children[0].innerHTML = this.localize('Play'); // change the button text to "Play"
5243
+ };
5244
+ /**
5245
+ * Displays the current time
5246
+ * @param {vjs.Player|Object} player
5247
+ * @param {Object=} options
5248
+ * @constructor
5249
+ */
5250
+ vjs.CurrentTimeDisplay = vjs.Component.extend({
5251
+ /** @constructor */
5252
+ init: function(player, options){
5253
+ vjs.Component.call(this, player, options);
5254
+
5255
+ this.on(player, 'timeupdate', this.updateContent);
5256
+ }
5257
+ });
5258
+
5259
+ vjs.CurrentTimeDisplay.prototype.createEl = function(){
5260
+ var el = vjs.Component.prototype.createEl.call(this, 'div', {
5261
+ className: 'vjs-current-time vjs-time-controls vjs-control'
5262
+ });
5263
+
5264
+ this.contentEl_ = vjs.createEl('div', {
5265
+ className: 'vjs-current-time-display',
5266
+ innerHTML: '<span class="vjs-control-text">Current Time </span>' + '0:00', // label the current time for screen reader users
5267
+ 'aria-live': 'off' // tell screen readers not to automatically read the time as it changes
5268
+ });
5269
+
5270
+ el.appendChild(this.contentEl_);
5271
+ return el;
5272
+ };
5273
+
5274
+ vjs.CurrentTimeDisplay.prototype.updateContent = function(){
5275
+ // Allows for smooth scrubbing, when player can't keep up.
5276
+ var time = (this.player_.scrubbing) ? this.player_.getCache().currentTime : this.player_.currentTime();
5277
+ this.contentEl_.innerHTML = '<span class="vjs-control-text">' + this.localize('Current Time') + '</span> ' + vjs.formatTime(time, this.player_.duration());
5278
+ };
5279
+
5280
+ /**
5281
+ * Displays the duration
5282
+ * @param {vjs.Player|Object} player
5283
+ * @param {Object=} options
5284
+ * @constructor
5285
+ */
5286
+ vjs.DurationDisplay = vjs.Component.extend({
5287
+ /** @constructor */
5288
+ init: function(player, options){
5289
+ vjs.Component.call(this, player, options);
5290
+
5291
+ // this might need to be changed to 'durationchange' instead of 'timeupdate' eventually,
5292
+ // however the durationchange event fires before this.player_.duration() is set,
5293
+ // so the value cannot be written out using this method.
5294
+ // Once the order of durationchange and this.player_.duration() being set is figured out,
5295
+ // this can be updated.
5296
+ this.on(player, 'timeupdate', this.updateContent);
5297
+ }
5298
+ });
5299
+
5300
+ vjs.DurationDisplay.prototype.createEl = function(){
5301
+ var el = vjs.Component.prototype.createEl.call(this, 'div', {
5302
+ className: 'vjs-duration vjs-time-controls vjs-control'
5303
+ });
5304
+
5305
+ this.contentEl_ = vjs.createEl('div', {
5306
+ className: 'vjs-duration-display',
5307
+ innerHTML: '<span class="vjs-control-text">' + this.localize('Duration Time') + '</span> ' + '0:00', // label the duration time for screen reader users
5308
+ 'aria-live': 'off' // tell screen readers not to automatically read the time as it changes
5309
+ });
5310
+
5311
+ el.appendChild(this.contentEl_);
5312
+ return el;
5313
+ };
5314
+
5315
+ vjs.DurationDisplay.prototype.updateContent = function(){
5316
+ var duration = this.player_.duration();
5317
+ if (duration) {
5318
+ this.contentEl_.innerHTML = '<span class="vjs-control-text">' + this.localize('Duration Time') + '</span> ' + vjs.formatTime(duration); // label the duration time for screen reader users
5319
+ }
5320
+ };
5321
+
5322
+ /**
5323
+ * The separator between the current time and duration
5324
+ *
5325
+ * Can be hidden if it's not needed in the design.
5326
+ *
5327
+ * @param {vjs.Player|Object} player
5328
+ * @param {Object=} options
5329
+ * @constructor
5330
+ */
5331
+ vjs.TimeDivider = vjs.Component.extend({
5332
+ /** @constructor */
5333
+ init: function(player, options){
5334
+ vjs.Component.call(this, player, options);
5335
+ }
5336
+ });
5337
+
5338
+ vjs.TimeDivider.prototype.createEl = function(){
5339
+ return vjs.Component.prototype.createEl.call(this, 'div', {
5340
+ className: 'vjs-time-divider',
5341
+ innerHTML: '<div><span>/</span></div>'
5342
+ });
5343
+ };
5344
+
5345
+ /**
5346
+ * Displays the time left in the video
5347
+ * @param {vjs.Player|Object} player
5348
+ * @param {Object=} options
5349
+ * @constructor
5350
+ */
5351
+ vjs.RemainingTimeDisplay = vjs.Component.extend({
5352
+ /** @constructor */
5353
+ init: function(player, options){
5354
+ vjs.Component.call(this, player, options);
5355
+
5356
+ this.on(player, 'timeupdate', this.updateContent);
5357
+ }
5358
+ });
5359
+
5360
+ vjs.RemainingTimeDisplay.prototype.createEl = function(){
5361
+ var el = vjs.Component.prototype.createEl.call(this, 'div', {
5362
+ className: 'vjs-remaining-time vjs-time-controls vjs-control'
5363
+ });
5364
+
5365
+ this.contentEl_ = vjs.createEl('div', {
5366
+ className: 'vjs-remaining-time-display',
5367
+ innerHTML: '<span class="vjs-control-text">' + this.localize('Remaining Time') + '</span> ' + '-0:00', // label the remaining time for screen reader users
5368
+ 'aria-live': 'off' // tell screen readers not to automatically read the time as it changes
5369
+ });
5370
+
5371
+ el.appendChild(this.contentEl_);
5372
+ return el;
5373
+ };
5374
+
5375
+ vjs.RemainingTimeDisplay.prototype.updateContent = function(){
5376
+ if (this.player_.duration()) {
5377
+ this.contentEl_.innerHTML = '<span class="vjs-control-text">' + this.localize('Remaining Time') + '</span> ' + '-'+ vjs.formatTime(this.player_.remainingTime());
5378
+ }
5379
+
5380
+ // Allows for smooth scrubbing, when player can't keep up.
5381
+ // var time = (this.player_.scrubbing) ? this.player_.getCache().currentTime : this.player_.currentTime();
5382
+ // this.contentEl_.innerHTML = vjs.formatTime(time, this.player_.duration());
5383
+ };
5384
+ /**
5385
+ * Toggle fullscreen video
5386
+ * @param {vjs.Player|Object} player
5387
+ * @param {Object=} options
5388
+ * @class
5389
+ * @extends vjs.Button
5390
+ */
5391
+ vjs.FullscreenToggle = vjs.Button.extend({
5392
+ /**
5393
+ * @constructor
5394
+ * @memberof vjs.FullscreenToggle
5395
+ * @instance
5396
+ */
5397
+ init: function(player, options){
5398
+ vjs.Button.call(this, player, options);
5399
+ }
5400
+ });
5401
+
5402
+ vjs.FullscreenToggle.prototype.buttonText = 'Fullscreen';
5403
+
5404
+ vjs.FullscreenToggle.prototype.buildCSSClass = function(){
5405
+ return 'vjs-fullscreen-control ' + vjs.Button.prototype.buildCSSClass.call(this);
5406
+ };
5407
+
5408
+ vjs.FullscreenToggle.prototype.onClick = function(){
5409
+ if (!this.player_.isFullscreen()) {
5410
+ this.player_.requestFullscreen();
5411
+ this.controlText_.innerHTML = this.localize('Non-Fullscreen');
5412
+ } else {
5413
+ this.player_.exitFullscreen();
5414
+ this.controlText_.innerHTML = this.localize('Fullscreen');
5415
+ }
5416
+ };
5417
+ /**
5418
+ * The Progress Control component contains the seek bar, load progress,
5419
+ * and play progress
5420
+ *
5421
+ * @param {vjs.Player|Object} player
5422
+ * @param {Object=} options
5423
+ * @constructor
5424
+ */
5425
+ vjs.ProgressControl = vjs.Component.extend({
5426
+ /** @constructor */
5427
+ init: function(player, options){
5428
+ vjs.Component.call(this, player, options);
5429
+ }
5430
+ });
5431
+
5432
+ vjs.ProgressControl.prototype.options_ = {
5433
+ children: {
5434
+ 'seekBar': {}
5435
+ }
5436
+ };
5437
+
5438
+ vjs.ProgressControl.prototype.createEl = function(){
5439
+ return vjs.Component.prototype.createEl.call(this, 'div', {
5440
+ className: 'vjs-progress-control vjs-control'
5441
+ });
5442
+ };
5443
+
5444
+ /**
5445
+ * Seek Bar and holder for the progress bars
5446
+ *
5447
+ * @param {vjs.Player|Object} player
5448
+ * @param {Object=} options
5449
+ * @constructor
5450
+ */
5451
+ vjs.SeekBar = vjs.Slider.extend({
5452
+ /** @constructor */
5453
+ init: function(player, options){
5454
+ vjs.Slider.call(this, player, options);
5455
+ this.on(player, 'timeupdate', this.updateARIAAttributes);
5456
+ player.ready(vjs.bind(this, this.updateARIAAttributes));
5457
+ }
5458
+ });
5459
+
5460
+ vjs.SeekBar.prototype.options_ = {
5461
+ children: {
5462
+ 'loadProgressBar': {},
5463
+ 'playProgressBar': {},
5464
+ 'seekHandle': {}
5465
+ },
5466
+ 'barName': 'playProgressBar',
5467
+ 'handleName': 'seekHandle'
5468
+ };
5469
+
5470
+ vjs.SeekBar.prototype.playerEvent = 'timeupdate';
5471
+
5472
+ vjs.SeekBar.prototype.createEl = function(){
5473
+ return vjs.Slider.prototype.createEl.call(this, 'div', {
5474
+ className: 'vjs-progress-holder',
5475
+ 'aria-label': 'video progress bar'
5476
+ });
5477
+ };
5478
+
5479
+ vjs.SeekBar.prototype.updateARIAAttributes = function(){
5480
+ // Allows for smooth scrubbing, when player can't keep up.
5481
+ var time = (this.player_.scrubbing) ? this.player_.getCache().currentTime : this.player_.currentTime();
5482
+ this.el_.setAttribute('aria-valuenow',vjs.round(this.getPercent()*100, 2)); // machine readable value of progress bar (percentage complete)
5483
+ this.el_.setAttribute('aria-valuetext',vjs.formatTime(time, this.player_.duration())); // human readable value of progress bar (time complete)
5484
+ };
5485
+
5486
+ vjs.SeekBar.prototype.getPercent = function(){
5487
+ return this.player_.currentTime() / this.player_.duration();
5488
+ };
5489
+
5490
+ vjs.SeekBar.prototype.onMouseDown = function(event){
5491
+ vjs.Slider.prototype.onMouseDown.call(this, event);
5492
+
5493
+ this.player_.scrubbing = true;
5494
+
5495
+ this.videoWasPlaying = !this.player_.paused();
5496
+ this.player_.pause();
5497
+ };
5498
+
5499
+ vjs.SeekBar.prototype.onMouseMove = function(event){
5500
+ var newTime = this.calculateDistance(event) * this.player_.duration();
5501
+
5502
+ // Don't let video end while scrubbing.
5503
+ if (newTime == this.player_.duration()) { newTime = newTime - 0.1; }
5504
+
5505
+ // Set new time (tell player to seek to new time)
5506
+ this.player_.currentTime(newTime);
5507
+ };
5508
+
5509
+ vjs.SeekBar.prototype.onMouseUp = function(event){
5510
+ vjs.Slider.prototype.onMouseUp.call(this, event);
5511
+
5512
+ this.player_.scrubbing = false;
5513
+ if (this.videoWasPlaying) {
5514
+ this.player_.play();
5515
+ }
5516
+ };
5517
+
5518
+ vjs.SeekBar.prototype.stepForward = function(){
5519
+ this.player_.currentTime(this.player_.currentTime() + 5); // more quickly fast forward for keyboard-only users
5520
+ };
5521
+
5522
+ vjs.SeekBar.prototype.stepBack = function(){
5523
+ this.player_.currentTime(this.player_.currentTime() - 5); // more quickly rewind for keyboard-only users
5524
+ };
5525
+
5526
+ /**
5527
+ * Shows load progress
5528
+ *
5529
+ * @param {vjs.Player|Object} player
5530
+ * @param {Object=} options
5531
+ * @constructor
5532
+ */
5533
+ vjs.LoadProgressBar = vjs.Component.extend({
5534
+ /** @constructor */
5535
+ init: function(player, options){
5536
+ vjs.Component.call(this, player, options);
5537
+ this.on(player, 'progress', this.update);
5538
+ }
5539
+ });
5540
+
5541
+ vjs.LoadProgressBar.prototype.createEl = function(){
5542
+ return vjs.Component.prototype.createEl.call(this, 'div', {
5543
+ className: 'vjs-load-progress',
5544
+ innerHTML: '<span class="vjs-control-text"><span>' + this.localize('Loaded') + '</span>: 0%</span>'
5545
+ });
5546
+ };
5547
+
5548
+ vjs.LoadProgressBar.prototype.update = function(){
5549
+ var i, start, end, part,
5550
+ buffered = this.player_.buffered(),
5551
+ duration = this.player_.duration(),
5552
+ bufferedEnd = this.player_.bufferedEnd(),
5553
+ children = this.el_.children,
5554
+ // get the percent width of a time compared to the total end
5555
+ percentify = function (time, end){
5556
+ var percent = (time / end) || 0; // no NaN
5557
+ return (percent * 100) + '%';
5558
+ };
5559
+
5560
+ // update the width of the progress bar
5561
+ this.el_.style.width = percentify(bufferedEnd, duration);
5562
+
5563
+ // add child elements to represent the individual buffered time ranges
5564
+ for (i = 0; i < buffered.length; i++) {
5565
+ start = buffered.start(i),
5566
+ end = buffered.end(i),
5567
+ part = children[i];
5568
+
5569
+ if (!part) {
5570
+ part = this.el_.appendChild(vjs.createEl())
5571
+ };
5572
+
5573
+ // set the percent based on the width of the progress bar (bufferedEnd)
5574
+ part.style.left = percentify(start, bufferedEnd);
5575
+ part.style.width = percentify(end - start, bufferedEnd);
5576
+ };
5577
+
5578
+ // remove unused buffered range elements
5579
+ for (i = children.length; i > buffered.length; i--) {
5580
+ this.el_.removeChild(children[i-1]);
5581
+ }
5582
+ };
5583
+
5584
+ /**
5585
+ * Shows play progress
5586
+ *
5587
+ * @param {vjs.Player|Object} player
5588
+ * @param {Object=} options
5589
+ * @constructor
5590
+ */
5591
+ vjs.PlayProgressBar = vjs.Component.extend({
5592
+ /** @constructor */
5593
+ init: function(player, options){
5594
+ vjs.Component.call(this, player, options);
5595
+ }
5596
+ });
5597
+
5598
+ vjs.PlayProgressBar.prototype.createEl = function(){
5599
+ return vjs.Component.prototype.createEl.call(this, 'div', {
5600
+ className: 'vjs-play-progress',
5601
+ innerHTML: '<span class="vjs-control-text"><span>' + this.localize('Progress') + '</span>: 0%</span>'
5602
+ });
5603
+ };
5604
+
5605
+ /**
5606
+ * The Seek Handle shows the current position of the playhead during playback,
5607
+ * and can be dragged to adjust the playhead.
5608
+ *
5609
+ * @param {vjs.Player|Object} player
5610
+ * @param {Object=} options
5611
+ * @constructor
5612
+ */
5613
+ vjs.SeekHandle = vjs.SliderHandle.extend({
5614
+ init: function(player, options) {
5615
+ vjs.SliderHandle.call(this, player, options);
5616
+ this.on(player, 'timeupdate', this.updateContent);
5617
+ }
5618
+ });
5619
+
5620
+ /**
5621
+ * The default value for the handle content, which may be read by screen readers
5622
+ *
5623
+ * @type {String}
5624
+ * @private
5625
+ */
5626
+ vjs.SeekHandle.prototype.defaultValue = '00:00';
5627
+
5628
+ /** @inheritDoc */
5629
+ vjs.SeekHandle.prototype.createEl = function() {
5630
+ return vjs.SliderHandle.prototype.createEl.call(this, 'div', {
5631
+ className: 'vjs-seek-handle',
5632
+ 'aria-live': 'off'
5633
+ });
5634
+ };
5635
+
5636
+ vjs.SeekHandle.prototype.updateContent = function() {
5637
+ var time = (this.player_.scrubbing) ? this.player_.getCache().currentTime : this.player_.currentTime();
5638
+ this.el_.innerHTML = '<span class="vjs-control-text">' + vjs.formatTime(time, this.player_.duration()) + '</span>';
5639
+ };
5640
+ /**
5641
+ * The component for controlling the volume level
5642
+ *
5643
+ * @param {vjs.Player|Object} player
5644
+ * @param {Object=} options
5645
+ * @constructor
5646
+ */
5647
+ vjs.VolumeControl = vjs.Component.extend({
5648
+ /** @constructor */
5649
+ init: function(player, options){
5650
+ vjs.Component.call(this, player, options);
5651
+
5652
+ // hide volume controls when they're not supported by the current tech
5653
+ if (player.tech && player.tech['featuresVolumeControl'] === false) {
5654
+ this.addClass('vjs-hidden');
5655
+ }
5656
+ this.on(player, 'loadstart', function(){
5657
+ if (player.tech['featuresVolumeControl'] === false) {
5658
+ this.addClass('vjs-hidden');
5659
+ } else {
5660
+ this.removeClass('vjs-hidden');
5661
+ }
5662
+ });
5663
+ }
5664
+ });
5665
+
5666
+ vjs.VolumeControl.prototype.options_ = {
5667
+ children: {
5668
+ 'volumeBar': {}
5669
+ }
5670
+ };
5671
+
5672
+ vjs.VolumeControl.prototype.createEl = function(){
5673
+ return vjs.Component.prototype.createEl.call(this, 'div', {
5674
+ className: 'vjs-volume-control vjs-control'
5675
+ });
5676
+ };
5677
+
5678
+ /**
5679
+ * The bar that contains the volume level and can be clicked on to adjust the level
5680
+ *
5681
+ * @param {vjs.Player|Object} player
5682
+ * @param {Object=} options
5683
+ * @constructor
5684
+ */
5685
+ vjs.VolumeBar = vjs.Slider.extend({
5686
+ /** @constructor */
5687
+ init: function(player, options){
5688
+ vjs.Slider.call(this, player, options);
5689
+ this.on(player, 'volumechange', this.updateARIAAttributes);
5690
+ player.ready(vjs.bind(this, this.updateARIAAttributes));
5691
+ }
5692
+ });
5693
+
5694
+ vjs.VolumeBar.prototype.updateARIAAttributes = function(){
5695
+ // Current value of volume bar as a percentage
5696
+ this.el_.setAttribute('aria-valuenow',vjs.round(this.player_.volume()*100, 2));
5697
+ this.el_.setAttribute('aria-valuetext',vjs.round(this.player_.volume()*100, 2)+'%');
5698
+ };
5699
+
5700
+ vjs.VolumeBar.prototype.options_ = {
5701
+ children: {
5702
+ 'volumeLevel': {},
5703
+ 'volumeHandle': {}
5704
+ },
5705
+ 'barName': 'volumeLevel',
5706
+ 'handleName': 'volumeHandle'
5707
+ };
5708
+
5709
+ vjs.VolumeBar.prototype.playerEvent = 'volumechange';
5710
+
5711
+ vjs.VolumeBar.prototype.createEl = function(){
5712
+ return vjs.Slider.prototype.createEl.call(this, 'div', {
5713
+ className: 'vjs-volume-bar',
5714
+ 'aria-label': 'volume level'
5715
+ });
5716
+ };
5717
+
5718
+ vjs.VolumeBar.prototype.onMouseMove = function(event) {
5719
+ if (this.player_.muted()) {
5720
+ this.player_.muted(false);
5721
+ }
5722
+
5723
+ this.player_.volume(this.calculateDistance(event));
5724
+ };
5725
+
5726
+ vjs.VolumeBar.prototype.getPercent = function(){
5727
+ if (this.player_.muted()) {
5728
+ return 0;
5729
+ } else {
5730
+ return this.player_.volume();
5731
+ }
5732
+ };
5733
+
5734
+ vjs.VolumeBar.prototype.stepForward = function(){
5735
+ this.player_.volume(this.player_.volume() + 0.1);
5736
+ };
5737
+
5738
+ vjs.VolumeBar.prototype.stepBack = function(){
5739
+ this.player_.volume(this.player_.volume() - 0.1);
5740
+ };
5741
+
5742
+ /**
5743
+ * Shows volume level
5744
+ *
5745
+ * @param {vjs.Player|Object} player
5746
+ * @param {Object=} options
5747
+ * @constructor
5748
+ */
5749
+ vjs.VolumeLevel = vjs.Component.extend({
5750
+ /** @constructor */
5751
+ init: function(player, options){
5752
+ vjs.Component.call(this, player, options);
5753
+ }
5754
+ });
5755
+
5756
+ vjs.VolumeLevel.prototype.createEl = function(){
5757
+ return vjs.Component.prototype.createEl.call(this, 'div', {
5758
+ className: 'vjs-volume-level',
5759
+ innerHTML: '<span class="vjs-control-text"></span>'
5760
+ });
5761
+ };
5762
+
5763
+ /**
5764
+ * The volume handle can be dragged to adjust the volume level
5765
+ *
5766
+ * @param {vjs.Player|Object} player
5767
+ * @param {Object=} options
5768
+ * @constructor
5769
+ */
5770
+ vjs.VolumeHandle = vjs.SliderHandle.extend();
5771
+
5772
+ vjs.VolumeHandle.prototype.defaultValue = '00:00';
5773
+
5774
+ /** @inheritDoc */
5775
+ vjs.VolumeHandle.prototype.createEl = function(){
5776
+ return vjs.SliderHandle.prototype.createEl.call(this, 'div', {
5777
+ className: 'vjs-volume-handle'
5778
+ });
5779
+ };
5780
+ /**
5781
+ * A button component for muting the audio
5782
+ *
5783
+ * @param {vjs.Player|Object} player
5784
+ * @param {Object=} options
5785
+ * @constructor
5786
+ */
5787
+ vjs.MuteToggle = vjs.Button.extend({
5788
+ /** @constructor */
5789
+ init: function(player, options){
5790
+ vjs.Button.call(this, player, options);
5791
+
5792
+ this.on(player, 'volumechange', this.update);
5793
+
5794
+ // hide mute toggle if the current tech doesn't support volume control
5795
+ if (player.tech && player.tech['featuresVolumeControl'] === false) {
5796
+ this.addClass('vjs-hidden');
5797
+ }
5798
+
5799
+ this.on(player, 'loadstart', function(){
5800
+ if (player.tech['featuresVolumeControl'] === false) {
5801
+ this.addClass('vjs-hidden');
5802
+ } else {
5803
+ this.removeClass('vjs-hidden');
5804
+ }
5805
+ });
5806
+ }
5807
+ });
5808
+
5809
+ vjs.MuteToggle.prototype.createEl = function(){
5810
+ return vjs.Button.prototype.createEl.call(this, 'div', {
5811
+ className: 'vjs-mute-control vjs-control',
5812
+ innerHTML: '<div><span class="vjs-control-text">' + this.localize('Mute') + '</span></div>'
5813
+ });
5814
+ };
5815
+
5816
+ vjs.MuteToggle.prototype.onClick = function(){
5817
+ this.player_.muted( this.player_.muted() ? false : true );
5818
+ };
5819
+
5820
+ vjs.MuteToggle.prototype.update = function(){
5821
+ var vol = this.player_.volume(),
5822
+ level = 3;
5823
+
5824
+ if (vol === 0 || this.player_.muted()) {
5825
+ level = 0;
5826
+ } else if (vol < 0.33) {
5827
+ level = 1;
5828
+ } else if (vol < 0.67) {
5829
+ level = 2;
5830
+ }
5831
+
5832
+ // Don't rewrite the button text if the actual text doesn't change.
5833
+ // This causes unnecessary and confusing information for screen reader users.
5834
+ // This check is needed because this function gets called every time the volume level is changed.
5835
+ if(this.player_.muted()){
5836
+ if(this.el_.children[0].children[0].innerHTML!=this.localize('Unmute')){
5837
+ this.el_.children[0].children[0].innerHTML = this.localize('Unmute'); // change the button text to "Unmute"
5838
+ }
5839
+ } else {
5840
+ if(this.el_.children[0].children[0].innerHTML!=this.localize('Mute')){
5841
+ this.el_.children[0].children[0].innerHTML = this.localize('Mute'); // change the button text to "Mute"
5842
+ }
5843
+ }
5844
+
5845
+ /* TODO improve muted icon classes */
5846
+ for (var i = 0; i < 4; i++) {
5847
+ vjs.removeClass(this.el_, 'vjs-vol-'+i);
5848
+ }
5849
+ vjs.addClass(this.el_, 'vjs-vol-'+level);
5850
+ };
5851
+ /**
5852
+ * Menu button with a popup for showing the volume slider.
5853
+ * @constructor
5854
+ */
5855
+ vjs.VolumeMenuButton = vjs.MenuButton.extend({
5856
+ /** @constructor */
5857
+ init: function(player, options){
5858
+ vjs.MenuButton.call(this, player, options);
5859
+
5860
+ // Same listeners as MuteToggle
5861
+ this.on(player, 'volumechange', this.update);
5862
+
5863
+ // hide mute toggle if the current tech doesn't support volume control
5864
+ if (player.tech && player.tech['featuresVolumeControl'] === false) {
5865
+ this.addClass('vjs-hidden');
5866
+ }
5867
+ this.on(player, 'loadstart', function(){
5868
+ if (player.tech['featuresVolumeControl'] === false) {
5869
+ this.addClass('vjs-hidden');
5870
+ } else {
5871
+ this.removeClass('vjs-hidden');
5872
+ }
5873
+ });
5874
+ this.addClass('vjs-menu-button');
5875
+ }
5876
+ });
5877
+
5878
+ vjs.VolumeMenuButton.prototype.createMenu = function(){
5879
+ var menu = new vjs.Menu(this.player_, {
5880
+ contentElType: 'div'
5881
+ });
5882
+ var vc = new vjs.VolumeBar(this.player_, this.options_['volumeBar']);
5883
+ vc.on('focus', function() {
5884
+ menu.lockShowing();
5885
+ });
5886
+ vc.on('blur', function() {
5887
+ menu.unlockShowing();
5888
+ });
5889
+ menu.addChild(vc);
5890
+ return menu;
5891
+ };
5892
+
5893
+ vjs.VolumeMenuButton.prototype.onClick = function(){
5894
+ vjs.MuteToggle.prototype.onClick.call(this);
5895
+ vjs.MenuButton.prototype.onClick.call(this);
5896
+ };
5897
+
5898
+ vjs.VolumeMenuButton.prototype.createEl = function(){
5899
+ return vjs.Button.prototype.createEl.call(this, 'div', {
5900
+ className: 'vjs-volume-menu-button vjs-menu-button vjs-control',
5901
+ innerHTML: '<div><span class="vjs-control-text">' + this.localize('Mute') + '</span></div>'
5902
+ });
5903
+ };
5904
+ vjs.VolumeMenuButton.prototype.update = vjs.MuteToggle.prototype.update;
5905
+ /**
5906
+ * The component for controlling the playback rate
5907
+ *
5908
+ * @param {vjs.Player|Object} player
5909
+ * @param {Object=} options
5910
+ * @constructor
5911
+ */
5912
+ vjs.PlaybackRateMenuButton = vjs.MenuButton.extend({
5913
+ /** @constructor */
5914
+ init: function(player, options){
5915
+ vjs.MenuButton.call(this, player, options);
5916
+
5917
+ this.updateVisibility();
5918
+ this.updateLabel();
5919
+
5920
+ this.on(player, 'loadstart', this.updateVisibility);
5921
+ this.on(player, 'ratechange', this.updateLabel);
5922
+ }
5923
+ });
5924
+
5925
+ vjs.PlaybackRateMenuButton.prototype.createEl = function(){
5926
+ var el = vjs.Component.prototype.createEl.call(this, 'div', {
5927
+ className: 'vjs-playback-rate vjs-menu-button vjs-control',
5928
+ innerHTML: '<div class="vjs-control-content"><span class="vjs-control-text">' + this.localize('Playback Rate') + '</span></div>'
5929
+ });
5930
+
5931
+ this.labelEl_ = vjs.createEl('div', {
5932
+ className: 'vjs-playback-rate-value',
5933
+ innerHTML: 1.0
5934
+ });
5935
+
5936
+ el.appendChild(this.labelEl_);
5937
+
5938
+ return el;
5939
+ };
5940
+
5941
+ // Menu creation
5942
+ vjs.PlaybackRateMenuButton.prototype.createMenu = function(){
5943
+ var menu = new vjs.Menu(this.player());
5944
+ var rates = this.player().options()['playbackRates'];
5945
+
5946
+ if (rates) {
5947
+ for (var i = rates.length - 1; i >= 0; i--) {
5948
+ menu.addChild(
5949
+ new vjs.PlaybackRateMenuItem(this.player(), { 'rate': rates[i] + 'x'})
5950
+ );
5951
+ };
5952
+ }
5953
+
5954
+ return menu;
5955
+ };
5956
+
5957
+ vjs.PlaybackRateMenuButton.prototype.updateARIAAttributes = function(){
5958
+ // Current playback rate
5959
+ this.el().setAttribute('aria-valuenow', this.player().playbackRate());
5960
+ };
5961
+
5962
+ vjs.PlaybackRateMenuButton.prototype.onClick = function(){
5963
+ // select next rate option
5964
+ var currentRate = this.player().playbackRate();
5965
+ var rates = this.player().options()['playbackRates'];
5966
+ // this will select first one if the last one currently selected
5967
+ var newRate = rates[0];
5968
+ for (var i = 0; i <rates.length ; i++) {
5969
+ if (rates[i] > currentRate) {
5970
+ newRate = rates[i];
5971
+ break;
5972
+ }
5973
+ };
5974
+ this.player().playbackRate(newRate);
5975
+ };
5976
+
5977
+ vjs.PlaybackRateMenuButton.prototype.playbackRateSupported = function(){
5978
+ return this.player().tech
5979
+ && this.player().tech['featuresPlaybackRate']
5980
+ && this.player().options()['playbackRates']
5981
+ && this.player().options()['playbackRates'].length > 0
5982
+ ;
5983
+ };
5984
+
5985
+ /**
5986
+ * Hide playback rate controls when they're no playback rate options to select
5987
+ */
5988
+ vjs.PlaybackRateMenuButton.prototype.updateVisibility = function(){
5989
+ if (this.playbackRateSupported()) {
5990
+ this.removeClass('vjs-hidden');
5991
+ } else {
5992
+ this.addClass('vjs-hidden');
5993
+ }
5994
+ };
5995
+
5996
+ /**
5997
+ * Update button label when rate changed
5998
+ */
5999
+ vjs.PlaybackRateMenuButton.prototype.updateLabel = function(){
6000
+ if (this.playbackRateSupported()) {
6001
+ this.labelEl_.innerHTML = this.player().playbackRate() + 'x';
6002
+ }
6003
+ };
6004
+
6005
+ /**
6006
+ * The specific menu item type for selecting a playback rate
6007
+ *
6008
+ * @constructor
6009
+ */
6010
+ vjs.PlaybackRateMenuItem = vjs.MenuItem.extend({
6011
+ contentElType: 'button',
6012
+ /** @constructor */
6013
+ init: function(player, options){
6014
+ var label = this.label = options['rate'];
6015
+ var rate = this.rate = parseFloat(label, 10);
6016
+
6017
+ // Modify options for parent MenuItem class's init.
6018
+ options['label'] = label;
6019
+ options['selected'] = rate === 1;
6020
+ vjs.MenuItem.call(this, player, options);
6021
+
6022
+ this.on(player, 'ratechange', this.update);
6023
+ }
6024
+ });
6025
+
6026
+ vjs.PlaybackRateMenuItem.prototype.onClick = function(){
6027
+ vjs.MenuItem.prototype.onClick.call(this);
6028
+ this.player().playbackRate(this.rate);
6029
+ };
6030
+
6031
+ vjs.PlaybackRateMenuItem.prototype.update = function(){
6032
+ this.selected(this.player().playbackRate() == this.rate);
6033
+ };
6034
+ /* Poster Image
6035
+ ================================================================================ */
6036
+ /**
6037
+ * The component that handles showing the poster image.
6038
+ *
6039
+ * @param {vjs.Player|Object} player
6040
+ * @param {Object=} options
6041
+ * @constructor
6042
+ */
6043
+ vjs.PosterImage = vjs.Button.extend({
6044
+ /** @constructor */
6045
+ init: function(player, options){
6046
+ vjs.Button.call(this, player, options);
6047
+
6048
+ this.update();
6049
+ player.on('posterchange', vjs.bind(this, this.update));
6050
+ }
6051
+ });
6052
+
6053
+ /**
6054
+ * Clean up the poster image
6055
+ */
6056
+ vjs.PosterImage.prototype.dispose = function(){
6057
+ this.player().off('posterchange', this.update);
6058
+ vjs.Button.prototype.dispose.call(this);
6059
+ };
6060
+
6061
+ /**
6062
+ * Create the poster image element
6063
+ * @return {Element}
6064
+ */
6065
+ vjs.PosterImage.prototype.createEl = function(){
6066
+ var el = vjs.createEl('div', {
6067
+ className: 'vjs-poster',
6068
+
6069
+ // Don't want poster to be tabbable.
6070
+ tabIndex: -1
6071
+ });
6072
+
6073
+ // To ensure the poster image resizes while maintaining its original aspect
6074
+ // ratio, use a div with `background-size` when available. For browsers that
6075
+ // do not support `background-size` (e.g. IE8), fall back on using a regular
6076
+ // img element.
6077
+ if (!vjs.BACKGROUND_SIZE_SUPPORTED) {
6078
+ this.fallbackImg_ = vjs.createEl('img');
6079
+ el.appendChild(this.fallbackImg_);
6080
+ }
6081
+
6082
+ return el;
6083
+ };
6084
+
6085
+ /**
6086
+ * Event handler for updates to the player's poster source
6087
+ */
6088
+ vjs.PosterImage.prototype.update = function(){
6089
+ var url = this.player().poster();
6090
+
6091
+ this.setSrc(url);
6092
+
6093
+ // If there's no poster source we should display:none on this component
6094
+ // so it's not still clickable or right-clickable
6095
+ if (url) {
6096
+ // Remove the display style property that hide() adds
6097
+ // as opposed to show() which sets display to block
6098
+ // In the future it might be worth creating an `unhide` component method
6099
+ this.el_.style.display = '';
6100
+ } else {
6101
+ this.hide();
6102
+ }
6103
+ };
6104
+
6105
+ /**
6106
+ * Set the poster source depending on the display method
6107
+ */
6108
+ vjs.PosterImage.prototype.setSrc = function(url){
6109
+ var backgroundImage;
6110
+
6111
+ if (this.fallbackImg_) {
6112
+ this.fallbackImg_.src = url;
6113
+ } else {
6114
+ backgroundImage = '';
6115
+ // Any falsey values should stay as an empty string, otherwise
6116
+ // this will throw an extra error
6117
+ if (url) {
6118
+ backgroundImage = 'url("' + url + '")';
6119
+ }
6120
+
6121
+ this.el_.style.backgroundImage = backgroundImage;
6122
+ }
6123
+ };
6124
+
6125
+ /**
6126
+ * Event handler for clicks on the poster image
6127
+ */
6128
+ vjs.PosterImage.prototype.onClick = function(){
6129
+ // We don't want a click to trigger playback when controls are disabled
6130
+ // but CSS should be hiding the poster to prevent that from happening
6131
+ this.player_.play();
6132
+ };
6133
+ /* Loading Spinner
6134
+ ================================================================================ */
6135
+ /**
6136
+ * Loading spinner for waiting events
6137
+ * @param {vjs.Player|Object} player
6138
+ * @param {Object=} options
6139
+ * @class
6140
+ * @constructor
6141
+ */
6142
+ vjs.LoadingSpinner = vjs.Component.extend({
6143
+ /** @constructor */
6144
+ init: function(player, options){
6145
+ vjs.Component.call(this, player, options);
6146
+
6147
+ // MOVING DISPLAY HANDLING TO CSS
6148
+
6149
+ // player.on('canplay', vjs.bind(this, this.hide));
6150
+ // player.on('canplaythrough', vjs.bind(this, this.hide));
6151
+ // player.on('playing', vjs.bind(this, this.hide));
6152
+ // player.on('seeking', vjs.bind(this, this.show));
6153
+
6154
+ // in some browsers seeking does not trigger the 'playing' event,
6155
+ // so we also need to trap 'seeked' if we are going to set a
6156
+ // 'seeking' event
6157
+ // player.on('seeked', vjs.bind(this, this.hide));
6158
+
6159
+ // player.on('ended', vjs.bind(this, this.hide));
6160
+
6161
+ // Not showing spinner on stalled any more. Browsers may stall and then not trigger any events that would remove the spinner.
6162
+ // Checked in Chrome 16 and Safari 5.1.2. http://help.videojs.com/discussions/problems/883-why-is-the-download-progress-showing
6163
+ // player.on('stalled', vjs.bind(this, this.show));
6164
+
6165
+ // player.on('waiting', vjs.bind(this, this.show));
6166
+ }
6167
+ });
6168
+
6169
+ vjs.LoadingSpinner.prototype.createEl = function(){
6170
+ return vjs.Component.prototype.createEl.call(this, 'div', {
6171
+ className: 'vjs-loading-spinner'
6172
+ });
6173
+ };
6174
+ /* Big Play Button
6175
+ ================================================================================ */
6176
+ /**
6177
+ * Initial play button. Shows before the video has played. The hiding of the
6178
+ * big play button is done via CSS and player states.
6179
+ * @param {vjs.Player|Object} player
6180
+ * @param {Object=} options
6181
+ * @class
6182
+ * @constructor
6183
+ */
6184
+ vjs.BigPlayButton = vjs.Button.extend();
6185
+
6186
+ vjs.BigPlayButton.prototype.createEl = function(){
6187
+ return vjs.Button.prototype.createEl.call(this, 'div', {
6188
+ className: 'vjs-big-play-button',
6189
+ innerHTML: '<span aria-hidden="true"></span>',
6190
+ 'aria-label': 'play video'
6191
+ });
6192
+ };
6193
+
6194
+ vjs.BigPlayButton.prototype.onClick = function(){
6195
+ this.player_.play();
6196
+ };
6197
+ /**
6198
+ * Display that an error has occurred making the video unplayable
6199
+ * @param {vjs.Player|Object} player
6200
+ * @param {Object=} options
6201
+ * @constructor
6202
+ */
6203
+ vjs.ErrorDisplay = vjs.Component.extend({
6204
+ init: function(player, options){
6205
+ vjs.Component.call(this, player, options);
6206
+
6207
+ this.update();
6208
+ this.on(player, 'error', this.update);
6209
+ }
6210
+ });
6211
+
6212
+ vjs.ErrorDisplay.prototype.createEl = function(){
6213
+ var el = vjs.Component.prototype.createEl.call(this, 'div', {
6214
+ className: 'vjs-error-display'
6215
+ });
6216
+
6217
+ this.contentEl_ = vjs.createEl('div');
6218
+ el.appendChild(this.contentEl_);
6219
+
6220
+ return el;
6221
+ };
6222
+
6223
+ vjs.ErrorDisplay.prototype.update = function(){
6224
+ if (this.player().error()) {
6225
+ this.contentEl_.innerHTML = this.localize(this.player().error().message);
6226
+ }
6227
+ };
6228
+ /**
6229
+ * @fileoverview Media Technology Controller - Base class for media playback
6230
+ * technology controllers like Flash and HTML5
6231
+ */
6232
+
6233
+ /**
6234
+ * Base class for media (HTML5 Video, Flash) controllers
6235
+ * @param {vjs.Player|Object} player Central player instance
6236
+ * @param {Object=} options Options object
6237
+ * @constructor
6238
+ */
6239
+ vjs.MediaTechController = vjs.Component.extend({
6240
+ /** @constructor */
6241
+ init: function(player, options, ready){
6242
+ options = options || {};
6243
+ // we don't want the tech to report user activity automatically.
6244
+ // This is done manually in addControlsListeners
6245
+ options.reportTouchActivity = false;
6246
+ vjs.Component.call(this, player, options, ready);
6247
+
6248
+ // Manually track progress in cases where the browser/flash player doesn't report it.
6249
+ if (!this['featuresProgressEvents']) {
6250
+ this.manualProgressOn();
6251
+ }
6252
+
6253
+ // Manually track timeudpates in cases where the browser/flash player doesn't report it.
6254
+ if (!this['featuresTimeupdateEvents']) {
6255
+ this.manualTimeUpdatesOn();
6256
+ }
6257
+
6258
+ this.initControlsListeners();
6259
+ }
6260
+ });
6261
+
6262
+ /**
6263
+ * Set up click and touch listeners for the playback element
6264
+ * On desktops, a click on the video itself will toggle playback,
6265
+ * on a mobile device a click on the video toggles controls.
6266
+ * (toggling controls is done by toggling the user state between active and
6267
+ * inactive)
6268
+ *
6269
+ * A tap can signal that a user has become active, or has become inactive
6270
+ * e.g. a quick tap on an iPhone movie should reveal the controls. Another
6271
+ * quick tap should hide them again (signaling the user is in an inactive
6272
+ * viewing state)
6273
+ *
6274
+ * In addition to this, we still want the user to be considered inactive after
6275
+ * a few seconds of inactivity.
6276
+ *
6277
+ * Note: the only part of iOS interaction we can't mimic with this setup
6278
+ * is a touch and hold on the video element counting as activity in order to
6279
+ * keep the controls showing, but that shouldn't be an issue. A touch and hold on
6280
+ * any controls will still keep the user active
6281
+ */
6282
+ vjs.MediaTechController.prototype.initControlsListeners = function(){
6283
+ var player, activateControls;
6284
+
6285
+ player = this.player();
6286
+
6287
+ activateControls = function(){
6288
+ if (player.controls() && !player.usingNativeControls()) {
6289
+ this.addControlsListeners();
6290
+ }
6291
+ };
6292
+
6293
+ // Set up event listeners once the tech is ready and has an element to apply
6294
+ // listeners to
6295
+ this.ready(activateControls);
6296
+ this.on(player, 'controlsenabled', activateControls);
6297
+ this.on(player, 'controlsdisabled', this.removeControlsListeners);
6298
+
6299
+ // if we're loading the playback object after it has started loading or playing the
6300
+ // video (often with autoplay on) then the loadstart event has already fired and we
6301
+ // need to fire it manually because many things rely on it.
6302
+ // Long term we might consider how we would do this for other events like 'canplay'
6303
+ // that may also have fired.
6304
+ this.ready(function(){
6305
+ if (this.networkState && this.networkState() > 0) {
6306
+ this.player().trigger('loadstart');
6307
+ }
6308
+ });
6309
+ };
6310
+
6311
+ vjs.MediaTechController.prototype.addControlsListeners = function(){
6312
+ var userWasActive;
6313
+
6314
+ // Some browsers (Chrome & IE) don't trigger a click on a flash swf, but do
6315
+ // trigger mousedown/up.
6316
+ // http://stackoverflow.com/questions/1444562/javascript-onclick-event-over-flash-object
6317
+ // Any touch events are set to block the mousedown event from happening
6318
+ this.on('mousedown', this.onClick);
6319
+
6320
+ // If the controls were hidden we don't want that to change without a tap event
6321
+ // so we'll check if the controls were already showing before reporting user
6322
+ // activity
6323
+ this.on('touchstart', function(event) {
6324
+ userWasActive = this.player_.userActive();
6325
+ });
6326
+
6327
+ this.on('touchmove', function(event) {
6328
+ if (userWasActive){
6329
+ this.player().reportUserActivity();
6330
+ }
6331
+ });
6332
+
6333
+ this.on('touchend', function(event) {
6334
+ // Stop the mouse events from also happening
6335
+ event.preventDefault();
6336
+ });
6337
+
6338
+ // Turn on component tap events
6339
+ this.emitTapEvents();
6340
+
6341
+ // The tap listener needs to come after the touchend listener because the tap
6342
+ // listener cancels out any reportedUserActivity when setting userActive(false)
6343
+ this.on('tap', this.onTap);
6344
+ };
6345
+
6346
+ /**
6347
+ * Remove the listeners used for click and tap controls. This is needed for
6348
+ * toggling to controls disabled, where a tap/touch should do nothing.
6349
+ */
6350
+ vjs.MediaTechController.prototype.removeControlsListeners = function(){
6351
+ // We don't want to just use `this.off()` because there might be other needed
6352
+ // listeners added by techs that extend this.
6353
+ this.off('tap');
6354
+ this.off('touchstart');
6355
+ this.off('touchmove');
6356
+ this.off('touchleave');
6357
+ this.off('touchcancel');
6358
+ this.off('touchend');
6359
+ this.off('click');
6360
+ this.off('mousedown');
6361
+ };
6362
+
6363
+ /**
6364
+ * Handle a click on the media element. By default will play/pause the media.
6365
+ */
6366
+ vjs.MediaTechController.prototype.onClick = function(event){
6367
+ // We're using mousedown to detect clicks thanks to Flash, but mousedown
6368
+ // will also be triggered with right-clicks, so we need to prevent that
6369
+ if (event.button !== 0) return;
6370
+
6371
+ // When controls are disabled a click should not toggle playback because
6372
+ // the click is considered a control
6373
+ if (this.player().controls()) {
6374
+ if (this.player().paused()) {
6375
+ this.player().play();
6376
+ } else {
6377
+ this.player().pause();
6378
+ }
6379
+ }
6380
+ };
6381
+
6382
+ /**
6383
+ * Handle a tap on the media element. By default it will toggle the user
6384
+ * activity state, which hides and shows the controls.
6385
+ */
6386
+ vjs.MediaTechController.prototype.onTap = function(){
6387
+ this.player().userActive(!this.player().userActive());
6388
+ };
6389
+
6390
+ /* Fallbacks for unsupported event types
6391
+ ================================================================================ */
6392
+ // Manually trigger progress events based on changes to the buffered amount
6393
+ // Many flash players and older HTML5 browsers don't send progress or progress-like events
6394
+ vjs.MediaTechController.prototype.manualProgressOn = function(){
6395
+ this.manualProgress = true;
6396
+
6397
+ // Trigger progress watching when a source begins loading
6398
+ this.trackProgress();
6399
+ };
6400
+
6401
+ vjs.MediaTechController.prototype.manualProgressOff = function(){
6402
+ this.manualProgress = false;
6403
+ this.stopTrackingProgress();
6404
+ };
6405
+
6406
+ vjs.MediaTechController.prototype.trackProgress = function(){
6407
+
6408
+ this.progressInterval = setInterval(vjs.bind(this, function(){
6409
+ // Don't trigger unless buffered amount is greater than last time
6410
+
6411
+ var bufferedPercent = this.player().bufferedPercent();
6412
+
6413
+ if (this.bufferedPercent_ != bufferedPercent) {
6414
+ this.player().trigger('progress');
6415
+ }
6416
+
6417
+ this.bufferedPercent_ = bufferedPercent;
6418
+
6419
+ if (bufferedPercent === 1) {
6420
+ this.stopTrackingProgress();
6421
+ }
6422
+ }), 500);
6423
+ };
6424
+ vjs.MediaTechController.prototype.stopTrackingProgress = function(){ clearInterval(this.progressInterval); };
6425
+
6426
+ /*! Time Tracking -------------------------------------------------------------- */
6427
+ vjs.MediaTechController.prototype.manualTimeUpdatesOn = function(){
6428
+ var player = this.player_;
6429
+
6430
+ this.manualTimeUpdates = true;
6431
+
6432
+ this.on(player, 'play', this.trackCurrentTime);
6433
+ this.on(player, 'pause', this.stopTrackingCurrentTime);
6434
+ // timeupdate is also called by .currentTime whenever current time is set
6435
+
6436
+ // Watch for native timeupdate event
6437
+ this.one('timeupdate', function(){
6438
+ // Update known progress support for this playback technology
6439
+ this['featuresTimeupdateEvents'] = true;
6440
+ // Turn off manual progress tracking
6441
+ this.manualTimeUpdatesOff();
6442
+ });
6443
+ };
6444
+
6445
+ vjs.MediaTechController.prototype.manualTimeUpdatesOff = function(){
6446
+ this.manualTimeUpdates = false;
6447
+ this.stopTrackingCurrentTime();
6448
+ this.off('play', this.trackCurrentTime);
6449
+ this.off('pause', this.stopTrackingCurrentTime);
6450
+ };
6451
+
6452
+ vjs.MediaTechController.prototype.trackCurrentTime = function(){
6453
+ if (this.currentTimeInterval) { this.stopTrackingCurrentTime(); }
6454
+ this.currentTimeInterval = setInterval(vjs.bind(this, function(){
6455
+ this.player().trigger('timeupdate');
6456
+ }), 250); // 42 = 24 fps // 250 is what Webkit uses // FF uses 15
6457
+ };
6458
+
6459
+ // Turn off play progress tracking (when paused or dragging)
6460
+ vjs.MediaTechController.prototype.stopTrackingCurrentTime = function(){
6461
+ clearInterval(this.currentTimeInterval);
6462
+
6463
+ // #1002 - if the video ends right before the next timeupdate would happen,
6464
+ // the progress bar won't make it all the way to the end
6465
+ this.player().trigger('timeupdate');
6466
+ };
6467
+
6468
+ vjs.MediaTechController.prototype.dispose = function() {
6469
+ // Turn off any manual progress or timeupdate tracking
6470
+ if (this.manualProgress) { this.manualProgressOff(); }
6471
+
6472
+ if (this.manualTimeUpdates) { this.manualTimeUpdatesOff(); }
6473
+
6474
+ vjs.Component.prototype.dispose.call(this);
6475
+ };
6476
+
6477
+ vjs.MediaTechController.prototype.setCurrentTime = function() {
6478
+ // improve the accuracy of manual timeupdates
6479
+ if (this.manualTimeUpdates) { this.player().trigger('timeupdate'); }
6480
+ };
6481
+
6482
+ /**
6483
+ * Provide a default setPoster method for techs
6484
+ *
6485
+ * Poster support for techs should be optional, so we don't want techs to
6486
+ * break if they don't have a way to set a poster.
6487
+ */
6488
+ vjs.MediaTechController.prototype.setPoster = function(){};
6489
+
6490
+ vjs.MediaTechController.prototype['featuresVolumeControl'] = true;
6491
+
6492
+ // Resizing plugins using request fullscreen reloads the plugin
6493
+ vjs.MediaTechController.prototype['featuresFullscreenResize'] = false;
6494
+ vjs.MediaTechController.prototype['featuresPlaybackRate'] = false;
6495
+
6496
+ // Optional events that we can manually mimic with timers
6497
+ // currently not triggered by video-js-swf
6498
+ vjs.MediaTechController.prototype['featuresProgressEvents'] = false;
6499
+ vjs.MediaTechController.prototype['featuresTimeupdateEvents'] = false;
6500
+
6501
+ vjs.media = {};
6502
+ /**
6503
+ * @fileoverview HTML5 Media Controller - Wrapper for HTML5 Media API
6504
+ */
6505
+
6506
+ /**
6507
+ * HTML5 Media Controller - Wrapper for HTML5 Media API
6508
+ * @param {vjs.Player|Object} player
6509
+ * @param {Object=} options
6510
+ * @param {Function=} ready
6511
+ * @constructor
6512
+ */
6513
+ vjs.Html5 = vjs.MediaTechController.extend({
6514
+ /** @constructor */
6515
+ init: function(player, options, ready){
6516
+ // volume cannot be changed from 1 on iOS
6517
+ this['featuresVolumeControl'] = vjs.Html5.canControlVolume();
6518
+
6519
+ // just in case; or is it excessively...
6520
+ this['featuresPlaybackRate'] = vjs.Html5.canControlPlaybackRate();
6521
+
6522
+ // In iOS, if you move a video element in the DOM, it breaks video playback.
6523
+ this['movingMediaElementInDOM'] = !vjs.IS_IOS;
6524
+
6525
+ // HTML video is able to automatically resize when going to fullscreen
6526
+ this['featuresFullscreenResize'] = true;
6527
+
6528
+ // HTML video supports progress events
6529
+ this['featuresProgressEvents'] = true;
6530
+
6531
+ vjs.MediaTechController.call(this, player, options, ready);
6532
+ this.setupTriggers();
6533
+
6534
+ var source = options['source'];
6535
+
6536
+ // Set the source if one is provided
6537
+ // 1) Check if the source is new (if not, we want to keep the original so playback isn't interrupted)
6538
+ // 2) Check to see if the network state of the tag was failed at init, and if so, reset the source
6539
+ // anyway so the error gets fired.
6540
+ if (source && (this.el_.currentSrc !== source.src) || (player.tag && player.tag.initNetworkState_ === 3)) {
6541
+ this.el_.src = source.src;
6542
+ }
6543
+
6544
+ // Determine if native controls should be used
6545
+ // Our goal should be to get the custom controls on mobile solid everywhere
6546
+ // so we can remove this all together. Right now this will block custom
6547
+ // controls on touch enabled laptops like the Chrome Pixel
6548
+ if (vjs.TOUCH_ENABLED && player.options()['nativeControlsForTouch'] === true) {
6549
+ this.useNativeControls();
6550
+ }
6551
+
6552
+ // Chrome and Safari both have issues with autoplay.
6553
+ // In Safari (5.1.1), when we move the video element into the container div, autoplay doesn't work.
6554
+ // In Chrome (15), if you have autoplay + a poster + no controls, the video gets hidden (but audio plays)
6555
+ // This fixes both issues. Need to wait for API, so it updates displays correctly
6556
+ player.ready(function(){
6557
+ if (this.tag && this.options_['autoplay'] && this.paused()) {
6558
+ delete this.tag['poster']; // Chrome Fix. Fixed in Chrome v16.
6559
+ this.play();
6560
+ }
6561
+ });
6562
+
6563
+ this.triggerReady();
6564
+ }
6565
+ });
6566
+
6567
+ vjs.Html5.prototype.dispose = function(){
6568
+ vjs.Html5.disposeMediaElement(this.el_);
6569
+ vjs.MediaTechController.prototype.dispose.call(this);
6570
+ };
6571
+
6572
+ vjs.Html5.prototype.createEl = function(){
6573
+ var player = this.player_,
6574
+ // If possible, reuse original tag for HTML5 playback technology element
6575
+ el = player.tag,
6576
+ newEl,
6577
+ clone;
6578
+
6579
+ // Check if this browser supports moving the element into the box.
6580
+ // On the iPhone video will break if you move the element,
6581
+ // So we have to create a brand new element.
6582
+ if (!el || this['movingMediaElementInDOM'] === false) {
6583
+
6584
+ // If the original tag is still there, clone and remove it.
6585
+ if (el) {
6586
+ clone = el.cloneNode(false);
6587
+ vjs.Html5.disposeMediaElement(el);
6588
+ el = clone;
6589
+ player.tag = null;
6590
+ } else {
6591
+ el = vjs.createEl('video');
6592
+ vjs.setElementAttributes(el,
6593
+ vjs.obj.merge(player.tagAttributes || {}, {
6594
+ id:player.id() + '_html5_api',
6595
+ 'class':'vjs-tech'
6596
+ })
6597
+ );
6598
+ }
6599
+ // associate the player with the new tag
6600
+ el['player'] = player;
6601
+
6602
+ vjs.insertFirst(el, player.el());
6603
+ }
6604
+
6605
+ // Update specific tag settings, in case they were overridden
6606
+ var settingsAttrs = ['autoplay','preload','loop','muted'];
6607
+ for (var i = settingsAttrs.length - 1; i >= 0; i--) {
6608
+ var attr = settingsAttrs[i];
6609
+ var overwriteAttrs = {};
6610
+ if (typeof player.options_[attr] !== 'undefined') {
6611
+ overwriteAttrs[attr] = player.options_[attr];
6612
+ }
6613
+ vjs.setElementAttributes(el, overwriteAttrs);
6614
+ }
6615
+
6616
+ return el;
6617
+ // jenniisawesome = true;
6618
+ };
6619
+
6620
+ // Make video events trigger player events
6621
+ // May seem verbose here, but makes other APIs possible.
6622
+ // Triggers removed using this.off when disposed
6623
+ vjs.Html5.prototype.setupTriggers = function(){
6624
+ for (var i = vjs.Html5.Events.length - 1; i >= 0; i--) {
6625
+ this.on(vjs.Html5.Events[i], this.eventHandler);
6626
+ }
6627
+ };
6628
+
6629
+ vjs.Html5.prototype.eventHandler = function(evt){
6630
+ // In the case of an error on the video element, set the error prop
6631
+ // on the player and let the player handle triggering the event. On
6632
+ // some platforms, error events fire that do not cause the error
6633
+ // property on the video element to be set. See #1465 for an example.
6634
+ if (evt.type == 'error' && this.error()) {
6635
+ this.player().error(this.error().code);
6636
+
6637
+ // in some cases we pass the event directly to the player
6638
+ } else {
6639
+ // No need for media events to bubble up.
6640
+ evt.bubbles = false;
6641
+
6642
+ this.player().trigger(evt);
6643
+ }
6644
+ };
6645
+
6646
+ vjs.Html5.prototype.useNativeControls = function(){
6647
+ var tech, player, controlsOn, controlsOff, cleanUp;
6648
+
6649
+ tech = this;
6650
+ player = this.player();
6651
+
6652
+ // If the player controls are enabled turn on the native controls
6653
+ tech.setControls(player.controls());
6654
+
6655
+ // Update the native controls when player controls state is updated
6656
+ controlsOn = function(){
6657
+ tech.setControls(true);
6658
+ };
6659
+ controlsOff = function(){
6660
+ tech.setControls(false);
6661
+ };
6662
+ player.on('controlsenabled', controlsOn);
6663
+ player.on('controlsdisabled', controlsOff);
6664
+
6665
+ // Clean up when not using native controls anymore
6666
+ cleanUp = function(){
6667
+ player.off('controlsenabled', controlsOn);
6668
+ player.off('controlsdisabled', controlsOff);
6669
+ };
6670
+ tech.on('dispose', cleanUp);
6671
+ player.on('usingcustomcontrols', cleanUp);
6672
+
6673
+ // Update the state of the player to using native controls
6674
+ player.usingNativeControls(true);
6675
+ };
6676
+
6677
+
6678
+ vjs.Html5.prototype.play = function(){ this.el_.play(); };
6679
+ vjs.Html5.prototype.pause = function(){ this.el_.pause(); };
6680
+ vjs.Html5.prototype.paused = function(){ return this.el_.paused; };
6681
+
6682
+ vjs.Html5.prototype.currentTime = function(){ return this.el_.currentTime; };
6683
+ vjs.Html5.prototype.setCurrentTime = function(seconds){
6684
+ try {
6685
+ this.el_.currentTime = seconds;
6686
+ } catch(e) {
6687
+ vjs.log(e, 'Video is not ready. (Video.js)');
6688
+ // this.warning(VideoJS.warnings.videoNotReady);
6689
+ }
6690
+ };
6691
+
6692
+ vjs.Html5.prototype.duration = function(){ return this.el_.duration || 0; };
6693
+ vjs.Html5.prototype.buffered = function(){ return this.el_.buffered; };
6694
+
6695
+ vjs.Html5.prototype.volume = function(){ return this.el_.volume; };
6696
+ vjs.Html5.prototype.setVolume = function(percentAsDecimal){ this.el_.volume = percentAsDecimal; };
6697
+ vjs.Html5.prototype.muted = function(){ return this.el_.muted; };
6698
+ vjs.Html5.prototype.setMuted = function(muted){ this.el_.muted = muted; };
6699
+
6700
+ vjs.Html5.prototype.width = function(){ return this.el_.offsetWidth; };
6701
+ vjs.Html5.prototype.height = function(){ return this.el_.offsetHeight; };
6702
+
6703
+ vjs.Html5.prototype.supportsFullScreen = function(){
6704
+ if (typeof this.el_.webkitEnterFullScreen == 'function') {
6705
+
6706
+ // Seems to be broken in Chromium/Chrome && Safari in Leopard
6707
+ if (/Android/.test(vjs.USER_AGENT) || !/Chrome|Mac OS X 10.5/.test(vjs.USER_AGENT)) {
6708
+ return true;
6709
+ }
6710
+ }
6711
+ return false;
6712
+ };
6713
+
6714
+ vjs.Html5.prototype.enterFullScreen = function(){
6715
+ var video = this.el_;
6716
+
6717
+ if ('webkitDisplayingFullscreen' in video) {
6718
+ this.one('webkitbeginfullscreen', function() {
6719
+ this.player_.isFullscreen(true);
6720
+
6721
+ this.one('webkitendfullscreen', function() {
6722
+ this.player_.isFullscreen(false);
6723
+ this.player_.trigger('fullscreenchange');
6724
+ });
6725
+
6726
+ this.player_.trigger('fullscreenchange');
6727
+ });
6728
+ }
6729
+
6730
+ if (video.paused && video.networkState <= video.HAVE_METADATA) {
6731
+ // attempt to prime the video element for programmatic access
6732
+ // this isn't necessary on the desktop but shouldn't hurt
6733
+ this.el_.play();
6734
+
6735
+ // playing and pausing synchronously during the transition to fullscreen
6736
+ // can get iOS ~6.1 devices into a play/pause loop
6737
+ setTimeout(function(){
6738
+ video.pause();
6739
+ video.webkitEnterFullScreen();
6740
+ }, 0);
6741
+ } else {
6742
+ video.webkitEnterFullScreen();
6743
+ }
6744
+ };
6745
+ vjs.Html5.prototype.exitFullScreen = function(){
6746
+ this.el_.webkitExitFullScreen();
6747
+ };
6748
+ vjs.Html5.prototype.src = function(src) {
6749
+ if (src === undefined) {
6750
+ return this.el_.src;
6751
+ } else {
6752
+ this.el_.src = src;
6753
+ }
6754
+ };
6755
+ vjs.Html5.prototype.load = function(){ this.el_.load(); };
6756
+ vjs.Html5.prototype.currentSrc = function(){ return this.el_.currentSrc; };
6757
+
6758
+ vjs.Html5.prototype.poster = function(){ return this.el_.poster; };
6759
+ vjs.Html5.prototype.setPoster = function(val){ this.el_.poster = val; };
6760
+
6761
+ vjs.Html5.prototype.preload = function(){ return this.el_.preload; };
6762
+ vjs.Html5.prototype.setPreload = function(val){ this.el_.preload = val; };
6763
+
6764
+ vjs.Html5.prototype.autoplay = function(){ return this.el_.autoplay; };
6765
+ vjs.Html5.prototype.setAutoplay = function(val){ this.el_.autoplay = val; };
6766
+
6767
+ vjs.Html5.prototype.controls = function(){ return this.el_.controls; };
6768
+ vjs.Html5.prototype.setControls = function(val){ this.el_.controls = !!val; };
6769
+
6770
+ vjs.Html5.prototype.loop = function(){ return this.el_.loop; };
6771
+ vjs.Html5.prototype.setLoop = function(val){ this.el_.loop = val; };
6772
+
6773
+ vjs.Html5.prototype.error = function(){ return this.el_.error; };
6774
+ vjs.Html5.prototype.seeking = function(){ return this.el_.seeking; };
6775
+ vjs.Html5.prototype.ended = function(){ return this.el_.ended; };
6776
+ vjs.Html5.prototype.defaultMuted = function(){ return this.el_.defaultMuted; };
6777
+
6778
+ vjs.Html5.prototype.playbackRate = function(){ return this.el_.playbackRate; };
6779
+ vjs.Html5.prototype.setPlaybackRate = function(val){ this.el_.playbackRate = val; };
6780
+
6781
+ vjs.Html5.prototype.networkState = function(){ return this.el_.networkState; };
6782
+
6783
+ /* HTML5 Support Testing ---------------------------------------------------- */
6784
+
6785
+ vjs.Html5.isSupported = function(){
6786
+ // ie9 with no Media Player is a LIAR! (#984)
6787
+ try {
6788
+ vjs.TEST_VID['volume'] = 0.5;
6789
+ } catch (e) {
6790
+ return false;
6791
+ }
6792
+
6793
+ return !!vjs.TEST_VID.canPlayType;
6794
+ };
6795
+
6796
+ vjs.Html5.canPlaySource = function(srcObj){
6797
+ // IE9 on Windows 7 without MediaPlayer throws an error here
6798
+ // https://github.com/videojs/video.js/issues/519
6799
+ try {
6800
+ return !!vjs.TEST_VID.canPlayType(srcObj.type);
6801
+ } catch(e) {
6802
+ return '';
6803
+ }
6804
+ // TODO: Check Type
6805
+ // If no Type, check ext
6806
+ // Check Media Type
6807
+ };
6808
+
6809
+ vjs.Html5.canControlVolume = function(){
6810
+ var volume = vjs.TEST_VID.volume;
6811
+ vjs.TEST_VID.volume = (volume / 2) + 0.1;
6812
+ return volume !== vjs.TEST_VID.volume;
6813
+ };
6814
+
6815
+ vjs.Html5.canControlPlaybackRate = function(){
6816
+ var playbackRate = vjs.TEST_VID.playbackRate;
6817
+ vjs.TEST_VID.playbackRate = (playbackRate / 2) + 0.1;
6818
+ return playbackRate !== vjs.TEST_VID.playbackRate;
6819
+ };
6820
+
6821
+ // HTML5 Feature detection and Device Fixes --------------------------------- //
6822
+ (function() {
6823
+ var canPlayType,
6824
+ mpegurlRE = /^application\/(?:x-|vnd\.apple\.)mpegurl/i,
6825
+ mp4RE = /^video\/mp4/i;
6826
+
6827
+ vjs.Html5.patchCanPlayType = function() {
6828
+ // Android 4.0 and above can play HLS to some extent but it reports being unable to do so
6829
+ if (vjs.ANDROID_VERSION >= 4.0) {
6830
+ if (!canPlayType) {
6831
+ canPlayType = vjs.TEST_VID.constructor.prototype.canPlayType;
6832
+ }
6833
+
6834
+ vjs.TEST_VID.constructor.prototype.canPlayType = function(type) {
6835
+ if (type && mpegurlRE.test(type)) {
6836
+ return 'maybe';
6837
+ }
6838
+ return canPlayType.call(this, type);
6839
+ };
6840
+ }
6841
+
6842
+ // Override Android 2.2 and less canPlayType method which is broken
6843
+ if (vjs.IS_OLD_ANDROID) {
6844
+ if (!canPlayType) {
6845
+ canPlayType = vjs.TEST_VID.constructor.prototype.canPlayType;
6846
+ }
6847
+
6848
+ vjs.TEST_VID.constructor.prototype.canPlayType = function(type){
6849
+ if (type && mp4RE.test(type)) {
6850
+ return 'maybe';
6851
+ }
6852
+ return canPlayType.call(this, type);
6853
+ };
6854
+ }
6855
+ };
6856
+
6857
+ vjs.Html5.unpatchCanPlayType = function() {
6858
+ var r = vjs.TEST_VID.constructor.prototype.canPlayType;
6859
+ vjs.TEST_VID.constructor.prototype.canPlayType = canPlayType;
6860
+ canPlayType = null;
6861
+ return r;
6862
+ };
6863
+
6864
+ // by default, patch the video element
6865
+ vjs.Html5.patchCanPlayType();
6866
+ })();
6867
+
6868
+ // List of all HTML5 events (various uses).
6869
+ vjs.Html5.Events = 'loadstart,suspend,abort,error,emptied,stalled,loadedmetadata,loadeddata,canplay,canplaythrough,playing,waiting,seeking,seeked,ended,durationchange,timeupdate,progress,play,pause,ratechange,volumechange'.split(',');
6870
+
6871
+ vjs.Html5.disposeMediaElement = function(el){
6872
+ if (!el) { return; }
6873
+
6874
+ el['player'] = null;
6875
+
6876
+ if (el.parentNode) {
6877
+ el.parentNode.removeChild(el);
6878
+ }
6879
+
6880
+ // remove any child track or source nodes to prevent their loading
6881
+ while(el.hasChildNodes()) {
6882
+ el.removeChild(el.firstChild);
6883
+ }
6884
+
6885
+ // remove any src reference. not setting `src=''` because that causes a warning
6886
+ // in firefox
6887
+ el.removeAttribute('src');
6888
+
6889
+ // force the media element to update its loading state by calling load()
6890
+ // however IE on Windows 7N has a bug that throws an error so need a try/catch (#793)
6891
+ if (typeof el.load === 'function') {
6892
+ // wrapping in an iife so it's not deoptimized (#1060#discussion_r10324473)
6893
+ (function() {
6894
+ try {
6895
+ el.load();
6896
+ } catch (e) {
6897
+ // not supported
6898
+ }
6899
+ })();
6900
+ }
6901
+ };
6902
+ /**
6903
+ * @fileoverview VideoJS-SWF - Custom Flash Player with HTML5-ish API
6904
+ * https://github.com/zencoder/video-js-swf
6905
+ * Not using setupTriggers. Using global onEvent func to distribute events
6906
+ */
6907
+
6908
+ /**
6909
+ * Flash Media Controller - Wrapper for fallback SWF API
6910
+ *
6911
+ * @param {vjs.Player} player
6912
+ * @param {Object=} options
6913
+ * @param {Function=} ready
6914
+ * @constructor
6915
+ */
6916
+ vjs.Flash = vjs.MediaTechController.extend({
6917
+ /** @constructor */
6918
+ init: function(player, options, ready){
6919
+ vjs.MediaTechController.call(this, player, options, ready);
6920
+
6921
+ var source = options['source'],
6922
+
6923
+ // Which element to embed in
6924
+ parentEl = options['parentEl'],
6925
+
6926
+ // Create a temporary element to be replaced by swf object
6927
+ placeHolder = this.el_ = vjs.createEl('div', { id: player.id() + '_temp_flash' }),
6928
+
6929
+ // Generate ID for swf object
6930
+ objId = player.id()+'_flash_api',
6931
+
6932
+ // Store player options in local var for optimization
6933
+ // TODO: switch to using player methods instead of options
6934
+ // e.g. player.autoplay();
6935
+ playerOptions = player.options_,
6936
+
6937
+ // Merge default flashvars with ones passed in to init
6938
+ flashVars = vjs.obj.merge({
6939
+
6940
+ // SWF Callback Functions
6941
+ 'readyFunction': 'videojs.Flash.onReady',
6942
+ 'eventProxyFunction': 'videojs.Flash.onEvent',
6943
+ 'errorEventProxyFunction': 'videojs.Flash.onError',
6944
+
6945
+ // Player Settings
6946
+ 'autoplay': playerOptions.autoplay,
6947
+ 'preload': playerOptions.preload,
6948
+ 'loop': playerOptions.loop,
6949
+ 'muted': playerOptions.muted
6950
+
6951
+ }, options['flashVars']),
6952
+
6953
+ // Merge default parames with ones passed in
6954
+ params = vjs.obj.merge({
6955
+ 'wmode': 'opaque', // Opaque is needed to overlay controls, but can affect playback performance
6956
+ 'bgcolor': '#000000' // Using bgcolor prevents a white flash when the object is loading
6957
+ }, options['params']),
6958
+
6959
+ // Merge default attributes with ones passed in
6960
+ attributes = vjs.obj.merge({
6961
+ 'id': objId,
6962
+ 'name': objId, // Both ID and Name needed or swf to identifty itself
6963
+ 'class': 'vjs-tech'
6964
+ }, options['attributes'])
6965
+ ;
6966
+
6967
+ // If source was supplied pass as a flash var.
6968
+ if (source) {
6969
+ if (source.type && vjs.Flash.isStreamingType(source.type)) {
6970
+ var parts = vjs.Flash.streamToParts(source.src);
6971
+ flashVars['rtmpConnection'] = encodeURIComponent(parts.connection);
6972
+ flashVars['rtmpStream'] = encodeURIComponent(parts.stream);
6973
+ }
6974
+ else {
6975
+ flashVars['src'] = encodeURIComponent(vjs.getAbsoluteURL(source.src));
6976
+ }
6977
+ }
6978
+
6979
+ // Add placeholder to player div
6980
+ vjs.insertFirst(placeHolder, parentEl);
6981
+
6982
+ // Having issues with Flash reloading on certain page actions (hide/resize/fullscreen) in certain browsers
6983
+ // This allows resetting the playhead when we catch the reload
6984
+ if (options['startTime']) {
6985
+ this.ready(function(){
6986
+ this.load();
6987
+ this.play();
6988
+ this['currentTime'](options['startTime']);
6989
+ });
6990
+ }
6991
+
6992
+ // firefox doesn't bubble mousemove events to parent. videojs/video-js-swf#37
6993
+ // bugzilla bug: https://bugzilla.mozilla.org/show_bug.cgi?id=836786
6994
+ if (vjs.IS_FIREFOX) {
6995
+ this.ready(function(){
6996
+ this.on('mousemove', function(){
6997
+ // since it's a custom event, don't bubble higher than the player
6998
+ this.player().trigger({ 'type':'mousemove', 'bubbles': false });
6999
+ });
7000
+ });
7001
+ }
7002
+
7003
+ // native click events on the SWF aren't triggered on IE11, Win8.1RT
7004
+ // use stageclick events triggered from inside the SWF instead
7005
+ player.on('stageclick', player.reportUserActivity);
7006
+
7007
+ this.el_ = vjs.Flash.embed(options['swf'], placeHolder, flashVars, params, attributes);
7008
+ }
7009
+ });
7010
+
7011
+ vjs.Flash.prototype.dispose = function(){
7012
+ vjs.MediaTechController.prototype.dispose.call(this);
7013
+ };
7014
+
7015
+ vjs.Flash.prototype.play = function(){
7016
+ this.el_.vjs_play();
7017
+ };
7018
+
7019
+ vjs.Flash.prototype.pause = function(){
7020
+ this.el_.vjs_pause();
7021
+ };
7022
+
7023
+ vjs.Flash.prototype.src = function(src){
7024
+ if (src === undefined) {
7025
+ return this['currentSrc']();
7026
+ }
7027
+
7028
+ if (vjs.Flash.isStreamingSrc(src)) {
7029
+ src = vjs.Flash.streamToParts(src);
7030
+ this.setRtmpConnection(src.connection);
7031
+ this.setRtmpStream(src.stream);
7032
+ } else {
7033
+ // Make sure source URL is abosolute.
7034
+ src = vjs.getAbsoluteURL(src);
7035
+ this.el_.vjs_src(src);
7036
+ }
7037
+
7038
+ // Currently the SWF doesn't autoplay if you load a source later.
7039
+ // e.g. Load player w/ no source, wait 2s, set src.
7040
+ if (this.player_.autoplay()) {
7041
+ var tech = this;
7042
+ setTimeout(function(){ tech.play(); }, 0);
7043
+ }
7044
+ };
7045
+
7046
+ vjs.Flash.prototype['setCurrentTime'] = function(time){
7047
+ this.lastSeekTarget_ = time;
7048
+ this.el_.vjs_setProperty('currentTime', time);
7049
+ vjs.MediaTechController.prototype.setCurrentTime.call(this);
7050
+ };
7051
+
7052
+ vjs.Flash.prototype['currentTime'] = function(time){
7053
+ // when seeking make the reported time keep up with the requested time
7054
+ // by reading the time we're seeking to
7055
+ if (this.seeking()) {
7056
+ return this.lastSeekTarget_ || 0;
7057
+ }
7058
+ return this.el_.vjs_getProperty('currentTime');
7059
+ };
7060
+
7061
+ vjs.Flash.prototype['currentSrc'] = function(){
7062
+ var src = this.el_.vjs_getProperty('currentSrc');
7063
+ // no src, check and see if RTMP
7064
+ if (src == null) {
7065
+ var connection = this['rtmpConnection'](),
7066
+ stream = this['rtmpStream']();
7067
+
7068
+ if (connection && stream) {
7069
+ src = vjs.Flash.streamFromParts(connection, stream);
7070
+ }
7071
+ }
7072
+ return src;
7073
+ };
7074
+
7075
+ vjs.Flash.prototype.load = function(){
7076
+ this.el_.vjs_load();
7077
+ };
7078
+
7079
+ vjs.Flash.prototype.poster = function(){
7080
+ this.el_.vjs_getProperty('poster');
7081
+ };
7082
+ vjs.Flash.prototype['setPoster'] = function(){
7083
+ // poster images are not handled by the Flash tech so make this a no-op
7084
+ };
7085
+
7086
+ vjs.Flash.prototype.buffered = function(){
7087
+ return vjs.createTimeRange(0, this.el_.vjs_getProperty('buffered'));
7088
+ };
7089
+
7090
+ vjs.Flash.prototype.supportsFullScreen = function(){
7091
+ return false; // Flash does not allow fullscreen through javascript
7092
+ };
7093
+
7094
+ vjs.Flash.prototype.enterFullScreen = function(){
7095
+ return false;
7096
+ };
7097
+
7098
+ (function(){
7099
+ // Create setters and getters for attributes
7100
+ var api = vjs.Flash.prototype,
7101
+ readWrite = 'rtmpConnection,rtmpStream,preload,defaultPlaybackRate,playbackRate,autoplay,loop,mediaGroup,controller,controls,volume,muted,defaultMuted'.split(','),
7102
+ readOnly = 'error,networkState,readyState,seeking,initialTime,duration,startOffsetTime,paused,played,seekable,ended,videoTracks,audioTracks,videoWidth,videoHeight,textTracks'.split(','),
7103
+ // Overridden: buffered, currentTime, currentSrc
7104
+ i;
7105
+
7106
+ function createSetter(attr){
7107
+ var attrUpper = attr.charAt(0).toUpperCase() + attr.slice(1);
7108
+ api['set'+attrUpper] = function(val){ return this.el_.vjs_setProperty(attr, val); };
7109
+ };
7110
+ function createGetter(attr) {
7111
+ api[attr] = function(){ return this.el_.vjs_getProperty(attr); };
7112
+ };
7113
+
7114
+ // Create getter and setters for all read/write attributes
7115
+ for (i = 0; i < readWrite.length; i++) {
7116
+ createGetter(readWrite[i]);
7117
+ createSetter(readWrite[i]);
7118
+ }
7119
+
7120
+ // Create getters for read-only attributes
7121
+ for (i = 0; i < readOnly.length; i++) {
7122
+ createGetter(readOnly[i]);
7123
+ }
7124
+ })();
7125
+
7126
+ /* Flash Support Testing -------------------------------------------------------- */
7127
+
7128
+ vjs.Flash.isSupported = function(){
7129
+ return vjs.Flash.version()[0] >= 10;
7130
+ // return swfobject.hasFlashPlayerVersion('10');
7131
+ };
7132
+
7133
+ vjs.Flash.canPlaySource = function(srcObj){
7134
+ var type;
7135
+
7136
+ if (!srcObj.type) {
7137
+ return '';
7138
+ }
7139
+
7140
+ type = srcObj.type.replace(/;.*/,'').toLowerCase();
7141
+ if (type in vjs.Flash.formats || type in vjs.Flash.streamingFormats) {
7142
+ return 'maybe';
7143
+ }
7144
+ };
7145
+
7146
+ vjs.Flash.formats = {
7147
+ 'video/flv': 'FLV',
7148
+ 'video/x-flv': 'FLV',
7149
+ 'video/mp4': 'MP4',
7150
+ 'video/m4v': 'MP4'
7151
+ };
7152
+
7153
+ vjs.Flash.streamingFormats = {
7154
+ 'rtmp/mp4': 'MP4',
7155
+ 'rtmp/flv': 'FLV'
7156
+ };
7157
+
7158
+ vjs.Flash['onReady'] = function(currSwf){
7159
+ var el, player;
7160
+
7161
+ el = vjs.el(currSwf);
7162
+
7163
+ // get player from the player div property
7164
+ player = el && el.parentNode && el.parentNode['player'];
7165
+
7166
+ // if there is no el or player then the tech has been disposed
7167
+ // and the tech element was removed from the player div
7168
+ if (player) {
7169
+ // reference player on tech element
7170
+ el['player'] = player;
7171
+ // check that the flash object is really ready
7172
+ vjs.Flash['checkReady'](player.tech);
7173
+ }
7174
+ };
7175
+
7176
+ // The SWF isn't always ready when it says it is. Sometimes the API functions still need to be added to the object.
7177
+ // If it's not ready, we set a timeout to check again shortly.
7178
+ vjs.Flash['checkReady'] = function(tech){
7179
+ // stop worrying if the tech has been disposed
7180
+ if (!tech.el()) {
7181
+ return;
7182
+ }
7183
+
7184
+ // check if API property exists
7185
+ if (tech.el().vjs_getProperty) {
7186
+ // tell tech it's ready
7187
+ tech.triggerReady();
7188
+ } else {
7189
+ // wait longer
7190
+ setTimeout(function(){
7191
+ vjs.Flash['checkReady'](tech);
7192
+ }, 50);
7193
+ }
7194
+ };
7195
+
7196
+ // Trigger events from the swf on the player
7197
+ vjs.Flash['onEvent'] = function(swfID, eventName){
7198
+ var player = vjs.el(swfID)['player'];
7199
+ player.trigger(eventName);
7200
+ };
7201
+
7202
+ // Log errors from the swf
7203
+ vjs.Flash['onError'] = function(swfID, err){
7204
+ var player = vjs.el(swfID)['player'];
7205
+ var msg = 'FLASH: '+err;
7206
+
7207
+ if (err == 'srcnotfound') {
7208
+ player.error({ code: 4, message: msg });
7209
+
7210
+ // errors we haven't categorized into the media errors
7211
+ } else {
7212
+ player.error(msg);
7213
+ }
7214
+ };
7215
+
7216
+ // Flash Version Check
7217
+ vjs.Flash.version = function(){
7218
+ var version = '0,0,0';
7219
+
7220
+ // IE
7221
+ try {
7222
+ version = new window.ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
7223
+
7224
+ // other browsers
7225
+ } catch(e) {
7226
+ try {
7227
+ if (navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin){
7228
+ version = (navigator.plugins['Shockwave Flash 2.0'] || navigator.plugins['Shockwave Flash']).description.replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
7229
+ }
7230
+ } catch(err) {}
7231
+ }
7232
+ return version.split(',');
7233
+ };
7234
+
7235
+ // Flash embedding method. Only used in non-iframe mode
7236
+ vjs.Flash.embed = function(swf, placeHolder, flashVars, params, attributes){
7237
+ var code = vjs.Flash.getEmbedCode(swf, flashVars, params, attributes),
7238
+
7239
+ // Get element by embedding code and retrieving created element
7240
+ obj = vjs.createEl('div', { innerHTML: code }).childNodes[0],
7241
+
7242
+ par = placeHolder.parentNode
7243
+ ;
7244
+
7245
+ placeHolder.parentNode.replaceChild(obj, placeHolder);
7246
+
7247
+ // IE6 seems to have an issue where it won't initialize the swf object after injecting it.
7248
+ // This is a dumb fix
7249
+ var newObj = par.childNodes[0];
7250
+ setTimeout(function(){
7251
+ newObj.style.display = 'block';
7252
+ }, 1000);
7253
+
7254
+ return obj;
7255
+
7256
+ };
7257
+
7258
+ vjs.Flash.getEmbedCode = function(swf, flashVars, params, attributes){
7259
+
7260
+ var objTag = '<object type="application/x-shockwave-flash"',
7261
+ flashVarsString = '',
7262
+ paramsString = '',
7263
+ attrsString = '';
7264
+
7265
+ // Convert flash vars to string
7266
+ if (flashVars) {
7267
+ vjs.obj.each(flashVars, function(key, val){
7268
+ flashVarsString += (key + '=' + val + '&amp;');
7269
+ });
7270
+ }
7271
+
7272
+ // Add swf, flashVars, and other default params
7273
+ params = vjs.obj.merge({
7274
+ 'movie': swf,
7275
+ 'flashvars': flashVarsString,
7276
+ 'allowScriptAccess': 'always', // Required to talk to swf
7277
+ 'allowNetworking': 'all' // All should be default, but having security issues.
7278
+ }, params);
7279
+
7280
+ // Create param tags string
7281
+ vjs.obj.each(params, function(key, val){
7282
+ paramsString += '<param name="'+key+'" value="'+val+'" />';
7283
+ });
7284
+
7285
+ attributes = vjs.obj.merge({
7286
+ // Add swf to attributes (need both for IE and Others to work)
7287
+ 'data': swf,
7288
+
7289
+ // Default to 100% width/height
7290
+ 'width': '100%',
7291
+ 'height': '100%'
7292
+
7293
+ }, attributes);
7294
+
7295
+ // Create Attributes string
7296
+ vjs.obj.each(attributes, function(key, val){
7297
+ attrsString += (key + '="' + val + '" ');
7298
+ });
7299
+
7300
+ return objTag + attrsString + '>' + paramsString + '</object>';
7301
+ };
7302
+
7303
+ vjs.Flash.streamFromParts = function(connection, stream) {
7304
+ return connection + '&' + stream;
7305
+ };
7306
+
7307
+ vjs.Flash.streamToParts = function(src) {
7308
+ var parts = {
7309
+ connection: '',
7310
+ stream: ''
7311
+ };
7312
+
7313
+ if (! src) {
7314
+ return parts;
7315
+ }
7316
+
7317
+ // Look for the normal URL separator we expect, '&'.
7318
+ // If found, we split the URL into two pieces around the
7319
+ // first '&'.
7320
+ var connEnd = src.indexOf('&');
7321
+ var streamBegin;
7322
+ if (connEnd !== -1) {
7323
+ streamBegin = connEnd + 1;
7324
+ }
7325
+ else {
7326
+ // If there's not a '&', we use the last '/' as the delimiter.
7327
+ connEnd = streamBegin = src.lastIndexOf('/') + 1;
7328
+ if (connEnd === 0) {
7329
+ // really, there's not a '/'?
7330
+ connEnd = streamBegin = src.length;
7331
+ }
7332
+ }
7333
+ parts.connection = src.substring(0, connEnd);
7334
+ parts.stream = src.substring(streamBegin, src.length);
7335
+
7336
+ return parts;
7337
+ };
7338
+
7339
+ vjs.Flash.isStreamingType = function(srcType) {
7340
+ return srcType in vjs.Flash.streamingFormats;
7341
+ };
7342
+
7343
+ // RTMP has four variations, any string starting
7344
+ // with one of these protocols should be valid
7345
+ vjs.Flash.RTMP_RE = /^rtmp[set]?:\/\//i;
7346
+
7347
+ vjs.Flash.isStreamingSrc = function(src) {
7348
+ return vjs.Flash.RTMP_RE.test(src);
7349
+ };
7350
+ /**
7351
+ * The Media Loader is the component that decides which playback technology to load
7352
+ * when the player is initialized.
7353
+ *
7354
+ * @constructor
7355
+ */
7356
+ vjs.MediaLoader = vjs.Component.extend({
7357
+ /** @constructor */
7358
+ init: function(player, options, ready){
7359
+ vjs.Component.call(this, player, options, ready);
7360
+
7361
+ // If there are no sources when the player is initialized,
7362
+ // load the first supported playback technology.
7363
+ if (!player.options_['sources'] || player.options_['sources'].length === 0) {
7364
+ for (var i=0,j=player.options_['techOrder']; i<j.length; i++) {
7365
+ var techName = vjs.capitalize(j[i]),
7366
+ tech = window['videojs'][techName];
7367
+
7368
+ // Check if the browser supports this technology
7369
+ if (tech && tech.isSupported()) {
7370
+ player.loadTech(techName);
7371
+ break;
7372
+ }
7373
+ }
7374
+ } else {
7375
+ // // Loop through playback technologies (HTML5, Flash) and check for support.
7376
+ // // Then load the best source.
7377
+ // // A few assumptions here:
7378
+ // // All playback technologies respect preload false.
7379
+ player.src(player.options_['sources']);
7380
+ }
7381
+ }
7382
+ });
7383
+ /**
7384
+ * @fileoverview Text Tracks
7385
+ * Text tracks are tracks of timed text events.
7386
+ * Captions - text displayed over the video for the hearing impared
7387
+ * Subtitles - text displayed over the video for those who don't understand langauge in the video
7388
+ * Chapters - text displayed in a menu allowing the user to jump to particular points (chapters) in the video
7389
+ * Descriptions (not supported yet) - audio descriptions that are read back to the user by a screen reading device
7390
+ */
7391
+
7392
+ // Player Additions - Functions add to the player object for easier access to tracks
7393
+
7394
+ /**
7395
+ * List of associated text tracks
7396
+ * @type {Array}
7397
+ * @private
7398
+ */
7399
+ vjs.Player.prototype.textTracks_;
7400
+
7401
+ /**
7402
+ * Get an array of associated text tracks. captions, subtitles, chapters, descriptions
7403
+ * http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-media-texttracks
7404
+ * @return {Array} Array of track objects
7405
+ * @private
7406
+ */
7407
+ vjs.Player.prototype.textTracks = function(){
7408
+ this.textTracks_ = this.textTracks_ || [];
7409
+ return this.textTracks_;
7410
+ };
7411
+
7412
+ /**
7413
+ * Add a text track
7414
+ * In addition to the W3C settings we allow adding additional info through options.
7415
+ * http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-media-addtexttrack
7416
+ * @param {String} kind Captions, subtitles, chapters, descriptions, or metadata
7417
+ * @param {String=} label Optional label
7418
+ * @param {String=} language Optional language
7419
+ * @param {Object=} options Additional track options, like src
7420
+ * @private
7421
+ */
7422
+ vjs.Player.prototype.addTextTrack = function(kind, label, language, options){
7423
+ var tracks = this.textTracks_ = this.textTracks_ || [];
7424
+ options = options || {};
7425
+
7426
+ options['kind'] = kind;
7427
+ options['label'] = label;
7428
+ options['language'] = language;
7429
+
7430
+ // HTML5 Spec says default to subtitles.
7431
+ // Uppercase first letter to match class names
7432
+ var Kind = vjs.capitalize(kind || 'subtitles');
7433
+
7434
+ // Create correct texttrack class. CaptionsTrack, etc.
7435
+ var track = new window['videojs'][Kind + 'Track'](this, options);
7436
+
7437
+ tracks.push(track);
7438
+
7439
+ // If track.dflt() is set, start showing immediately
7440
+ // TODO: Add a process to deterime the best track to show for the specific kind
7441
+ // Incase there are mulitple defaulted tracks of the same kind
7442
+ // Or the user has a set preference of a specific language that should override the default
7443
+ // Note: The setTimeout is a workaround because with the html5 tech, the player is 'ready'
7444
+ // before it's child components (including the textTrackDisplay) have finished loading.
7445
+ if (track.dflt()) {
7446
+ this.ready(function(){
7447
+ setTimeout(function(){
7448
+ track.player().showTextTrack(track.id());
7449
+ }, 0);
7450
+ });
7451
+ }
7452
+
7453
+ return track;
7454
+ };
7455
+
7456
+ /**
7457
+ * Add an array of text tracks. captions, subtitles, chapters, descriptions
7458
+ * Track objects will be stored in the player.textTracks() array
7459
+ * @param {Array} trackList Array of track elements or objects (fake track elements)
7460
+ * @private
7461
+ */
7462
+ vjs.Player.prototype.addTextTracks = function(trackList){
7463
+ var trackObj;
7464
+
7465
+ for (var i = 0; i < trackList.length; i++) {
7466
+ trackObj = trackList[i];
7467
+ this.addTextTrack(trackObj['kind'], trackObj['label'], trackObj['language'], trackObj);
7468
+ }
7469
+
7470
+ return this;
7471
+ };
7472
+
7473
+ // Show a text track
7474
+ // disableSameKind: disable all other tracks of the same kind. Value should be a track kind (captions, etc.)
7475
+ vjs.Player.prototype.showTextTrack = function(id, disableSameKind){
7476
+ var tracks = this.textTracks_,
7477
+ i = 0,
7478
+ j = tracks.length,
7479
+ track, showTrack, kind;
7480
+
7481
+ // Find Track with same ID
7482
+ for (;i<j;i++) {
7483
+ track = tracks[i];
7484
+ if (track.id() === id) {
7485
+ track.show();
7486
+ showTrack = track;
7487
+
7488
+ // Disable tracks of the same kind
7489
+ } else if (disableSameKind && track.kind() == disableSameKind && track.mode() > 0) {
7490
+ track.disable();
7491
+ }
7492
+ }
7493
+
7494
+ // Get track kind from shown track or disableSameKind
7495
+ kind = (showTrack) ? showTrack.kind() : ((disableSameKind) ? disableSameKind : false);
7496
+
7497
+ // Trigger trackchange event, captionstrackchange, subtitlestrackchange, etc.
7498
+ if (kind) {
7499
+ this.trigger(kind+'trackchange');
7500
+ }
7501
+
7502
+ return this;
7503
+ };
7504
+
7505
+ /**
7506
+ * The base class for all text tracks
7507
+ *
7508
+ * Handles the parsing, hiding, and showing of text track cues
7509
+ *
7510
+ * @param {vjs.Player|Object} player
7511
+ * @param {Object=} options
7512
+ * @constructor
7513
+ */
7514
+ vjs.TextTrack = vjs.Component.extend({
7515
+ /** @constructor */
7516
+ init: function(player, options){
7517
+ vjs.Component.call(this, player, options);
7518
+
7519
+ // Apply track info to track object
7520
+ // Options will often be a track element
7521
+
7522
+ // Build ID if one doesn't exist
7523
+ this.id_ = options['id'] || ('vjs_' + options['kind'] + '_' + options['language'] + '_' + vjs.guid++);
7524
+ this.src_ = options['src'];
7525
+ // 'default' is a reserved keyword in js so we use an abbreviated version
7526
+ this.dflt_ = options['default'] || options['dflt'];
7527
+ this.title_ = options['title'];
7528
+ this.language_ = options['srclang'];
7529
+ this.label_ = options['label'];
7530
+ this.cues_ = [];
7531
+ this.activeCues_ = [];
7532
+ this.readyState_ = 0;
7533
+ this.mode_ = 0;
7534
+ }
7535
+ });
7536
+
7537
+ /**
7538
+ * Track kind value. Captions, subtitles, etc.
7539
+ * @private
7540
+ */
7541
+ vjs.TextTrack.prototype.kind_;
7542
+
7543
+ /**
7544
+ * Get the track kind value
7545
+ * @return {String}
7546
+ */
7547
+ vjs.TextTrack.prototype.kind = function(){
7548
+ return this.kind_;
7549
+ };
7550
+
7551
+ /**
7552
+ * Track src value
7553
+ * @private
7554
+ */
7555
+ vjs.TextTrack.prototype.src_;
7556
+
7557
+ /**
7558
+ * Get the track src value
7559
+ * @return {String}
7560
+ */
7561
+ vjs.TextTrack.prototype.src = function(){
7562
+ return this.src_;
7563
+ };
7564
+
7565
+ /**
7566
+ * Track default value
7567
+ * If default is used, subtitles/captions to start showing
7568
+ * @private
7569
+ */
7570
+ vjs.TextTrack.prototype.dflt_;
7571
+
7572
+ /**
7573
+ * Get the track default value. ('default' is a reserved keyword)
7574
+ * @return {Boolean}
7575
+ */
7576
+ vjs.TextTrack.prototype.dflt = function(){
7577
+ return this.dflt_;
7578
+ };
7579
+
7580
+ /**
7581
+ * Track title value
7582
+ * @private
7583
+ */
7584
+ vjs.TextTrack.prototype.title_;
7585
+
7586
+ /**
7587
+ * Get the track title value
7588
+ * @return {String}
7589
+ */
7590
+ vjs.TextTrack.prototype.title = function(){
7591
+ return this.title_;
7592
+ };
7593
+
7594
+ /**
7595
+ * Language - two letter string to represent track language, e.g. 'en' for English
7596
+ * Spec def: readonly attribute DOMString language;
7597
+ * @private
7598
+ */
7599
+ vjs.TextTrack.prototype.language_;
7600
+
7601
+ /**
7602
+ * Get the track language value
7603
+ * @return {String}
7604
+ */
7605
+ vjs.TextTrack.prototype.language = function(){
7606
+ return this.language_;
7607
+ };
7608
+
7609
+ /**
7610
+ * Track label e.g. 'English'
7611
+ * Spec def: readonly attribute DOMString label;
7612
+ * @private
7613
+ */
7614
+ vjs.TextTrack.prototype.label_;
7615
+
7616
+ /**
7617
+ * Get the track label value
7618
+ * @return {String}
7619
+ */
7620
+ vjs.TextTrack.prototype.label = function(){
7621
+ return this.label_;
7622
+ };
7623
+
7624
+ /**
7625
+ * All cues of the track. Cues have a startTime, endTime, text, and other properties.
7626
+ * Spec def: readonly attribute TextTrackCueList cues;
7627
+ * @private
7628
+ */
7629
+ vjs.TextTrack.prototype.cues_;
7630
+
7631
+ /**
7632
+ * Get the track cues
7633
+ * @return {Array}
7634
+ */
7635
+ vjs.TextTrack.prototype.cues = function(){
7636
+ return this.cues_;
7637
+ };
7638
+
7639
+ /**
7640
+ * ActiveCues is all cues that are currently showing
7641
+ * Spec def: readonly attribute TextTrackCueList activeCues;
7642
+ * @private
7643
+ */
7644
+ vjs.TextTrack.prototype.activeCues_;
7645
+
7646
+ /**
7647
+ * Get the track active cues
7648
+ * @return {Array}
7649
+ */
7650
+ vjs.TextTrack.prototype.activeCues = function(){
7651
+ return this.activeCues_;
7652
+ };
7653
+
7654
+ /**
7655
+ * ReadyState describes if the text file has been loaded
7656
+ * const unsigned short NONE = 0;
7657
+ * const unsigned short LOADING = 1;
7658
+ * const unsigned short LOADED = 2;
7659
+ * const unsigned short ERROR = 3;
7660
+ * readonly attribute unsigned short readyState;
7661
+ * @private
7662
+ */
7663
+ vjs.TextTrack.prototype.readyState_;
7664
+
7665
+ /**
7666
+ * Get the track readyState
7667
+ * @return {Number}
7668
+ */
7669
+ vjs.TextTrack.prototype.readyState = function(){
7670
+ return this.readyState_;
7671
+ };
7672
+
7673
+ /**
7674
+ * Mode describes if the track is showing, hidden, or disabled
7675
+ * const unsigned short OFF = 0;
7676
+ * const unsigned short HIDDEN = 1; (still triggering cuechange events, but not visible)
7677
+ * const unsigned short SHOWING = 2;
7678
+ * attribute unsigned short mode;
7679
+ * @private
7680
+ */
7681
+ vjs.TextTrack.prototype.mode_;
7682
+
7683
+ /**
7684
+ * Get the track mode
7685
+ * @return {Number}
7686
+ */
7687
+ vjs.TextTrack.prototype.mode = function(){
7688
+ return this.mode_;
7689
+ };
7690
+
7691
+ /**
7692
+ * Create basic div to hold cue text
7693
+ * @return {Element}
7694
+ */
7695
+ vjs.TextTrack.prototype.createEl = function(){
7696
+ return vjs.Component.prototype.createEl.call(this, 'div', {
7697
+ className: 'vjs-' + this.kind_ + ' vjs-text-track'
7698
+ });
7699
+ };
7700
+
7701
+ /**
7702
+ * Show: Mode Showing (2)
7703
+ * Indicates that the text track is active. If no attempt has yet been made to obtain the track's cues, the user agent will perform such an attempt momentarily.
7704
+ * The user agent is maintaining a list of which cues are active, and events are being fired accordingly.
7705
+ * In addition, for text tracks whose kind is subtitles or captions, the cues are being displayed over the video as appropriate;
7706
+ * for text tracks whose kind is descriptions, the user agent is making the cues available to the user in a non-visual fashion;
7707
+ * and for text tracks whose kind is chapters, the user agent is making available to the user a mechanism by which the user can navigate to any point in the media resource by selecting a cue.
7708
+ * The showing by default state is used in conjunction with the default attribute on track elements to indicate that the text track was enabled due to that attribute.
7709
+ * This allows the user agent to override the state if a later track is discovered that is more appropriate per the user's preferences.
7710
+ */
7711
+ vjs.TextTrack.prototype.show = function(){
7712
+ this.activate();
7713
+
7714
+ this.mode_ = 2;
7715
+
7716
+ // Show element.
7717
+ vjs.Component.prototype.show.call(this);
7718
+ };
7719
+
7720
+ /**
7721
+ * Hide: Mode Hidden (1)
7722
+ * Indicates that the text track is active, but that the user agent is not actively displaying the cues.
7723
+ * If no attempt has yet been made to obtain the track's cues, the user agent will perform such an attempt momentarily.
7724
+ * The user agent is maintaining a list of which cues are active, and events are being fired accordingly.
7725
+ */
7726
+ vjs.TextTrack.prototype.hide = function(){
7727
+ // When hidden, cues are still triggered. Disable to stop triggering.
7728
+ this.activate();
7729
+
7730
+ this.mode_ = 1;
7731
+
7732
+ // Hide element.
7733
+ vjs.Component.prototype.hide.call(this);
7734
+ };
7735
+
7736
+ /**
7737
+ * Disable: Mode Off/Disable (0)
7738
+ * Indicates that the text track is not active. Other than for the purposes of exposing the track in the DOM, the user agent is ignoring the text track.
7739
+ * No cues are active, no events are fired, and the user agent will not attempt to obtain the track's cues.
7740
+ */
7741
+ vjs.TextTrack.prototype.disable = function(){
7742
+ // If showing, hide.
7743
+ if (this.mode_ == 2) { this.hide(); }
7744
+
7745
+ // Stop triggering cues
7746
+ this.deactivate();
7747
+
7748
+ // Switch Mode to Off
7749
+ this.mode_ = 0;
7750
+ };
7751
+
7752
+ /**
7753
+ * Turn on cue tracking. Tracks that are showing OR hidden are active.
7754
+ */
7755
+ vjs.TextTrack.prototype.activate = function(){
7756
+ // Load text file if it hasn't been yet.
7757
+ if (this.readyState_ === 0) { this.load(); }
7758
+
7759
+ // Only activate if not already active.
7760
+ if (this.mode_ === 0) {
7761
+ // Update current cue on timeupdate
7762
+ // Using unique ID for bind function so other tracks don't remove listener
7763
+ this.player_.on('timeupdate', vjs.bind(this, this.update, this.id_));
7764
+
7765
+ // Reset cue time on media end
7766
+ this.player_.on('ended', vjs.bind(this, this.reset, this.id_));
7767
+
7768
+ // Add to display
7769
+ if (this.kind_ === 'captions' || this.kind_ === 'subtitles') {
7770
+ this.player_.getChild('textTrackDisplay').addChild(this);
7771
+ }
7772
+ }
7773
+ };
7774
+
7775
+ /**
7776
+ * Turn off cue tracking.
7777
+ */
7778
+ vjs.TextTrack.prototype.deactivate = function(){
7779
+ // Using unique ID for bind function so other tracks don't remove listener
7780
+ this.player_.off('timeupdate', vjs.bind(this, this.update, this.id_));
7781
+ this.player_.off('ended', vjs.bind(this, this.reset, this.id_));
7782
+ this.reset(); // Reset
7783
+
7784
+ // Remove from display
7785
+ this.player_.getChild('textTrackDisplay').removeChild(this);
7786
+ };
7787
+
7788
+ // A readiness state
7789
+ // One of the following:
7790
+ //
7791
+ // Not loaded
7792
+ // Indicates that the text track is known to exist (e.g. it has been declared with a track element), but its cues have not been obtained.
7793
+ //
7794
+ // Loading
7795
+ // Indicates that the text track is loading and there have been no fatal errors encountered so far. Further cues might still be added to the track.
7796
+ //
7797
+ // Loaded
7798
+ // Indicates that the text track has been loaded with no fatal errors. No new cues will be added to the track except if the text track corresponds to a MutableTextTrack object.
7799
+ //
7800
+ // Failed to load
7801
+ // Indicates that the text track was enabled, but when the user agent attempted to obtain it, this failed in some way (e.g. URL could not be resolved, network error, unknown text track format). Some or all of the cues are likely missing and will not be obtained.
7802
+ vjs.TextTrack.prototype.load = function(){
7803
+
7804
+ // Only load if not loaded yet.
7805
+ if (this.readyState_ === 0) {
7806
+ this.readyState_ = 1;
7807
+ vjs.get(this.src_, vjs.bind(this, this.parseCues), vjs.bind(this, this.onError));
7808
+ }
7809
+
7810
+ };
7811
+
7812
+ vjs.TextTrack.prototype.onError = function(err){
7813
+ this.error = err;
7814
+ this.readyState_ = 3;
7815
+ this.trigger('error');
7816
+ };
7817
+
7818
+ // Parse the WebVTT text format for cue times.
7819
+ // TODO: Separate parser into own class so alternative timed text formats can be used. (TTML, DFXP)
7820
+ vjs.TextTrack.prototype.parseCues = function(srcContent) {
7821
+ var cue, time, text,
7822
+ lines = srcContent.split('\n'),
7823
+ line = '', id;
7824
+
7825
+ for (var i=1, j=lines.length; i<j; i++) {
7826
+ // Line 0 should be 'WEBVTT', so skipping i=0
7827
+
7828
+ line = vjs.trim(lines[i]); // Trim whitespace and linebreaks
7829
+
7830
+ if (line) { // Loop until a line with content
7831
+
7832
+ // First line could be an optional cue ID
7833
+ // Check if line has the time separator
7834
+ if (line.indexOf('-->') == -1) {
7835
+ id = line;
7836
+ // Advance to next line for timing.
7837
+ line = vjs.trim(lines[++i]);
7838
+ } else {
7839
+ id = this.cues_.length;
7840
+ }
7841
+
7842
+ // First line - Number
7843
+ cue = {
7844
+ id: id, // Cue Number
7845
+ index: this.cues_.length // Position in Array
7846
+ };
7847
+
7848
+ // Timing line
7849
+ time = line.split(/[\t ]+/);
7850
+ cue.startTime = this.parseCueTime(time[0]);
7851
+ cue.endTime = this.parseCueTime(time[2]);
7852
+
7853
+ // Additional lines - Cue Text
7854
+ text = [];
7855
+
7856
+ // Loop until a blank line or end of lines
7857
+ // Assumeing trim('') returns false for blank lines
7858
+ while (lines[++i] && (line = vjs.trim(lines[i]))) {
7859
+ text.push(line);
7860
+ }
7861
+
7862
+ cue.text = text.join('<br/>');
7863
+
7864
+ // Add this cue
7865
+ this.cues_.push(cue);
7866
+ }
7867
+ }
7868
+
7869
+ this.readyState_ = 2;
7870
+ this.trigger('loaded');
7871
+ };
7872
+
7873
+
7874
+ vjs.TextTrack.prototype.parseCueTime = function(timeText) {
7875
+ var parts = timeText.split(':'),
7876
+ time = 0,
7877
+ hours, minutes, other, seconds, ms;
7878
+
7879
+ // Check if optional hours place is included
7880
+ // 00:00:00.000 vs. 00:00.000
7881
+ if (parts.length == 3) {
7882
+ hours = parts[0];
7883
+ minutes = parts[1];
7884
+ other = parts[2];
7885
+ } else {
7886
+ hours = 0;
7887
+ minutes = parts[0];
7888
+ other = parts[1];
7889
+ }
7890
+
7891
+ // Break other (seconds, milliseconds, and flags) by spaces
7892
+ // TODO: Make additional cue layout settings work with flags
7893
+ other = other.split(/\s+/);
7894
+ // Remove seconds. Seconds is the first part before any spaces.
7895
+ seconds = other.splice(0,1)[0];
7896
+ // Could use either . or , for decimal
7897
+ seconds = seconds.split(/\.|,/);
7898
+ // Get milliseconds
7899
+ ms = parseFloat(seconds[1]);
7900
+ seconds = seconds[0];
7901
+
7902
+ // hours => seconds
7903
+ time += parseFloat(hours) * 3600;
7904
+ // minutes => seconds
7905
+ time += parseFloat(minutes) * 60;
7906
+ // Add seconds
7907
+ time += parseFloat(seconds);
7908
+ // Add milliseconds
7909
+ if (ms) { time += ms/1000; }
7910
+
7911
+ return time;
7912
+ };
7913
+
7914
+ // Update active cues whenever timeupdate events are triggered on the player.
7915
+ vjs.TextTrack.prototype.update = function(){
7916
+ if (this.cues_.length > 0) {
7917
+
7918
+ // Get current player time, adjust for track offset
7919
+ var offset = this.player_.options()['trackTimeOffset'] || 0;
7920
+ var time = this.player_.currentTime() + offset;
7921
+
7922
+ // Check if the new time is outside the time box created by the the last update.
7923
+ if (this.prevChange === undefined || time < this.prevChange || this.nextChange <= time) {
7924
+ var cues = this.cues_,
7925
+
7926
+ // Create a new time box for this state.
7927
+ newNextChange = this.player_.duration(), // Start at beginning of the timeline
7928
+ newPrevChange = 0, // Start at end
7929
+
7930
+ reverse = false, // Set the direction of the loop through the cues. Optimized the cue check.
7931
+ newCues = [], // Store new active cues.
7932
+
7933
+ // Store where in the loop the current active cues are, to provide a smart starting point for the next loop.
7934
+ firstActiveIndex, lastActiveIndex,
7935
+ cue, i; // Loop vars
7936
+
7937
+ // Check if time is going forwards or backwards (scrubbing/rewinding)
7938
+ // If we know the direction we can optimize the starting position and direction of the loop through the cues array.
7939
+ if (time >= this.nextChange || this.nextChange === undefined) { // NextChange should happen
7940
+ // Forwards, so start at the index of the first active cue and loop forward
7941
+ i = (this.firstActiveIndex !== undefined) ? this.firstActiveIndex : 0;
7942
+ } else {
7943
+ // Backwards, so start at the index of the last active cue and loop backward
7944
+ reverse = true;
7945
+ i = (this.lastActiveIndex !== undefined) ? this.lastActiveIndex : cues.length - 1;
7946
+ }
7947
+
7948
+ while (true) { // Loop until broken
7949
+ cue = cues[i];
7950
+
7951
+ // Cue ended at this point
7952
+ if (cue.endTime <= time) {
7953
+ newPrevChange = Math.max(newPrevChange, cue.endTime);
7954
+
7955
+ if (cue.active) {
7956
+ cue.active = false;
7957
+ }
7958
+
7959
+ // No earlier cues should have an active start time.
7960
+ // Nevermind. Assume first cue could have a duration the same as the video.
7961
+ // In that case we need to loop all the way back to the beginning.
7962
+ // if (reverse && cue.startTime) { break; }
7963
+
7964
+ // Cue hasn't started
7965
+ } else if (time < cue.startTime) {
7966
+ newNextChange = Math.min(newNextChange, cue.startTime);
7967
+
7968
+ if (cue.active) {
7969
+ cue.active = false;
7970
+ }
7971
+
7972
+ // No later cues should have an active start time.
7973
+ if (!reverse) { break; }
7974
+
7975
+ // Cue is current
7976
+ } else {
7977
+
7978
+ if (reverse) {
7979
+ // Add cue to front of array to keep in time order
7980
+ newCues.splice(0,0,cue);
7981
+
7982
+ // If in reverse, the first current cue is our lastActiveCue
7983
+ if (lastActiveIndex === undefined) { lastActiveIndex = i; }
7984
+ firstActiveIndex = i;
7985
+ } else {
7986
+ // Add cue to end of array
7987
+ newCues.push(cue);
7988
+
7989
+ // If forward, the first current cue is our firstActiveIndex
7990
+ if (firstActiveIndex === undefined) { firstActiveIndex = i; }
7991
+ lastActiveIndex = i;
7992
+ }
7993
+
7994
+ newNextChange = Math.min(newNextChange, cue.endTime);
7995
+ newPrevChange = Math.max(newPrevChange, cue.startTime);
7996
+
7997
+ cue.active = true;
7998
+ }
7999
+
8000
+ if (reverse) {
8001
+ // Reverse down the array of cues, break if at first
8002
+ if (i === 0) { break; } else { i--; }
8003
+ } else {
8004
+ // Walk up the array fo cues, break if at last
8005
+ if (i === cues.length - 1) { break; } else { i++; }
8006
+ }
8007
+
8008
+ }
8009
+
8010
+ this.activeCues_ = newCues;
8011
+ this.nextChange = newNextChange;
8012
+ this.prevChange = newPrevChange;
8013
+ this.firstActiveIndex = firstActiveIndex;
8014
+ this.lastActiveIndex = lastActiveIndex;
8015
+
8016
+ this.updateDisplay();
8017
+
8018
+ this.trigger('cuechange');
8019
+ }
8020
+ }
8021
+ };
8022
+
8023
+ // Add cue HTML to display
8024
+ vjs.TextTrack.prototype.updateDisplay = function(){
8025
+ var cues = this.activeCues_,
8026
+ html = '',
8027
+ i=0,j=cues.length;
8028
+
8029
+ for (;i<j;i++) {
8030
+ html += '<span class="vjs-tt-cue">'+cues[i].text+'</span>';
8031
+ }
8032
+
8033
+ this.el_.innerHTML = html;
8034
+ };
8035
+
8036
+ // Set all loop helper values back
8037
+ vjs.TextTrack.prototype.reset = function(){
8038
+ this.nextChange = 0;
8039
+ this.prevChange = this.player_.duration();
8040
+ this.firstActiveIndex = 0;
8041
+ this.lastActiveIndex = 0;
8042
+ };
8043
+
8044
+ // Create specific track types
8045
+ /**
8046
+ * The track component for managing the hiding and showing of captions
8047
+ *
8048
+ * @constructor
8049
+ */
8050
+ vjs.CaptionsTrack = vjs.TextTrack.extend();
8051
+ vjs.CaptionsTrack.prototype.kind_ = 'captions';
8052
+ // Exporting here because Track creation requires the track kind
8053
+ // to be available on global object. e.g. new window['videojs'][Kind + 'Track']
8054
+
8055
+ /**
8056
+ * The track component for managing the hiding and showing of subtitles
8057
+ *
8058
+ * @constructor
8059
+ */
8060
+ vjs.SubtitlesTrack = vjs.TextTrack.extend();
8061
+ vjs.SubtitlesTrack.prototype.kind_ = 'subtitles';
8062
+
8063
+ /**
8064
+ * The track component for managing the hiding and showing of chapters
8065
+ *
8066
+ * @constructor
8067
+ */
8068
+ vjs.ChaptersTrack = vjs.TextTrack.extend();
8069
+ vjs.ChaptersTrack.prototype.kind_ = 'chapters';
8070
+
8071
+
8072
+ /* Text Track Display
8073
+ ============================================================================= */
8074
+ // Global container for both subtitle and captions text. Simple div container.
8075
+
8076
+ /**
8077
+ * The component for displaying text track cues
8078
+ *
8079
+ * @constructor
8080
+ */
8081
+ vjs.TextTrackDisplay = vjs.Component.extend({
8082
+ /** @constructor */
8083
+ init: function(player, options, ready){
8084
+ vjs.Component.call(this, player, options, ready);
8085
+
8086
+ // This used to be called during player init, but was causing an error
8087
+ // if a track should show by default and the display hadn't loaded yet.
8088
+ // Should probably be moved to an external track loader when we support
8089
+ // tracks that don't need a display.
8090
+ if (player.options_['tracks'] && player.options_['tracks'].length > 0) {
8091
+ this.player_.addTextTracks(player.options_['tracks']);
8092
+ }
8093
+ }
8094
+ });
8095
+
8096
+ vjs.TextTrackDisplay.prototype.createEl = function(){
8097
+ return vjs.Component.prototype.createEl.call(this, 'div', {
8098
+ className: 'vjs-text-track-display'
8099
+ });
8100
+ };
8101
+
8102
+
8103
+ /**
8104
+ * The specific menu item type for selecting a language within a text track kind
8105
+ *
8106
+ * @constructor
8107
+ */
8108
+ vjs.TextTrackMenuItem = vjs.MenuItem.extend({
8109
+ /** @constructor */
8110
+ init: function(player, options){
8111
+ var track = this.track = options['track'];
8112
+
8113
+ // Modify options for parent MenuItem class's init.
8114
+ options['label'] = track.label();
8115
+ options['selected'] = track.dflt();
8116
+ vjs.MenuItem.call(this, player, options);
8117
+
8118
+ this.on(player, track.kind() + 'trackchange', this.update);
8119
+ }
8120
+ });
8121
+
8122
+ vjs.TextTrackMenuItem.prototype.onClick = function(){
8123
+ vjs.MenuItem.prototype.onClick.call(this);
8124
+ this.player_.showTextTrack(this.track.id_, this.track.kind());
8125
+ };
8126
+
8127
+ vjs.TextTrackMenuItem.prototype.update = function(){
8128
+ this.selected(this.track.mode() == 2);
8129
+ };
8130
+
8131
+ /**
8132
+ * A special menu item for turning of a specific type of text track
8133
+ *
8134
+ * @constructor
8135
+ */
8136
+ vjs.OffTextTrackMenuItem = vjs.TextTrackMenuItem.extend({
8137
+ /** @constructor */
8138
+ init: function(player, options){
8139
+ // Create pseudo track info
8140
+ // Requires options['kind']
8141
+ options['track'] = {
8142
+ kind: function() { return options['kind']; },
8143
+ player: player,
8144
+ label: function(){ return options['kind'] + ' off'; },
8145
+ dflt: function(){ return false; },
8146
+ mode: function(){ return false; }
8147
+ };
8148
+ vjs.TextTrackMenuItem.call(this, player, options);
8149
+ this.selected(true);
8150
+ }
8151
+ });
8152
+
8153
+ vjs.OffTextTrackMenuItem.prototype.onClick = function(){
8154
+ vjs.TextTrackMenuItem.prototype.onClick.call(this);
8155
+ this.player_.showTextTrack(this.track.id_, this.track.kind());
8156
+ };
8157
+
8158
+ vjs.OffTextTrackMenuItem.prototype.update = function(){
8159
+ var tracks = this.player_.textTracks(),
8160
+ i=0, j=tracks.length, track,
8161
+ off = true;
8162
+
8163
+ for (;i<j;i++) {
8164
+ track = tracks[i];
8165
+ if (track.kind() == this.track.kind() && track.mode() == 2) {
8166
+ off = false;
8167
+ }
8168
+ }
8169
+
8170
+ this.selected(off);
8171
+ };
8172
+
8173
+ /**
8174
+ * The base class for buttons that toggle specific text track types (e.g. subtitles)
8175
+ *
8176
+ * @constructor
8177
+ */
8178
+ vjs.TextTrackButton = vjs.MenuButton.extend({
8179
+ /** @constructor */
8180
+ init: function(player, options){
8181
+ vjs.MenuButton.call(this, player, options);
8182
+
8183
+ if (this.items.length <= 1) {
8184
+ this.hide();
8185
+ }
8186
+ }
8187
+ });
8188
+
8189
+ // vjs.TextTrackButton.prototype.buttonPressed = false;
8190
+
8191
+ // vjs.TextTrackButton.prototype.createMenu = function(){
8192
+ // var menu = new vjs.Menu(this.player_);
8193
+
8194
+ // // Add a title list item to the top
8195
+ // // menu.el().appendChild(vjs.createEl('li', {
8196
+ // // className: 'vjs-menu-title',
8197
+ // // innerHTML: vjs.capitalize(this.kind_),
8198
+ // // tabindex: -1
8199
+ // // }));
8200
+
8201
+ // this.items = this.createItems();
8202
+
8203
+ // // Add menu items to the menu
8204
+ // for (var i = 0; i < this.items.length; i++) {
8205
+ // menu.addItem(this.items[i]);
8206
+ // }
8207
+
8208
+ // // Add list to element
8209
+ // this.addChild(menu);
8210
+
8211
+ // return menu;
8212
+ // };
8213
+
8214
+ // Create a menu item for each text track
8215
+ vjs.TextTrackButton.prototype.createItems = function(){
8216
+ var items = [], track;
8217
+
8218
+ // Add an OFF menu item to turn all tracks off
8219
+ items.push(new vjs.OffTextTrackMenuItem(this.player_, { 'kind': this.kind_ }));
8220
+
8221
+ for (var i = 0; i < this.player_.textTracks().length; i++) {
8222
+ track = this.player_.textTracks()[i];
8223
+ if (track.kind() === this.kind_) {
8224
+ items.push(new vjs.TextTrackMenuItem(this.player_, {
8225
+ 'track': track
8226
+ }));
8227
+ }
8228
+ }
8229
+
8230
+ return items;
8231
+ };
8232
+
8233
+ /**
8234
+ * The button component for toggling and selecting captions
8235
+ *
8236
+ * @constructor
8237
+ */
8238
+ vjs.CaptionsButton = vjs.TextTrackButton.extend({
8239
+ /** @constructor */
8240
+ init: function(player, options, ready){
8241
+ vjs.TextTrackButton.call(this, player, options, ready);
8242
+ this.el_.setAttribute('aria-label','Captions Menu');
8243
+ }
8244
+ });
8245
+ vjs.CaptionsButton.prototype.kind_ = 'captions';
8246
+ vjs.CaptionsButton.prototype.buttonText = 'Captions';
8247
+ vjs.CaptionsButton.prototype.className = 'vjs-captions-button';
8248
+
8249
+ /**
8250
+ * The button component for toggling and selecting subtitles
8251
+ *
8252
+ * @constructor
8253
+ */
8254
+ vjs.SubtitlesButton = vjs.TextTrackButton.extend({
8255
+ /** @constructor */
8256
+ init: function(player, options, ready){
8257
+ vjs.TextTrackButton.call(this, player, options, ready);
8258
+ this.el_.setAttribute('aria-label','Subtitles Menu');
8259
+ }
8260
+ });
8261
+ vjs.SubtitlesButton.prototype.kind_ = 'subtitles';
8262
+ vjs.SubtitlesButton.prototype.buttonText = 'Subtitles';
8263
+ vjs.SubtitlesButton.prototype.className = 'vjs-subtitles-button';
8264
+
8265
+ // Chapters act much differently than other text tracks
8266
+ // Cues are navigation vs. other tracks of alternative languages
8267
+ /**
8268
+ * The button component for toggling and selecting chapters
8269
+ *
8270
+ * @constructor
8271
+ */
8272
+ vjs.ChaptersButton = vjs.TextTrackButton.extend({
8273
+ /** @constructor */
8274
+ init: function(player, options, ready){
8275
+ vjs.TextTrackButton.call(this, player, options, ready);
8276
+ this.el_.setAttribute('aria-label','Chapters Menu');
8277
+ }
8278
+ });
8279
+ vjs.ChaptersButton.prototype.kind_ = 'chapters';
8280
+ vjs.ChaptersButton.prototype.buttonText = 'Chapters';
8281
+ vjs.ChaptersButton.prototype.className = 'vjs-chapters-button';
8282
+
8283
+ // Create a menu item for each text track
8284
+ vjs.ChaptersButton.prototype.createItems = function(){
8285
+ var items = [], track;
8286
+
8287
+ for (var i = 0; i < this.player_.textTracks().length; i++) {
8288
+ track = this.player_.textTracks()[i];
8289
+ if (track.kind() === this.kind_) {
8290
+ items.push(new vjs.TextTrackMenuItem(this.player_, {
8291
+ 'track': track
8292
+ }));
8293
+ }
8294
+ }
8295
+
8296
+ return items;
8297
+ };
8298
+
8299
+ vjs.ChaptersButton.prototype.createMenu = function(){
8300
+ var tracks = this.player_.textTracks(),
8301
+ i = 0,
8302
+ j = tracks.length,
8303
+ track, chaptersTrack,
8304
+ items = this.items = [];
8305
+
8306
+ for (;i<j;i++) {
8307
+ track = tracks[i];
8308
+ if (track.kind() == this.kind_) {
8309
+ if (track.readyState() === 0) {
8310
+ track.load();
8311
+ track.on('loaded', vjs.bind(this, this.createMenu));
8312
+ } else {
8313
+ chaptersTrack = track;
8314
+ break;
8315
+ }
8316
+ }
8317
+ }
8318
+
8319
+ var menu = this.menu;
8320
+ if (menu === undefined) {
8321
+ menu = new vjs.Menu(this.player_);
8322
+ menu.contentEl().appendChild(vjs.createEl('li', {
8323
+ className: 'vjs-menu-title',
8324
+ innerHTML: vjs.capitalize(this.kind_),
8325
+ tabindex: -1
8326
+ }));
8327
+ }
8328
+
8329
+ if (chaptersTrack) {
8330
+ var cues = chaptersTrack.cues_, cue, mi;
8331
+ i = 0;
8332
+ j = cues.length;
8333
+
8334
+ for (;i<j;i++) {
8335
+ cue = cues[i];
8336
+
8337
+ mi = new vjs.ChaptersTrackMenuItem(this.player_, {
8338
+ 'track': chaptersTrack,
8339
+ 'cue': cue
8340
+ });
8341
+
8342
+ items.push(mi);
8343
+
8344
+ menu.addChild(mi);
8345
+ }
8346
+ this.addChild(menu);
8347
+ }
8348
+
8349
+ if (this.items.length > 0) {
8350
+ this.show();
8351
+ }
8352
+
8353
+ return menu;
8354
+ };
8355
+
8356
+
8357
+ /**
8358
+ * @constructor
8359
+ */
8360
+ vjs.ChaptersTrackMenuItem = vjs.MenuItem.extend({
8361
+ /** @constructor */
8362
+ init: function(player, options){
8363
+ var track = this.track = options['track'],
8364
+ cue = this.cue = options['cue'],
8365
+ currentTime = player.currentTime();
8366
+
8367
+ // Modify options for parent MenuItem class's init.
8368
+ options['label'] = cue.text;
8369
+ options['selected'] = (cue.startTime <= currentTime && currentTime < cue.endTime);
8370
+ vjs.MenuItem.call(this, player, options);
8371
+
8372
+ track.on('cuechange', vjs.bind(this, this.update));
8373
+ }
8374
+ });
8375
+
8376
+ vjs.ChaptersTrackMenuItem.prototype.onClick = function(){
8377
+ vjs.MenuItem.prototype.onClick.call(this);
8378
+ this.player_.currentTime(this.cue.startTime);
8379
+ this.update(this.cue.startTime);
8380
+ };
8381
+
8382
+ vjs.ChaptersTrackMenuItem.prototype.update = function(){
8383
+ var cue = this.cue,
8384
+ currentTime = this.player_.currentTime();
8385
+
8386
+ // vjs.log(currentTime, cue.startTime);
8387
+ this.selected(cue.startTime <= currentTime && currentTime < cue.endTime);
8388
+ };
8389
+
8390
+ // Add Buttons to controlBar
8391
+ vjs.obj.merge(vjs.ControlBar.prototype.options_['children'], {
8392
+ 'subtitlesButton': {},
8393
+ 'captionsButton': {},
8394
+ 'chaptersButton': {}
8395
+ });
8396
+
8397
+ // vjs.Cue = vjs.Component.extend({
8398
+ // /** @constructor */
8399
+ // init: function(player, options){
8400
+ // vjs.Component.call(this, player, options);
8401
+ // }
8402
+ // });
8403
+ /**
8404
+ * @fileoverview Add JSON support
8405
+ * @suppress {undefinedVars}
8406
+ * (Compiler doesn't like JSON not being declared)
8407
+ */
8408
+
8409
+ /**
8410
+ * Javascript JSON implementation
8411
+ * (Parse Method Only)
8412
+ * https://github.com/douglascrockford/JSON-js/blob/master/json2.js
8413
+ * Only using for parse method when parsing data-setup attribute JSON.
8414
+ * @suppress {undefinedVars}
8415
+ * @namespace
8416
+ * @private
8417
+ */
8418
+ vjs.JSON;
8419
+
8420
+ if (typeof window.JSON !== 'undefined' && typeof window.JSON.parse === 'function') {
8421
+ vjs.JSON = window.JSON;
8422
+
8423
+ } else {
8424
+ vjs.JSON = {};
8425
+
8426
+ var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
8427
+
8428
+ /**
8429
+ * parse the json
8430
+ *
8431
+ * @memberof vjs.JSON
8432
+ * @param {String} text The JSON string to parse
8433
+ * @param {Function=} [reviver] Optional function that can transform the results
8434
+ * @return {Object|Array} The parsed JSON
8435
+ */
8436
+ vjs.JSON.parse = function (text, reviver) {
8437
+ var j;
8438
+
8439
+ function walk(holder, key) {
8440
+ var k, v, value = holder[key];
8441
+ if (value && typeof value === 'object') {
8442
+ for (k in value) {
8443
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
8444
+ v = walk(value, k);
8445
+ if (v !== undefined) {
8446
+ value[k] = v;
8447
+ } else {
8448
+ delete value[k];
8449
+ }
8450
+ }
8451
+ }
8452
+ }
8453
+ return reviver.call(holder, key, value);
8454
+ }
8455
+ text = String(text);
8456
+ cx.lastIndex = 0;
8457
+ if (cx.test(text)) {
8458
+ text = text.replace(cx, function (a) {
8459
+ return '\\u' +
8460
+ ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
8461
+ });
8462
+ }
8463
+
8464
+ if (/^[\],:{}\s]*$/
8465
+ .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
8466
+ .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
8467
+ .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
8468
+
8469
+ j = eval('(' + text + ')');
8470
+
8471
+ return typeof reviver === 'function' ?
8472
+ walk({'': j}, '') : j;
8473
+ }
8474
+
8475
+ throw new SyntaxError('JSON.parse(): invalid or malformed JSON data');
8476
+ };
8477
+ }
8478
+ /**
8479
+ * @fileoverview Functions for automatically setting up a player
8480
+ * based on the data-setup attribute of the video tag
8481
+ */
8482
+
8483
+ // Automatically set up any tags that have a data-setup attribute
8484
+ vjs.autoSetup = function(){
8485
+ var options, mediaEl, player, i, e;
8486
+
8487
+ // One day, when we stop supporting IE8, go back to this, but in the meantime...*hack hack hack*
8488
+ // var vids = Array.prototype.slice.call(document.getElementsByTagName('video'));
8489
+ // var audios = Array.prototype.slice.call(document.getElementsByTagName('audio'));
8490
+ // var mediaEls = vids.concat(audios);
8491
+
8492
+ // Because IE8 doesn't support calling slice on a node list, we need to loop through each list of elements
8493
+ // to build up a new, combined list of elements.
8494
+ var vids = document.getElementsByTagName('video');
8495
+ var audios = document.getElementsByTagName('audio');
8496
+ var mediaEls = [];
8497
+ if (vids && vids.length > 0) {
8498
+ for(i=0, e=vids.length; i<e; i++) {
8499
+ mediaEls.push(vids[i]);
8500
+ }
8501
+ }
8502
+ if (audios && audios.length > 0) {
8503
+ for(i=0, e=audios.length; i<e; i++) {
8504
+ mediaEls.push(audios[i]);
8505
+ }
8506
+ }
8507
+
8508
+ // Check if any media elements exist
8509
+ if (mediaEls && mediaEls.length > 0) {
8510
+
8511
+ for (i=0,e=mediaEls.length; i<e; i++) {
8512
+ mediaEl = mediaEls[i];
8513
+
8514
+ // Check if element exists, has getAttribute func.
8515
+ // IE seems to consider typeof el.getAttribute == 'object' instead of 'function' like expected, at least when loading the player immediately.
8516
+ if (mediaEl && mediaEl.getAttribute) {
8517
+
8518
+ // Make sure this player hasn't already been set up.
8519
+ if (mediaEl['player'] === undefined) {
8520
+ options = mediaEl.getAttribute('data-setup');
8521
+
8522
+ // Check if data-setup attr exists.
8523
+ // We only auto-setup if they've added the data-setup attr.
8524
+ if (options !== null) {
8525
+ // Create new video.js instance.
8526
+ player = videojs(mediaEl);
8527
+ }
8528
+ }
8529
+
8530
+ // If getAttribute isn't defined, we need to wait for the DOM.
8531
+ } else {
8532
+ vjs.autoSetupTimeout(1);
8533
+ break;
8534
+ }
8535
+ }
8536
+
8537
+ // No videos were found, so keep looping unless page is finished loading.
8538
+ } else if (!vjs.windowLoaded) {
8539
+ vjs.autoSetupTimeout(1);
8540
+ }
8541
+ };
8542
+
8543
+ // Pause to let the DOM keep processing
8544
+ vjs.autoSetupTimeout = function(wait){
8545
+ setTimeout(vjs.autoSetup, wait);
8546
+ };
8547
+
8548
+ if (document.readyState === 'complete') {
8549
+ vjs.windowLoaded = true;
8550
+ } else {
8551
+ vjs.one(window, 'load', function(){
8552
+ vjs.windowLoaded = true;
8553
+ });
8554
+ }
8555
+
8556
+ // Run Auto-load players
8557
+ // You have to wait at least once in case this script is loaded after your video in the DOM (weird behavior only with minified version)
8558
+ vjs.autoSetupTimeout(1);
8559
+ /**
8560
+ * the method for registering a video.js plugin
8561
+ *
8562
+ * @param {String} name The name of the plugin
8563
+ * @param {Function} init The function that is run when the player inits
8564
+ */
8565
+ vjs.plugin = function(name, init){
8566
+ vjs.Player.prototype[name] = init;
8567
+ };
media/clipvilla/videos/clipvillalogo.png ADDED
Binary file
package.xml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>ClipVilla_Video_Producer</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.gnu.org/licenses/quick-guide-gplv3.html.en">GNU General Public License (GPLv3)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>This extension is built to create and publish product videos from the images stored inside the product catalog.</summary>
10
+ <description>- video production via videotemplates&#xD;
11
+ - video can be produced&#xD;
12
+ - via mass action inside the product catalog&#xD;
13
+ - individually on product detail level&#xD;
14
+ - managing of videos via Catalog / Manage videos&#xD;
15
+ - videos will by default be displayed on the appropriate product page within an integrated HTML5 player &#xD;
16
+ - videos will by default be stored inside the media library&#xD;
17
+ - three lines of custom text per video can either be set globally (System/Configuration/ClipVilla/Video Producer) or individually for each product (product detail page)&#xD;
18
+ - creation of video sitemap&#xD;
19
+ - for the video production the video contents will be sent to ClipVilla render clients via API. Via FTP the finished videos will be transferred back the Magento store. The entire process is run by a 1-minute cronjob.&#xD;
20
+ - Compatible with Magento Community 1.7.x and higher&#xD;
21
+ &#xD;
22
+ A three minute user guide video can be seen here: http://videoproducer.clipvilla.com/#Howto&#xD;
23
+ </description>
24
+ <notes>initial release&#xD;
25
+ &#xD;
26
+ license key is required for video rendering &#xD;
27
+ (key: test)&#xD;
28
+ &#xD;
29
+ The video rendering process is run by a 1-minute cronjob.&#xD;
30
+ &#xD;
31
+ Compatible with Magento Community 1.7.x and higher</notes>
32
+ <authors><author><name>Jens Neumann</name><user>ClipVilla</user><email>sales@clipvilla.de</email></author></authors>
33
+ <date>2014-12-02</date>
34
+ <time>11:08:34</time>
35
+ <contents><target name="magecommunity"><dir name="ClipVilla"><dir name="MorI"><dir name="Block"><dir name="Adminhtml"><file name="Info.php" hash="11a9ab957bd9af56ae251dc945dbf3f7"/><dir name="ManageVideos"><file name="Grid.php" hash="93bfe2440cc536531526830ff2175a89"/><file name="Popup.php" hash="eb4f3e57c4259cc4aa4f72900eaca2c5"/><dir name="Renderer"><file name="Popup.php" hash="79c2b58afefe0156d515a75c3871bab2"/><file name="Status.php" hash="d5777204eaba4771e748ab82919ff8ad"/><file name="TemplateName.php" hash="98a967e4a0acdc0d3faea263048c309e"/></dir></dir><file name="ManageVideos.php" hash="6f3f816e54806d1de9fc9d1609a62a64"/><file name="Notifications.php" hash="3568e554b60f0e7778531c09812bcec0"/></dir><file name="Videos.php" hash="f387bfc9fa7a7fa5ce60c4b535cf81bf"/></dir><dir name="Helper"><file name="Data.php" hash="7e891ee7e40302da18e12badeb34fada"/><file name="Path.php" hash="eca3738f9a85e0e4155669a1a8ba1125"/></dir><dir name="Model"><dir name="Executer"><file name="Mori.php" hash="8d84c2568f424599e4421e49e3de15c0"/></dir><file name="File.php" hash="a0f923e1c18ad99f2c52c5139b25355a"/><file name="Indexer.php" hash="4e433ef08c72723fe4716c5b8134d329"/><file name="Mail.php" hash="3ddc3d6c3bfb53bf4e374da84e6180c4"/><dir name="Observer"><file name="DefaultValues.php" hash="2015887e0a0522c036957eab24d0fb99"/><file name="MassAction.php" hash="52c8c50369ec39a0fe875e0ef7191a62"/><file name="ProductEditForm.php" hash="c81f34c776c8690d4f2d3c2cba84e09f"/><file name="VideoData.php" hash="7053a67170887e10244bf722410d6396"/></dir><dir name="Resource"><dir name="Stack"><file name="Collection.php" hash="49f4f482f216822d06eb240b6e2549c2"/></dir><file name="Stack.php" hash="26843f9a7dc4a97dd9343bcda6c52dec"/><dir name="Videos"><file name="Collection.php" hash="e7026670ce5e228f9465a9931209164d"/></dir><file name="Videos.php" hash="544d4daffa2673042d2bf1a44042608c"/></dir><dir name="Sitemap"><file name="Video.php" hash="d5b4aada440d3b732592304232c45d4c"/></dir><file name="Stack.php" hash="e3be25e698b6c03bc4da961a9ec38710"/><dir name="System"><dir name="Attribute"><dir name="Source"><file name="Provider.php" hash="eca6a4d1138eebab2322abe44be051ba"/></dir></dir><dir name="Config"><dir name="Source"><file name="TemplateSelect.php" hash="f0e6337d9aac5fcef9b64fa88a167fba"/></dir></dir></dir><file name="VideoCron.php" hash="b1ddf0c49abf0075ec33ce0be24faf28"/><file name="Videos.php" hash="5222e27c5194bce5808305c94175f0dd"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ManageVideosController.php" hash="22ca1253720cc21a9ca0a6e5c97bc32c"/><file name="VideoController.php" hash="f4960f316ca4c6e68d3a9be2297d0bb4"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="25bee954b42943d1717337bd1b3dadb0"/><file name="config.xml" hash="8c225b02edb1dd5e73a0386b46549145"/><file name="mapping.xml" hash="13dfe4dcd8ac3c317608920a4c5d4d6f"/><file name="system.xml" hash="ce0c307a5dfadc4662e1ca4463981870"/></dir><dir name="sql"><dir name="clipvilla_mori_setup"><file name="install-0.1.0.php" hash="f4dbc3569ef52f5ce699b31ad363844b"/><file name="upgrade-0.1.0-0.2.0.php" hash="8b7455e17037e34a5262a50bf943f05e"/><file name="upgrade-0.2.0-0.3.0.php" hash="1f2ede694d1c6dc45f7b449cca933a86"/><file name="upgrade-0.3.0-1.0.0.php" hash="af1aefba7c9f93f21df70373f554e4ca"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="ClipVilla_MorI.xml" hash="d74c4a55b43b9f0d1858502516bc70dd"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="clipvilla.xml" hash="e5a53b3cc2f354dac840afeac3004073"/></dir><dir name="template"><dir name="clipvilla"><file name="information.phtml" hash="5b8ee74aa47867dae65b4e772e9b5abe"/><file name="notifications.phtml" hash="c9e7de78d27d87e5807b491167a9bd1b"/><file name="popup.phtml" hash="8faba37c154ce9268d167e6b6bdc61a9"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="clipvilla.xml" hash="6c97edc988b4bdc7004272e7e7928783"/></dir><dir name="template"><dir name="clipvilla"><file name="videos.phtml" hash="07adcbe51b0ee4d0e9aa35e3e46600d4"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><file name="clipvilla.html" hash="5cd448e6d7b204c4bb90045dc010908e"/></dir></dir></dir></target><target name="magemedia"><dir name="clipvilla"><dir name="videos"><file name="clipvillalogo.png" hash="fb17314a8aec4137d5c51e30e8b01e78"/></dir></dir></target><target name="mage"><dir name="js"><dir name="clipvilla"><file name="popup.js" hash="4a9b4041fb717a2dbe0b62d0446806df"/><dir name="video-js"><dir name="font"><file name="vjs.eot" hash="062f06670a3b82ffb0732701c9d1e098"/><file name="vjs.svg" hash="17371a8f614b03b01b31a94d43cab2c4"/><file name="vjs.ttf" hash="0bfbb17e6e700d4815bc405d9fb8d65a"/><file name="vjs.woff" hash="6f37d5f587a44bff46a3d73546f20885"/></dir><dir name="lang"><file name="de.js" hash="fb573755ec207bc7df3b58c834f5bd93"/><file name="es.js" hash="49e8045c13c15e43c83e4c4f7bc7fe8e"/><file name="fr.js" hash="d09213dfb6fc6299ef7e72f0a9488a04"/><file name="it.js" hash="3534a7f02ad8478d544005f1bca4d882"/><file name="ja.js" hash="4b63ef305a1949c79bd3182fb08c455d"/><file name="ko.js" hash="9902b8850949bada295bea73797ac8c4"/><file name="nl.js" hash="84bc9ffa48d885823dd78337c3f708db"/><file name="pt-BR.js" hash="a8cd33f9584d240fba77c670a89e1c18"/><file name="ru.js" hash="0fbad4dd107ec5ea6efebaac905d41d7"/><file name="uk.js" hash="29787f2a551f5faa311643229eab69ef"/></dir><file name="video-js.css" hash="e1d509edbea396a1d429b59526916fc4"/><file name="video.js" hash="e28ac0edecccb3f12fdfa0a65baf21e3"/></dir></dir></dir></target></contents>
36
+ <compatible/>
37
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
38
+ </package>