5
5
*
6
6
* @package JWPlayer
7
7
* @author 羽中
8
- * @version 1.0.8
8
+ * @version 1.0.9
9
9
* @dependence 14.5.26-*
10
10
* @link http://www.yzmb.me/archives/net/jwplayer-for-typecho
11
11
*/
@@ -199,6 +199,11 @@ public static function config(Typecho_Widget_Helper_Form $form)
199
199
<td> ' ._t ('右击菜单链接,同上。 ' ).'</td>
200
200
</tr>
201
201
<tr>
202
+ <td class="param">stretching</td>
203
+ <td class="value">uniform</td>
204
+ <td> ' ._t ('画面适应方法,可覆盖插件统一设置,对应值%s固定/%s缩放/%s裁切/%s拉伸。 ' ,'<span class="value">none</span> ' ,'<span class="value">uniform</span> ' ,'<span class="value">fill</span> ' ,'<span class="value">exactfit</span> ' ).'</td>
205
+ </tr>
206
+ <tr>
202
207
<td class="param">minDvrWindow</td>
203
208
<td class="value">120</td>
204
209
<td> ' ._t ('(直播流)回放模式判定,默认检测到120个缓存单元开启,设置为0可强制显示录像控制按钮。 ' ,'<span class="value">monoscopic</span> ' ,'<strong>,</strong> ' ).'</td>
@@ -278,6 +283,10 @@ public static function config(Typecho_Widget_Helper_Form $form)
278
283
array ('none ' =>_t ('固定 ' ),'' =>_t ('缩放 ' ),'fill ' =>_t ('裁切 ' ),'exactfit ' =>_t ('拉伸 ' )),'' ,_t ('画面适应方法 ' ),_t ('视频尺寸与播放器尺寸不同时的修正方式 ' ));
279
284
$ form ->addInput ($ stretch );
280
285
286
+ $ encode = new Typecho_Widget_Helper_Form_Element_Radio ('encode ' ,
287
+ array (1 =>_t ('是 ' ),0 =>_t ('否 ' )),0 ,_t ('加密视频地址 ' ),_t ('是否隐藏文件url使其在源码中显示为乱码 ' ));
288
+ $ form ->addInput ($ encode );
289
+
281
290
$ info = new Typecho_Widget_Helper_Form_Element_Radio ('info ' ,
282
291
array (1 =>_t ('是 ' ),0 =>_t ('否 ' )),0 ,_t ('隐藏标题描述 ' ),_t ('是否在窗口显示title与description参数信息 ' ));
283
292
$ form ->addInput ($ info );
@@ -290,10 +299,10 @@ public static function config(Typecho_Widget_Helper_Form $form)
290
299
array ('' =>_t ('默认 ' ),'dropshadow ' =>_t ('下阴影 ' ),'depressed ' =>_t ('上阴影 ' ),'uniform ' =>_t ('深描边 ' ),'raised ' =>_t ('浅描边 ' )),'' ,_t ('外挂字幕效果 ' ));
291
300
$ form ->addInput ($ tedge );
292
301
293
- $ tsize = new Typecho_Widget_Helper_Form_Element_Text ('tsize ' ,NULL ,'15 ' ,_t ('字体大小: ' ));
302
+ $ tsize = new Typecho_Widget_Helper_Form_Element_Text ('tsize ' ,NULL ,'15 ' ,_t ('字体大小(单位px, 不用填写) : ' ));
294
303
$ tsize ->input ->setAttribute ('class ' ,'text-s ' );
295
304
$ tsize ->label ->setAttribute ('style ' ,'position:absolute;color:#999;font-weight:normal;bottom:10px;left:82px; ' );
296
- $ tsize ->input ->setAttribute ('style ' ,'position:absolute;width:38px;bottom:13px;left:145px ; ' );
305
+ $ tsize ->input ->setAttribute ('style ' ,'position:absolute;width:38px;bottom:13px;left:258px ; ' );
297
306
$ tsize ->setAttribute ('style ' ,'position:relative ' );
298
307
$ form ->addInput ($ tsize ->addRule ('isFloat ' ));
299
308
@@ -311,16 +320,16 @@ public static function config(Typecho_Widget_Helper_Form $form)
311
320
array ('' =>_t ('右上角 ' ),'top-left ' =>_t ('左上角 ' ),'bottom-right ' =>_t ('右下角 ' ),'bottom-left ' =>_t ('左下角 ' ),'control-bar ' =>_t ('控制条 ' )),'' ,_t ('logo显示位置 ' ));
312
321
$ form ->addInput ($ lpos );
313
322
314
- $ margin = new Typecho_Widget_Helper_Form_Element_Text ('margin ' ,NULL ,'8 ' ,_t ('边距(margin值 ): ' ));
323
+ $ margin = new Typecho_Widget_Helper_Form_Element_Text ('margin ' ,NULL ,'8 ' ,_t ('边距(单位px, 不用填写 ): ' ));
315
324
$ margin ->input ->setAttribute ('class ' ,'text-s ' );
316
325
$ margin ->label ->setAttribute ('style ' ,'position:absolute;color:#999;font-weight:normal;bottom:10px;left:82px; ' );
317
- $ margin ->input ->setAttribute ('style ' ,'position:absolute;width:38px;bottom:13px;left:183px ; ' );
326
+ $ margin ->input ->setAttribute ('style ' ,'position:absolute;width:38px;bottom:13px;left:230px ; ' );
318
327
$ margin ->setAttribute ('style ' ,'position:relative ' );
319
328
$ form ->addInput ($ margin ->addRule ('isFloat ' ));
320
329
321
330
$ hide = new Typecho_Widget_Helper_Form_Element_Checkbox ('hide ' ,
322
331
array (1 =>_t ('自动隐藏 ' )),NULL ,'' );
323
- $ hide ->label ->setAttribute ('style ' ,'position:absolute;color:#999;font-weight:normal;bottom:10px;left:232px ; ' );
332
+ $ hide ->label ->setAttribute ('style ' ,'position:absolute;color:#999;font-weight:normal;bottom:10px;left:279px ; ' );
324
333
$ hide ->input ->setAttribute ('style ' ,'position:absolute;bottom:4px;left:60px; ' );
325
334
$ hide ->setAttribute ('style ' ,'position:relative ' );
326
335
$ form ->addInput ($ hide );
@@ -404,140 +413,162 @@ public static function callback($match)
404
413
$ codes = trim (Typecho_Common::stripTags ($ match ['2 ' ]));
405
414
if (strpos ($ codes ,'< ' )) $ codes = substr ($ codes ,0 ,-3 ); //markdown fix
406
415
$ atts = strpos ($ codes ,'| ' ) ? explode ('| ' ,$ codes ) : array ($ codes );
407
- $ file = trim (array_shift ($ atts ));
408
416
409
- //处理地址参数
410
- if (preg_match ("/(\.rss|\.json)/i " ,$ file )) {
411
- $ data ['playlist ' ] = $ file ;
412
- } else {
413
- $ files = explode (', ' ,$ file );
414
- $ fnum = count ($ files );
415
- $ qfiles = array ();
416
- $ qnum = '' ;
417
- $ quality = array ();
418
- $ vr = strpos ($ codes ,'stereomode ' );
419
- $ dvr = strpos ($ codes ,'minDvrWindow ' );
420
-
421
- for ($ i =0 ;$ i <$ fnum ;++$ i ) {
422
- if ($ files [$ i ]) {
423
- $ qfiles = explode ('; ' ,$ files [$ i ]);
424
- $ qnum = count ($ qfiles );
425
-
426
- //准备画质数组
427
- for ($ j =0 ;$ j <$ qnum ;++$ j ) {
428
- $ quality [$ j ]['file ' ] = trim ($ qfiles [$ j ]);
429
- }
430
-
431
- //预设3种清晰度
432
- $ quality ['0 ' ]['label ' ] = _t ('标清 ' );
433
- if (isset ($ quality ['1 ' ])) {
434
- $ quality ['1 ' ]['label ' ] = _t ('高清 ' );
435
- }
436
- if (isset ($ quality ['2 ' ])) {
437
- $ quality ['2 ' ]['label ' ] = _t ('超清 ' );
438
- }
439
- }
440
-
441
- //多文件参数
442
- if ($ fnum >1 || $ vr || $ dvr ) {
443
- if ($ qnum >1 ) {
444
- $ lists [$ i ]['sources ' ] = $ quality ;
417
+ $ file = trim (array_shift ($ atts ));
418
+ $ files = explode (', ' ,$ file );
419
+ $ fnum = count ($ files );
420
+ $ qfiles = array ();
421
+ $ qnum = '' ;
422
+ $ source = '' ;
423
+ $ quality = array ();
424
+ $ vr = strpos ($ codes ,'stereomode ' );
425
+ $ dvr = strpos ($ codes ,'minDvrWindow ' );
426
+ //处理视频参数
427
+ for ($ i =0 ;$ i <$ fnum ;++$ i ) {
428
+ //处理画质参数
429
+ if ($ files [$ i ]) {
430
+ $ qfiles = explode ('; ' ,$ files [$ i ]);
431
+ $ qnum = count ($ qfiles );
432
+
433
+ //准备画质数组
434
+ for ($ j =0 ;$ j <$ qnum ;++$ j ) {
435
+ $ source = trim ($ qfiles [$ j ]);
436
+ if (false !==strpos ($ source ,'^ ' )) {
437
+ $ metas = explode ('^ ' ,$ source );
438
+ $ quality [$ j ]['label ' ] = $ metas ['0 ' ];
439
+ $ quality [$ j ]['file ' ] = self ::encode ($ metas ['1 ' ]);
440
+ if (isset ($ metas ['2 ' ])) {
441
+ $ quality [$ j ]['type ' ] = $ metas ['2 ' ];
442
+ }
445
443
} else {
446
- $ lists [$ i ]['file ' ] = trim ($ files [$ i ]);
444
+ $ quality [$ j ]['file ' ] = self ::encode ($ source );
445
+ //预设3种清晰度
446
+ $ quality ['0 ' ]['label ' ] = _t ('标清 ' );
447
+ if (isset ($ quality ['1 ' ])) {
448
+ $ quality ['1 ' ]['label ' ] = _t ('高清 ' );
449
+ }
450
+ if (isset ($ quality ['2 ' ])) {
451
+ $ quality ['2 ' ]['label ' ] = _t ('超清 ' );
452
+ }
447
453
}
448
454
}
449
455
}
450
456
451
- //单文件参数
452
- if ($ fnum<= 1 ) {
457
+ //多文件画质参数
458
+ if ($ fnum> 1 || $ vr || $ dvr ) {
453
459
if ($ qnum >1 ) {
454
- $ data ['sources ' ] = $ quality ;
460
+ $ lists [ $ i ] ['sources ' ] = $ quality ;
455
461
} else {
456
- $ data [ 'file ' ] = $ file ;
462
+ $ lists [ $ i ][ 'file ' ] = self :: encode ( trim ( $ files [ $ i ])) ;
457
463
}
458
464
}
459
465
}
466
+ //单文件画质参数
467
+ if ($ fnum <=1 ) {
468
+ if ($ qnum >1 ) {
469
+ $ data ['sources ' ] = $ quality ;
470
+ } else {
471
+ $ data ['file ' ] = self ::encode ($ file );
472
+ }
473
+ }
460
474
475
+ $ pair = array ();
476
+ $ key = '' ;
477
+ $ val = '' ;
478
+ $ listkey = false ;
479
+ $ vals = array ();
480
+ $ keyvals = '' ;
481
+ $ tfiles = array ();
482
+ $ tnum = '' ;
483
+ $ track = '' ;
484
+ $ subs = array ();
461
485
//处理其他参数
462
- if (array_filter ($ atts )) {
463
- $ pair = array ();
464
- $ key = '' ;
465
- $ val = '' ;
466
- $ vals = array ();
467
- $ vnum = '' ;
468
- $ tfiles = array ();
469
- $ subs = array ();
470
-
471
- foreach ($ atts as $ att ) {
472
- if (strpos ($ att ,'= ' )) {
473
- $ pair = explode ('= ' ,$ att );
474
- $ key = trim ($ pair ['0 ' ]);
475
- $ val = trim ($ pair ['1 ' ]);
476
- $ data [$ key ] = $ val ;
477
-
478
- //处理列表参数
479
- if (in_array ($ key ,array ('image ' ,'title ' ,'description ' ,'tracks ' ,'stereomode ' ,'minDvrWindow ' )) && false !==$ val ) {
480
- $ vals = explode (', ' ,$ val );
481
- $ vnum = count ($ vals );
482
-
483
- for ($ i =0 ;$ i <$ vnum ;++$ i ) {
484
- if (isset ($ vals [$ i ])) {
485
- if ($ key =='tracks ' ) {
486
- $ tfiles = explode ('; ' ,$ vals [$ i ]);
487
- $ tnum = count ($ tfiles );
488
-
489
- //准备语种数组
490
- for ($ j =0 ;$ j <$ tnum ;++$ j ) {
491
- $ subs [$ j ]['file ' ] = trim ($ tfiles [$ j ]);
492
- if ($ tnum <=1 ) {
493
- array_splice ($ subs ,1 );
494
- }
495
-
496
- //预设中英字幕
497
- $ subs ['0 ' ]['label ' ] = _t ('中文 ' );
498
- if (isset ($ subs ['1 ' ])) {
499
- $ subs ['1 ' ]['label ' ] = _t ('英文 ' );
500
- }
501
- }
502
-
503
- //多文件参数
504
- if ($ vnum >1 ) {
505
- unset($ data ['tracks ' ]);
506
- $ lists [$ i ]['tracks ' ] = $ subs ;
507
- }
508
- } elseif ($ vnum >1 || $ vr || $ dvr ) {
509
- unset($ data [$ key ]);
510
- $ lists [$ i ][$ key ] = $ vals [$ i ];
486
+ foreach ($ atts as $ att ) {
487
+ $ pair = explode ('= ' ,$ att );
488
+ $ key = trim ($ pair ['0 ' ]);
489
+ $ val = isset ($ pair ['1 ' ]) ? trim ($ pair ['1 ' ]) : '' ;
490
+ $ data [$ key ] = $ val ;
491
+
492
+ $ listkey = in_array ($ key ,array ('image ' ,'title ' ,'description ' ,'tracks ' ,'stereomode ' ,'minDvrWindow ' ));
493
+ if ($ listkey ) {
494
+ $ vals [$ key ] = explode (', ' ,$ data [$ key ]);
495
+ }
496
+
497
+ //处理列表参数
498
+ for ($ i =0 ;$ i <$ fnum ;++$ i ) {
499
+ if (isset ($ vals [$ key ][$ i ])) {
500
+ $ keyvals = trim ($ vals [$ key ][$ i ]);
501
+ //处理字幕参数
502
+ if ($ key =='tracks ' && $ keyvals ) {
503
+ $ tfiles = explode ('; ' ,$ keyvals );
504
+ $ tnum = count ($ tfiles );
505
+
506
+ //准备语种数组
507
+ for ($ j =0 ;$ j <$ tnum ;++$ j ) {
508
+ $ track = trim ($ tfiles [$ j ]);
509
+ if (false !==strpos ($ track ,'^ ' )) {
510
+ $ infos = explode ('^ ' ,$ track );
511
+ $ subs [$ j ]['label ' ] = $ infos ['0 ' ];
512
+ $ subs [$ j ]['file ' ] = $ infos ['1 ' ];
513
+ if (isset ($ infos ['2 ' ])) {
514
+ $ subs [$ j ]['kind ' ] = $ infos ['2 ' ];
515
+ }
516
+ } else {
517
+ $ subs [$ j ]['file ' ] = $ track ;
518
+ //预设中英字幕
519
+ $ subs ['0 ' ]['label ' ] = _t ('中文 ' );
520
+ if (isset ($ subs ['1 ' ])) {
521
+ $ subs ['1 ' ]['label ' ] = _t ('英文 ' );
511
522
}
512
523
}
513
524
}
525
+ if ($ tnum <=1 ) {
526
+ array_splice ($ subs ,1 );
527
+ }
514
528
515
- if ($ key =='tracks ' ) {
516
- $ tsize = $ settings ->tsize ;
517
- //字幕效果选项
518
- if ($ tsize && $ tsize !=='15 ' ) {
519
- $ data ['captions ' ]['fontSize ' ] = $ tsize ;
520
- }
521
- if ($ settings ->tedge ) {
522
- $ data ['captions ' ]['backgroundOpacity ' ] = '0 ' ;
523
- $ data ['captions ' ]['edgeStyle ' ] = $ settings ->tedge ;
524
- }
525
-
526
- //单文件参数
527
- if ($ vnum <=1 ) {
528
- $ data ['tracks ' ] = $ subs ;
529
- }
529
+ //多文件字幕参数
530
+ if ($ fnum >1 ) {
531
+ unset($ data ['tracks ' ]);
532
+ $ lists [$ i ]['tracks ' ] = $ subs ;
530
533
}
534
+
535
+ //多文件其他参数
536
+ } elseif ($ fnum >1 || $ vr || $ dvr ) {
537
+ unset($ data [$ key ]);
538
+ $ lists [$ i ][$ key ] = $ keyvals ;
531
539
}
540
+
541
+ //对应自动置空
542
+ } elseif ($ listkey ) {
543
+ $ lists [$ i ][$ key ] = '' ;
544
+ }
545
+ }
546
+
547
+ //单文件字幕参数
548
+ if ($ key =='tracks ' ) {
549
+ if ($ fnum <=1 ) {
550
+ $ data ['tracks ' ] = $ subs ;
551
+ }
552
+ //字幕效果选项
553
+ $ tsize = $ settings ->tsize ;
554
+ if ($ tsize && $ tsize !=='15 ' ) {
555
+ $ data ['captions ' ]['fontSize ' ] = $ tsize ;
556
+ }
557
+ if ($ settings ->tedge ) {
558
+ $ data ['captions ' ]['backgroundOpacity ' ] = '0 ' ;
559
+ $ data ['captions ' ]['edgeStyle ' ] = $ settings ->tedge ;
532
560
}
533
561
}
534
562
}
535
563
536
- if ($ lists ) {
564
+ if (preg_match ("/(\.rss|\.json)/i " ,$ file )) {
565
+ unset($ data ['file ' ]);
566
+ $ data ['playlist ' ] = self ::encode ($ file );
567
+ } elseif ($ lists ) {
537
568
$ data ['playlist ' ] = $ lists ;
538
569
}
539
570
540
- return self ::output (Typecho_Widget:: widget ( ' Widget_Archive ' ) ,array ($ data+ self :: locals () ,true ));
571
+ return self ::output ('' ,array ($ data ,true ));
541
572
}
542
573
543
574
/**
@@ -549,7 +580,8 @@ public static function callback($match)
549
580
*/
550
581
public static function output ($ widget ,array $ params )
551
582
{
552
- $ url = Helper::options ()->pluginUrl .'/JWPlayer/player/ ' ;
583
+ $ options = Helper::options ();
584
+ $ url = $ options ->pluginUrl .'/JWPlayer/player/ ' ;
553
585
$ ids = "jwplayer_ " .++self ::$ id ;
554
586
555
587
//处理实例参数
@@ -563,7 +595,7 @@ public static function output($widget,array $params)
563
595
$ output = '<script type="text/javascript">
564
596
window.jwplayer || document.write( \'<script type="text/javascript" src=" ' .$ url .'jwplayer.js"><\/script> \')</script> ' ; //不重复加载
565
597
$ output .= '<div id=" ' .$ ids .'"> ' ._t ('播放器载入中... ' ).'</div> ' ;
566
- $ output .= '<script type="text/javascript">jwplayer.defaults = {"base":" ' .$ url .'"};jwplayer(" ' .$ ids .'").setup( ' .$ jwsets .');</script> ' ;
598
+ $ output .= '<script type="text/javascript">jwplayer.defaults = {"base":" ' .$ url .'"}; ' .( $ options -> plugin ( ' JWPlayer ' )-> encode ? ' jwplayer.encode = true; ' : '' ). ' jwplayer(" ' .$ ids .'").setup( ' .$ jwsets .');</script> ' ;
567
599
568
600
//模版输出判断
569
601
if ($ iscall ) {
@@ -641,7 +673,34 @@ public static function getsets()
641
673
}
642
674
}
643
675
644
- return $ sets ;
676
+ return $ sets +self ::locals ();
677
+ }
678
+
679
+ /**
680
+ * 加密视频地址
681
+ *
682
+ * @param string $string
683
+ * @return string
684
+ */
685
+ private static function encode($ string )
686
+ {
687
+ if (Helper::options ()->plugin ('JWPlayer ' )->encode ) {
688
+ $ string = rawurlencode ($ string );
689
+
690
+ $ ntexto = '' ;
691
+ $ codekey = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_- ' ;
692
+ for ($ i =0 ;$ i <strlen ($ string );$ i ++) {
693
+ $ ntexto .= substr ('0000 ' .base_convert (ord ($ string {$ i }),10 ,2 ),-8 );
694
+ }
695
+ $ ntexto .= substr ('00000 ' ,0 ,6 -strlen ($ ntexto )%6 );
696
+
697
+ $ string = '' ;
698
+ for ($ i =0 ;$ i <strlen ($ ntexto )-1 ;$ i =$ i +6 ) {
699
+ $ string .= $ codekey {intval (substr ($ ntexto ,$ i ,6 ),2 )};
700
+ }
701
+ }
702
+
703
+ return $ string ;
645
704
}
646
705
647
706
/**
0 commit comments