forked from wgcowan/VideoStream
/
VideoStreamPlugin.php
710 lines (655 loc) · 26.7 KB
/
VideoStreamPlugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
<?php
if (!defined('VIDEOSTREAM_PLUGIN_DIR')) {
define('VIDEOSTREAM_PLUGIN_DIR', dirname(__FILE__));
}
//add_plugin_hook('public_head', 'jwplayer_public_head');
//add_plugin_hook('admin_head', 'jwplayer_admin_head');
require_once VIDEOSTREAM_PLUGIN_DIR . '/VideoStreamPlugin.php';
//require_once VIDEOSTREAM_PLUGIN_DIR . '/functions.php';
//$videostreamPlugin = new VideoStreamPlugin;
//$videostreamPlugin->setUp();
class VideoStreamPlugin extends Omeka_Plugin_AbstractPlugin
{
const DEFAULT_VIEWER_WIDTH = 640;
const DEFAULT_VIEWER_HEIGHT = 480;
const DEFAULT_VIEWER_CONTROL = 0;
const DEFAULT_VIEWER_DISPLAY = 0;
const DEFAULT_VIEWER_SKIN = 'basic';
const DEFAULT_VIEWER_FLASH = 0;
const DEFAULT_VIEWER_HTTP = 0;
const DEFAULT_VIEWER_HLS = 0;
const DEFAULT_VIEWER_PRIMARY = 0;
const DEFAULT_VIEWER_AUTOSTART = 0;
const DEFAULT_VIEWER_TUNING = 0;
protected $_hooks = array('install',
'uninstall',
'config_form',
'config',
'public_items_show',
'public_head',
'admin_head'
);
protected $_filters = array(
'admin_items_form_tabs',
);
public function hookInstall()
{
set_option('jwplayer_width_public', VideoStreamPlugin::DEFAULT_VIEWER_WIDTH);
set_option('jwplayer_height_public', VideoStreamPlugin::DEFAULT_VIEWER_HEIGHT);
set_option('jwplayer_external_control', VideoStreamPlugin::DEFAULT_VIEWER_CONTROL);
set_option('jwplayer_display_current', VideoStreamPlugin::DEFAULT_VIEWER_DISPLAY);
set_option('jwplayer_external_skin', VideoStreamPlugin::DEFAULT_VIEWER_SKIN);
set_option('jwplayer_flash_streaming', VideoStreamPlugin::DEFAULT_VIEWER_FLASH);
set_option('jwplayer_http_streaming', VideoStreamPlugin::DEFAULT_VIEWER_HTTP);
set_option('jwplayer_hls_streaming', VideoStreamPlugin::DEFAULT_VIEWER_HLS);
set_option('jwplayer_flash_primary', VideoStreamPlugin::DEFAULT_VIEWER_PRIMARY);
set_option('jwplayer_autostart', VideoStreamPlugin::DEFAULT_VIEWER_AUTOSTART);
set_option('jwplayer_tuning', VideoStreamPlugin::DEFAULT_VIEWER_TUNING);
$db = get_db();
// Don't install if an element set named "Streaming Video" already exists.
if ($db->getTable('ElementSet')->findByName('Streaming Video')) {
throw new Exception('An element set by the name "Streaming Video" already exists. You must delete that '
. 'element set to install this plugin.');
}
$elementSetMetadata = array(
'record_type' => "Item",
'name' => "Streaming Video",
'description' => "Elements needed for streaming video for the VideoStream Plugin"
);
$elements = array(
array(
'name' => "Video Filename",
'description' => "Actual filename of the video on the video source server"
),
array(
'name' => "Video Streaming URL",
'description' => "Actual URL of the streaming server without the filename"
),
array(
'name' => "Video Type",
'description' => "Encoding for the video; mp4, flv, mov, and so forth"
),
array(
'name' => "HLS Streaming Directory",
'description' => "Directory location on your server for the HLS .m3u8 file."
),
array(
'name' => "HLS Video Filename",
'description' => "Filename for HLS video file. Include any subdirectories."
),
array(
'name' => "HTTP Streaming Directory",
'description' => "Directory location for files to HTTP stream directly from Web Server."
),
array(
'name' => "HTTP Video Filename",
'description' => "Actual filename of the video on the web server"
),
array(
'name' => "Segment Start",
'description' => "Start point in video in either seconds or hh:mm:ss"
),
array(
'name' => "Segment End",
'description' => "End point in video in either seconds or hh:mm:ss"
),
array(
'name' => "Segment Type",
'description' => "Use segment type to help determine how segment is to be displayed. For instance, an event may encompass many scenes, etc."
),
array(
'name' => "Show Item",
'description' => "Should item be shown in a list. Can be useful in cetain types of displays where you may not want to have all items shown."
),
array(
'name' => "Video Source",
'description' => "Source of video. Streaming server, YouTube, etc."
)
// etc.
);
insert_element_set($elementSetMetadata, $elements);
}
public function hookUninstall()
{
delete_option('jwplayer_width_public');
delete_option('jwplayer_height_public');
delete_option('jwplayer_external_control');
delete_option('jwplayer_display_current');
delete_option('jwplayer_external_skin');
delete_option('jwplayer_flash_streaming');
delete_option('jwplayer_http_streaming');
delete_option('jwplayer_hls_streaming');
delete_option('jwplayer_flash_primary');
delete_option('jwplayer_autostart');
delete_option('jwplayer_tuning');
if ($elementSet = get_db()->getTable('ElementSet')->findByName("Streaming Video")) {
$elementSet->delete();
}
}
/**
* Appends a warning message to the uninstall confirmation page.
*/
public static function admin_append_to_plugin_uninstall_message()
{
echo '<p><strong>Warning</strong>: This will permanently delete the Streaming Video element set and all its associated metadata. You may deactivate this plugin if you do not want to lose data.</p>';
}
public function hookConfigForm()
{
include 'config_form.php';
}
public function hookConfig()
{
if (!is_numeric($_POST['jwplayer_width_public']) ||
!is_numeric($_POST['jwplayer_height_public'])) {
throw new Omeka_Validator_Exception('The width and height must be numeric.');
}
set_option('jwplayer_width_public', $_POST['jwplayer_width_public']);
set_option('jwplayer_height_public', $_POST['jwplayer_height_public']);
set_option('jwplayer_external_control', $_POST['jwplayer_external_control']);
set_option('jwplayer_external_skin', $_POST['jwplayer_external_skin']);
set_option('jwplayer_display_current', $_POST['jwplayer_display_current']);
set_option('jwplayer_flash_streaming', $_POST['jwplayer_flash_streaming']);
set_option('jwplayer_http_streaming', $_POST['jwplayer_http_streaming']);
set_option('jwplayer_hls_streaming', $_POST['jwplayer_hls_streaming']);
set_option('jwplayer_flash_primary', $_POST['jwplayer_flash_primary']);
set_option('jwplayer_autostart', $_POST['jwplayer_autostart']);
set_option('jwplayer_tuning', $_POST['jwplayer_tuning']);
}
public function hookPublicHead($args)
{?>
<?php echo queue_css_file("vidStyle");?>
<?php echo queue_css_file("jquery-ui-1.10.3.custom");?>
<?php echo js_tag('jwplayer');?>
<?php echo js_tag('pfUtils');?>
<?php echo js_tag('jquery');?>
<?php echo js_tag('jquery-ui-1.10.3.custom');
}
public function hookAdminHead($args)
{?>
<?php echo queue_css_file("jquery-ui-1.10.3.custom");?>
<?php echo js_tag('jwplayer');?>
<?php echo js_tag('pfUtils');?>
<?php echo js_tag('jquery');?>
<?php echo js_tag('jquery-ui-1.10.3.custom');
}
public function hookPublicItemsShow($args)
{
$this->append($args);
}
public function append($args)
{
?>
<?php if (get_option('jwplayer_external_control')) {
?>
<?php if (metadata('item',array('Streaming Video','Segment Start'))) {
?>
<div id="vid_player">
<div id="jwplayer_plugin">Player failed to load... </div>
<div id="vidcontrols">
<ul class="vidControlsLayout" style="width='<?php echo get_option("jwplayer_width_public");?>'">
<li id="start_img"><img src="<?php echo img('pause.png'); ?>" title="Start/Stop" class="btnPlay"/></li>
<li id="playback-display"><span class="current">0:00:00</span></li>
<li class="progressBar"></li>
<li id="slider-display"><span class="duration">0:00:00</span> </li>
<li id="vol_img"><img class="muted" src="<?php echo img('volume_speaker.png'); ?>" /></a></li>
<li class="volumeBar"></li>
</ul>
</div>
<script type="text/javascript">
var is_play = true;
var startTime= calculateTime("<?php echo metadata('item', array('Streaming Video','Segment Start'));?>");
var endTime = calculateTime("<?php echo metadata('item', array('Streaming Video','Segment End'));?>");
jwplayer("jwplayer_plugin").setup({
playlist: [{
sources: [
<?php if(get_option('jwplayer_hls_streaming')){?>
{
file: '<?php echo metadata('item',array("Streaming Video","HLS Streaming Directory"));?><?php echo metadata('item',array("Streaming Video","HLS Video Filename"));?>' },
<?php }?>
<?php if(get_option('jwplayer_flash_streaming')){?>
{
file: '<?php echo metadata("item",array ("Streaming Video","Video Streaming URL"));?><?php echo metadata("item",array("Streaming Video","Video Type"));?><?php echo metadata('item',array("Streaming Video","Video Filename"));?>'} ,
<?php }?>
<?php if(get_option('jwplayer_http_streaming')){?>
{
file: '<?php echo metadata("item",array("Streaming Video","HTTP Streaming Directory"));?><?php echo metadata("item",array("Streaming Video","HTTP Video Filename"));?>'},
<?php }?>
]
}
],
<?php if(get_option('jwplayer_flash_primary')){?>
primary: "flash",
<?php }?>
autostart: false,
controls: false,
width: "100%",
height: "<?php echo get_option('jwplayer_height_public');?>",
}
);
jwplayer("jwplayer_plugin").onReady(function(){
jQuery('.current').text(getFormattedTimeString(startTime));
jQuery('.duration').text(getFormattedTimeString(endTime));
jwplayer("jwplayer_plugin").seek(startTime);
<?php if(get_option('jwplayer_autostart')==0){?>
jwplayer("jwplayer_plugin").pause();
<?php }?>
}
);
jQuery( ".progressBar" ).slider(
{
min: startTime,
max: endTime,
range: "max",
slide: function(event, ui) {
jwplayer().seek(ui.value);
},
change: function(event,ui){
if (jwplayer().getPosition() > endTime){
jwplayer().seek(startTime);
}
}
});
jQuery( ".volumeBar" ).slider(
{
min: 0,
max: 100,
range: "max",
slide: function(event, ui) {
jwplayer().setVolume(ui.value);
},
change: function(event,ui){
jwplayer().setVolume(ui.value);
}
});
jwplayer("jwplayer_plugin").onTime(function(event){
jQuery(".progressBar").slider("value", jwplayer("jwplayer_plugin").getPosition());
jQuery('.current').text(getFormattedTimeString(jwplayer("jwplayer_plugin").getPosition()));
});
jwplayer("jwplayer_plugin").onPlay(function(){
jQuery('.btnPlay').attr("src","<?php echo img('pause.png'); ?>");
});
jwplayer("jwplayer_plugin").onPause(function(){
jQuery('.btnPlay').attr("src","<?php echo img('play.png'); ?>");
});
jwplayer("jwplayer_plugin").onMute(function(event){
if (event.mute){
jQuery('.muted').attr("src","<?php echo img('volume_speaker_mute.png'); ?>");
}else{
jQuery('.muted').attr("src","<?php echo img('volume_speaker.png'); ?>");
}
}
);
jwplayer("jwplayer_plugin").onVolume(function(event){
if (event.volume <= 0 ){
jQuery('.muted').attr("src","<?php echo img('volume_speaker_mute.png'); ?>");
}else{
jQuery('.muted').attr("src","<?php echo img('volume_speaker.png'); ?>");
}
}
);
jQuery('.btnPlay').on('click', function() {
if (jwplayer().getPosition() > endTime){
jwplayer().seek(startTime);
}
jwplayer().play();
return false;
});
jQuery('.btnStop').on('click', function() {
jwplayer().stop();
jwplayer().seek(startTime);
jQuery(".progressBar").slider("value", jwplayer().getPosition());
jQuery('.current').text(getFormattedTimeString(jwplayer().getPosition()));
return false;
});
jQuery('.muted').click(function() {
jwplayer().setMute();
return false;
});
jQuery('#vid_player')[0].onmouseover = (function() {
var onmousestop = function() {
jQuery('#vidcontrols').css('display', 'none');
}, thread;
return function() {
jQuery('#vidcontrols').css('display', 'block');
clearTimeout(thread);
thread = setTimeout(onmousestop, 3000);
};
})();
jQuery('#vid_player')[0].onmousedown = (function() {
var moveend = function() {
jQuery('#vidcontrols').css('display', 'none');
}, thread;
return function() {
jQuery('#vidcontrols').css('display', 'block');
clearTimeout(thread);
thread = setTimeout(moveend, 3000);
};
})();
</script>
</div>
<?php } ; ?>
<?php
} else {
//use jwplayer control
?>
<?php if ($bText = metadata('item',array('Streaming Video','Segment Start'))) {
?>
<div id="vid_player" style="width:100%; margin:0 auto;">
<div id="jwplayer_plugin" style="margin:0 auto;">Player failed to load... </div>
</div>
<?php } ; ?>
<script type="text/javascript">
var is_play = true;
var startTime= calculateTime("<?php echo metadata('item', array('Streaming Video','Segment Start'));?>");
var endTime = calculateTime("<?php echo metadata('item', array('Streaming Video','Segment End'));?>");
jwplayer("jwplayer_plugin").setup({
playlist: [{
sources: [
<?php if(get_option('jwplayer_hls_streaming')){?>
{
file: '<?php echo metadata('item',array("Streaming Video","HLS Streaming Directory"));?><?php echo metadata('item',array("Streaming Video","HLS Video Filename"));?>' },
<?php }?>
<?php if(get_option('jwplayer_flash_streaming')){?>
{
file: '<?php echo metadata("item",array ("Streaming Video","Video Streaming URL"));?><?php echo metadata("item",array("Streaming Video","Video Type"));?><?php echo metadata('item',array("Streaming Video","Video Filename"));?>'} ,
<?php }?>
<?php if(get_option('jwplayer_http_streaming')){?>
{
file: '<?php echo metadata("item",array("Streaming Video","HTTP Streaming Directory"));?><?php echo metadata("item",array("Streaming Video","HTTP Video Filename"));?>'},
<?php }?>
]
}
],
<?php if(get_option('jwplayer_flash_primary')){?>
primary: "flash",
<?php }?>
autostart: false,
width: "95%",
height: <?php echo get_option('jwplayer_height_public'); ?>
}
);
jwplayer("jwplayer_plugin").onReady(function(){
jwplayer("jwplayer_plugin").seek(startTime);
<?php if(get_option('jwplayer_autostart')==0){?>
jwplayer("jwplayer_plugin").pause();
<?php }?>
}
);
<?php } ?>
</script>
<?php if (get_option('jwplayer_display_current')) {
?>
<?php $orig_item=get_current_record('item');
$orig_video = metadata("item", array("Streaming Video","Video Filename"));
?>
<?php $items=get_records('item',array('collection'=>metadata('item','collection id'),'sort_field'=>'Streaming Video,Segment Start'),null);
?>
<?php set_loop_records('items', $items);
if (has_loop_records('items')) {
$items = get_loop_records('items');
}
?>
<?php foreach(loop('items') as $item): ?>
<?php if ((metadata('item',array('Streaming Video','Segment Type'))=='Scene') && (metadata('item',array('Streaming Video','Video Filename'))== $orig_video)){
?>
<div class="scene" id="<?php echo metadata('item',array('Streaming Video','Segment Start'));
?>" title="<?php echo metadata('item',array('Streaming Video','Segment End'));
?>" style="display:none;">
<h2>Current video segment:</h2>
<h3><?php echo link_to_item(metadata('item',array('Dublin Core','Title')));
?></h3>
<div style="overflow:auto; max-height:150px;">
<p> <?php echo metadata('item',array('Dublin Core', 'Description'));
?> </p>
</div>
<p>Segment: <?php echo metadata('item',array('Streaming Video','Segment Start'));
?>
--
<?php echo metadata('item',array('Streaming Video','Segment End'));
?>
</p>
</div> <!-- end of loop div for display -->
<?php }
;
?>
<?php endforeach;
?>
<hr style="color:lt-gray;"/>
<?php set_current_record('item',$orig_item);
?>
<script type="text/javascript">
function getElementsByClass(searchClass, domNode, tagName)
{
if (domNode == null) {
domNode = document;
}
if (tagName == null) {
tagName = '*';
}
var el = new Array();
var tags = domNode.getElementsByTagName(tagName);
var tcl = " "+searchClass+" ";
for (i=0,j=0; i<tags.length; i++) {
var test = " " + tags[i].className + " ";
if (test.indexOf(tcl) != -1) {
el[j++] = tags[i];
}
}
return el;
}
jwplayer("jwplayer_plugin").onTime(function(event){
var ctime = "0:00:00";
var scenes;
var sel;
var i = 0;
ctime = getTimeString(jwplayer("jwplayer_plugin").getPosition());
scenes = getElementsByClass("scene");
for (i; i < scenes.length; i++) {
sel = scenes[i];
if (sel.getAttribute('id') <= ctime && sel.getAttribute('title') >= ctime) {
sel.style.display = 'block';
} else {
sel.style.display = 'none';
}
}
}
);
</script>
<?php
}
?>
<?php
}
/*
* Save jQuery slider to Streaming Video element and Description to Dublin Core before save item
* use update_item in AfterSaveItem cause infinite loop where elements updated several times until above packet_limit
$post = $_POST;
$item = $args['record'];
update_item($item, array (
'overwriteElementTexts' => "true"
), array (
'Streaming Video' => array (
'Segment Start' => array ( array (
'text' => "$slider_start",
'html' => false)
),
'Segment End' => array ( array (
'text' => "$slider_end",
'html' => false)
)
),
'Dublin Core' => array (
'Description' => array ( array (
'text' => "$description",
'html' => false)
)
)
))
*
*/
public function filterAdminItemsFormTabs($tabs, $args)
{
// insert the Segmenting Video tab before the Miscellaneous tab
$item = $args['item'];
if(get_option('jwplayer_tuning')==0){
$tabs['Segment Tuning'] = $this->_segmentForm($item);
}
return $tabs;
}
/**
* Returns the form code for segmenting video for items
* @param Item $item
* @return string
**/
protected function _segmentForm($item)
{
$segment_flash_file = metadata("item", array("Streaming Video","Video Filename"));
$segment_flash_type = metadata("item", array("Streaming Video","Video Type"));
$segment_flash_url = metadata("item", array("Streaming Video","Video Streaming URL"));
$segment_http_dir = metadata("item", array("Streaming Video","HTTP Streaming Directory"));
$segment_http_file = metadata("item", array("Streaming Video","HTTP Video Filename"));
$segment_hls_dir = metadata("item", array("Streaming Video","HLS Streaming Directory"));
$segment_hls_file = metadata("item", array("Streaming Video","HLS Video Filename"));
$segment_start = metadata("item", array("Streaming Video","Segment Start"));
$segment_end = metadata('item', array('Streaming Video','Segment End'));
$segment_desc = metadata('item',array('Dublin Core','Description'));
$source = '';
if(get_option('jwplayer_flash_streaming')){
$source .= "\n" . '{' . "\n" . 'file: ' . "'" . metadata("item",array ("Streaming Video","Video Streaming URL")) . metadata("item",array("Streaming Video","Video Type")) . metadata("item",array("Streaming Video","Video Filename")) . "'" . '},' . "\n";
}
if(get_option('jwplayer_http_streaming')){
$source .= "\n" . '{' . "\n" . 'file: ' . "'" . metadata("item",array("Streaming Video","HTTP Streaming Directory")) . metadata("item",array("Streaming Video","HTTP Video Filename")) . "'" . '},' . "\n";
}
if(get_option('jwplayer_hls_streaming')){
$source .= "\n" . '{' . "\n" . 'file: ' . "'" . metadata('item',array("Streaming Video","HLS Streaming Directory")) . metadata('item',array("Streaming Video","HLS Video Filename")) . "'" . '},' . "\n";
}
$height = get_option('jwplayer_height_public');
$jwplayer = '';
if(get_option('jwplayer_flash_primary')){
$jwplayer .=
<<<JW_Str1
jwplayer("jwplayer_plugin").setup({
playlist: [{
sources: [
$source
]}
],
primary: "flash",
autostart: false,
controls: true,
width: "95%",
height: $height
});
JW_Str1;
} else {
$jwplayer .=
<<<JW_Str2
jwplayer("jwplayer_plugin").setup({
playlist: [{
sources: [
$source
]}
],
autostart: false,
controls: true,
width: "95%",
height: $height
});
JW_Str2;
}
$html = '';
$html .= '<div class="field">';
$html .= '<div id="videosegmentation_form" class="two columns alpha" >';
$html .= '<input type="hidden" name="videomeka_slider_start" id="videomeka_slider_start" />';
$html .= '<input type="hidden" name="videomeka_slider_end" id="videomeka_slider_end" />';
$html .= '</div>';
$html .=
/*heredoc must has its own line, with no other characters before and after
*jQuery("input[]") on array, button click must wrap in document ready
*/
<<<HTML
<div id="vid_player" style="margin:0 auto; width: 100%;">
<div id="jwplayer_plugin" style="margin:0 auto;">Player failed to load... </div>
</div>
<script type="text/javascript">
var startTime= calculateTime("$segment_start");
var endTime = calculateTime("$segment_end");
HTML;
$html .= $jwplayer . "\n";
$html .=
<<<HTML_1
jwplayer("jwplayer_plugin").onReady(function(){
jwplayer("jwplayer_plugin").seek(calculateTime("$segment_start"));
jQuery("#CurrentPos").val(getFormattedTimeString("$segment_start"));
jwplayer("jwplayer_plugin").pause();
}
);
jwplayer("jwplayer_plugin").onTime(function(){
jQuery("#CurrentPos").val(getFormattedTimeString(jwplayer("jwplayer_plugin").getPosition()));
});
</script>
HTML_1;
$html .=
<<<Slider_
<p>
<label for="CurrentPos" style="float:left;">Current position:</label>
<input type="text" id="CurrentPos" style="border: 0; color: #f6931f; font-weight: bold; width:20%; " /><pauseButton>>/=</pauseButton></p>
<p>
<label for="SegmentStart" style="float:left;">Segment start:</label>
<input type="text" id="SegmentStart" style="border: 0; color: #f6931f; font-weight: bold; width:20%; " /><startButton>Set</startButton></p>
<p>
<label for="SegmentEnd" style="float:left;">Segment End:</label>
<input type="text" id="SegmentEnd" style="border: 0; color: #f6931f; font-weight: bold; width:20%; " /><endButton>Set</endButton>
</p>
Slider_;
$html .= '<div class="inputs five columns omega">';
$html .= '<div class="input-block">';
$html .= '<label>Description:</label>';
$html .= '<textarea id="videomeka_description" name="videomeka_description">';
$html .='</textarea>';
$html .=
<<<JS
<saveButton>Update</saveButton>
<script type="text/javascript">
jQuery(document).ready(function(){
var v_desc = jQuery("#Elements-41-0-text").val();
jQuery("#SegmentStart").val(getFormattedTimeString(startTime));
jQuery("#SegmentEnd").val(getFormattedTimeString(endTime));
jQuery("pauseButton").button();
jQuery("startButton").button();
jQuery("endButton").button();
jQuery("saveButton").button();
jQuery("#videomeka_description").val(v_desc);
jQuery("pauseButton").click(function(){
jwplayer("jwplayer_plugin").pause();
});
jQuery("startButton").click(function(){
jQuery("#SegmentStart").val(getFormattedTimeString(jwplayer().getPosition()));
jQuery("#Elements-71-0-text").val(jQuery("#SegmentStart").val());
});
jQuery("endButton").click(function(){
jQuery("#SegmentEnd").val(getFormattedTimeString(jwplayer().getPosition()));
jQuery("#Elements-72-0-text").val(jQuery("#SegmentEnd").val());
});
jQuery("saveButton").click(function(){
if(jQuery("#videomeka_description").val().length == 0)
{
var desc = jQuery("#Elements-41-0-text").val();
}
else
{
var desc = jQuery("#videomeka_description").val();
}
jQuery("#Elements-41-0-text").val(desc);
jQuery("#Elements-71-0-text").val(jQuery("#SegmentStart").val());
jQuery("#Elements-72-0-text").val(jQuery("#SegmentEnd").val());
});
});
</script>
JS;
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
return $html;
}
}