Index: trunk/extensions/OggHandler/OggHandler.php |
— | — | @@ -39,9 +39,17 @@ |
40 | 40 | |
41 | 41 | /******************* CONFIGURATION STARTS HERE **********************/ |
42 | 42 | |
| 43 | +//set the supported ogg codecs: |
| 44 | +$wgOggVideoTypes = array( 'Theora' ); |
| 45 | +$wgOggAudioTypes = array( 'Vorbis', 'Speex', 'FLAC' ); |
| 46 | + |
43 | 47 | //if wgPlayerStats collection is enabled or not |
44 | 48 | $wgPlayerStatsCollection=false; |
45 | 49 | |
| 50 | +//if $wgEnableJS2system = true and the below variable is set to true |
| 51 | +// then we can output the <video> tag and its re-written by mv_embed |
| 52 | +$wgJs2VideoTagOut = true; |
| 53 | + |
46 | 54 | // Location of the FFmpeg binary |
47 | 55 | $wgFFmpegLocation = '/usr/bin/ffmpeg'; |
48 | 56 | |
Index: trunk/extensions/OggHandler/OggHandler_body.php |
— | — | @@ -7,9 +7,6 @@ |
8 | 8 | |
9 | 9 | static $magicDone = false; |
10 | 10 | |
11 | | - var $videoTypes = array( 'Theora' ); |
12 | | - var $audioTypes = array( 'Vorbis', 'Speex', 'FLAC' ); |
13 | | - |
14 | 11 | function isEnabled() { |
15 | 12 | return true; |
16 | 13 | } |
— | — | @@ -93,6 +90,7 @@ |
94 | 91 | } |
95 | 92 | |
96 | 93 | function getImageSize( $file, $path, $metadata = false ) { |
| 94 | + global $wgOggVideoTypes; |
97 | 95 | // Just return the size of the first video stream |
98 | 96 | if ( $metadata === false ) { |
99 | 97 | $metadata = $file->getMetadata(); |
— | — | @@ -102,9 +100,9 @@ |
103 | 101 | return false; |
104 | 102 | } |
105 | 103 | foreach ( $metadata['streams'] as $stream ) { |
106 | | - if ( in_array( $stream['type'], $this->videoTypes ) ) { |
107 | | - return array( |
108 | | - $stream['header']['PICW'], |
| 104 | + if ( in_array( $stream['type'], $wgOggVideoTypes ) ) { |
| 105 | + return array( |
| 106 | + $stream['header']['PICW'], |
109 | 107 | $stream['header']['PICH'] |
110 | 108 | ); |
111 | 109 | } |
— | — | @@ -351,16 +349,16 @@ |
352 | 350 | } |
353 | 351 | |
354 | 352 | function getShortDesc( $file ) { |
355 | | - global $wgLang; |
| 353 | + global $wgLang, $wgOggAudioTypes, $wgOggVideoTypes; |
356 | 354 | wfLoadExtensionMessages( 'OggHandler' ); |
357 | 355 | $streamTypes = $this->getStreamTypes( $file ); |
358 | 356 | if ( !$streamTypes ) { |
359 | 357 | return parent::getShortDesc( $file ); |
360 | 358 | } |
361 | | - if ( array_intersect( $streamTypes, $this->videoTypes ) ) { |
| 359 | + if ( array_intersect( $streamTypes, $wgOggVideoTypes ) ) { |
362 | 360 | // Count multiplexed audio/video as video for short descriptions |
363 | 361 | $msg = 'ogg-short-video'; |
364 | | - } elseif ( array_intersect( $streamTypes, $this->audioTypes ) ) { |
| 362 | + } elseif ( array_intersect( $streamTypes, $wgOggAudioTypes ) ) { |
365 | 363 | $msg = 'ogg-short-audio'; |
366 | 364 | } else { |
367 | 365 | $msg = 'ogg-short-general'; |
— | — | @@ -370,20 +368,20 @@ |
371 | 369 | } |
372 | 370 | |
373 | 371 | function getLongDesc( $file ) { |
374 | | - global $wgLang; |
| 372 | + global $wgLang, $wgOggVideoTypes, $wgOggAudioTypes; |
375 | 373 | wfLoadExtensionMessages( 'OggHandler' ); |
376 | 374 | $streamTypes = $this->getStreamTypes( $file ); |
377 | 375 | if ( !$streamTypes ) { |
378 | 376 | $unpacked = $this->unpackMetadata( $file->getMetadata() ); |
379 | 377 | return wfMsg( 'ogg-long-error', $unpacked['error']['message'] ); |
380 | 378 | } |
381 | | - if ( array_intersect( $streamTypes, $this->videoTypes ) ) { |
382 | | - if ( array_intersect( $streamTypes, $this->audioTypes ) ) { |
| 379 | + if ( array_intersect( $streamTypes,$wgOggVideoTypes ) ) { |
| 380 | + if ( array_intersect( $streamTypes, $wgOggAudioTypes ) ) { |
383 | 381 | $msg = 'ogg-long-multiplexed'; |
384 | 382 | } else { |
385 | 383 | $msg = 'ogg-long-video'; |
386 | 384 | } |
387 | | - } elseif ( array_intersect( $streamTypes, $this->audioTypes ) ) { |
| 385 | + } elseif ( array_intersect( $streamTypes, $wgOggAudioTypes ) ) { |
388 | 386 | $msg = 'ogg-long-audio'; |
389 | 387 | } else { |
390 | 388 | $msg = 'ogg-long-general'; |
— | — | @@ -426,32 +424,36 @@ |
427 | 425 | |
428 | 426 | function setHeaders( $out ) { |
429 | 427 | global $wgOggScriptVersion, $wgCortadoJarFile, $wgServer, $wgUser, $wgScriptPath, |
430 | | - $wgPlayerStatsCollection; |
431 | | - |
432 | | - if ( $out->hasHeadItem( 'OggHandler' ) ) { |
433 | | - return; |
434 | | - } |
435 | | - |
436 | | - wfLoadExtensionMessages( 'OggHandler' ); |
437 | | - |
438 | | - $msgNames = array( 'ogg-play', 'ogg-pause', 'ogg-stop', 'ogg-no-player', |
439 | | - 'ogg-player-videoElement', 'ogg-player-oggPlugin', 'ogg-player-cortado', 'ogg-player-vlc-mozilla', |
440 | | - 'ogg-player-vlc-activex', 'ogg-player-quicktime-mozilla', 'ogg-player-quicktime-activex', |
441 | | - 'ogg-player-totem', 'ogg-player-kaffeine', 'ogg-player-kmplayer', 'ogg-player-mplayerplug-in', |
442 | | - 'ogg-player-thumbnail', 'ogg-player-selected', 'ogg-use-player', 'ogg-more', 'ogg-download', |
443 | | - 'ogg-desc-link', 'ogg-dismiss', 'ogg-player-soundthumb', 'ogg-no-xiphqt' ); |
444 | | - $msgValues = array_map( 'wfMsg', $msgNames ); |
445 | | - $jsMsgs = Xml::encodeJsVar( (object)array_combine( $msgNames, $msgValues ) ); |
446 | | - $cortadoUrl = $wgCortadoJarFile; |
447 | | - $scriptPath = self::getMyScriptPath(); |
448 | | - if( substr( $cortadoUrl, 0, 1 ) != '/' |
449 | | - && substr( $cortadoUrl, 0, 4 ) != 'http' ) { |
450 | | - $cortadoUrl = "$wgServer$scriptPath/$cortadoUrl"; |
451 | | - } |
452 | | - $encCortadoUrl = Xml::encodeJsVar( $cortadoUrl ); |
453 | | - $encExtPathUrl = Xml::encodeJsVar( $scriptPath ); |
454 | | - |
455 | | - $out->addHeadItem( 'OggHandler', <<<EOT |
| 428 | + $wgPlayerStatsCollection, $wgJs2VideoTagOut, $wgEnableJS2system; |
| 429 | + |
| 430 | + if( $wgJs2VideoTagOut && $wgEnableJS2system){ |
| 431 | + //all javascript is localized via script-loader |
| 432 | + //and loaded on DOM ready if video tag is present |
| 433 | + }else{ |
| 434 | + if ( $out->hasHeadItem( 'OggHandler' ) ) { |
| 435 | + return; |
| 436 | + } |
| 437 | + |
| 438 | + wfLoadExtensionMessages( 'OggHandler' ); |
| 439 | + |
| 440 | + $msgNames = array( 'ogg-play', 'ogg-pause', 'ogg-stop', 'ogg-no-player', |
| 441 | + 'ogg-player-videoElement', 'ogg-player-oggPlugin', 'ogg-player-cortado', 'ogg-player-vlc-mozilla', |
| 442 | + 'ogg-player-vlc-activex', 'ogg-player-quicktime-mozilla', 'ogg-player-quicktime-activex', |
| 443 | + 'ogg-player-totem', 'ogg-player-kaffeine', 'ogg-player-kmplayer', 'ogg-player-mplayerplug-in', |
| 444 | + 'ogg-player-thumbnail', 'ogg-player-selected', 'ogg-use-player', 'ogg-more', 'ogg-download', |
| 445 | + 'ogg-desc-link', 'ogg-dismiss', 'ogg-player-soundthumb', 'ogg-no-xiphqt' ); |
| 446 | + $msgValues = array_map( 'wfMsg', $msgNames ); |
| 447 | + $jsMsgs = Xml::encodeJsVar( (object)array_combine( $msgNames, $msgValues ) ); |
| 448 | + $cortadoUrl = $wgCortadoJarFile; |
| 449 | + $scriptPath = self::getMyScriptPath(); |
| 450 | + if( substr( $cortadoUrl, 0, 1 ) != '/' |
| 451 | + && substr( $cortadoUrl, 0, 4 ) != 'http' ) { |
| 452 | + $cortadoUrl = "$wgServer$scriptPath/$cortadoUrl"; |
| 453 | + } |
| 454 | + $encCortadoUrl = Xml::encodeJsVar( $cortadoUrl ); |
| 455 | + $encExtPathUrl = Xml::encodeJsVar( $scriptPath ); |
| 456 | + |
| 457 | + $out->addHeadItem( 'OggHandler', <<<EOT |
456 | 458 | <script type="text/javascript" src="$scriptPath/OggPlayer.js?$wgOggScriptVersion"></script> |
457 | 459 | <script type="text/javascript"> |
458 | 460 | wgOggPlayer.msg = $jsMsgs; |
— | — | @@ -468,6 +470,7 @@ |
469 | 471 | </style> |
470 | 472 | EOT |
471 | 473 | ); |
| 474 | + } |
472 | 475 | |
473 | 476 | //if collecting stats add relevant code: |
474 | 477 | if( $wgPlayerStatsCollection ){ |
— | — | @@ -523,6 +526,7 @@ |
524 | 527 | } |
525 | 528 | |
526 | 529 | function toHtml( $options = array() ) { |
| 530 | + global $wgEnableTemporalOggUrls, $wgJs2VideoTagOut, $wgEnableJS2system; |
527 | 531 | wfLoadExtensionMessages( 'OggHandler' ); |
528 | 532 | if ( count( func_get_args() ) == 2 ) { |
529 | 533 | throw new MWException( __METHOD__ .' called in the old style' ); |
— | — | @@ -544,106 +548,154 @@ |
545 | 549 | $scriptPath = OggHandler::getMyScriptPath(); |
546 | 550 | $thumbDivAttribs = array(); |
547 | 551 | $showDescIcon = false; |
548 | | - if ( $this->isVideo ) { |
549 | | - $msgStartPlayer = wfMsg( 'ogg-play-video' ); |
550 | | - $imgAttribs = array( |
551 | | - 'src' => $this->url, |
552 | | - 'width' => $width, |
553 | | - 'height' => $height, |
554 | | - 'alt' => $alt ); |
555 | | - $playerHeight = $height; |
556 | | - } else { |
557 | | - // Sound file |
558 | | - if ( $height > 100 ) { |
559 | | - // Use a big file icon |
| 552 | + |
| 553 | + //check if outputing to video tag or oggHandler |
| 554 | + if( $wgJs2VideoTagOut && $wgEnableJS2system){ |
| 555 | + //video tag output: |
| 556 | + if ( $this->isVideo ) { |
| 557 | + $playerHeight = $height; |
| 558 | + $thumb_url = $this->url; |
| 559 | + }else{ |
| 560 | + // Sound file |
560 | 561 | global $wgStylePath; |
561 | | - $imgAttribs = array( |
562 | | - 'src' => "$wgStylePath/common/images/icons/fileicon-ogg.png", |
563 | | - 'width' => 125, |
564 | | - 'height' => 125, |
565 | | - 'alt' => $alt, |
| 562 | + $thumb_url = "$wgStylePath/common/images/icons/fileicon-ogg.png"; |
| 563 | + if ( $height < 35 ) |
| 564 | + $playerHeight = 35; |
| 565 | + else |
| 566 | + $playerHeight = $height; |
| 567 | + } |
| 568 | + $id = "ogg_player_" . OggTransformOutput::$serial; |
| 569 | + $linkAttribs = $this->getDescLinkAttribs( $alt ); |
| 570 | + $videoAttr = array( |
| 571 | + 'id' => $id, |
| 572 | + 'src' => $url, |
| 573 | + 'style' => "width:{$width}px;height:{$playerHeight}px", |
| 574 | + 'thumbnail'=>$thumb_url, |
| 575 | + 'controls'=> 'true', |
| 576 | + 'durationHint' => $length, |
| 577 | + 'startOffset' => $offset, |
| 578 | + 'linkback' => $linkAttribs['href'] |
| 579 | + ); |
| 580 | + |
| 581 | + if( $wgEnableTemporalOggUrls ) |
| 582 | + $videoAttr['URLTimeEncoding'] = 'true'; |
| 583 | + |
| 584 | + $s = Xml::tags( 'video', $videoAttr, |
| 585 | + Xml::tags('div', array( |
| 586 | + 'style'=>"overflow:hidden;". |
| 587 | + "width:{$width}px;height:{$playerHeight}px" |
| 588 | + ), |
| 589 | + wfMsg('ogg-no-player-js', $url) |
| 590 | + ) |
566 | 591 | ); |
567 | | - } else { |
568 | | - // make an icon later if necessary |
569 | | - $imgAttribs = false; |
570 | | - $showDescIcon = !$this->noIcon; |
571 | | - //$thumbDivAttribs = array( 'style' => 'text-align: right;' ); |
572 | | - } |
573 | | - $msgStartPlayer = wfMsg( 'ogg-play-sound' ); |
574 | | - $playerHeight = 35; |
575 | | - } |
576 | | - |
577 | | - // Set $thumb to the thumbnail img tag, or the thing that goes where |
578 | | - // the thumbnail usually goes |
579 | | - $descIcon = false; |
580 | | - if ( !empty( $options['desc-link'] ) ) { |
581 | | - $linkAttribs = $this->getDescLinkAttribs( $alt ); |
582 | | - if ( $showDescIcon ) { |
583 | | - // Make image description icon link |
| 592 | + |
| 593 | + return $s; |
| 594 | + |
| 595 | + |
| 596 | + }else{ |
| 597 | + //oggHandler output: |
| 598 | + |
| 599 | + if ( $this->isVideo ) { |
| 600 | + $msgStartPlayer = wfMsg( 'ogg-play-video' ); |
584 | 601 | $imgAttribs = array( |
585 | | - 'src' => "$scriptPath/info.png", |
586 | | - 'width' => 22, |
587 | | - 'height' => 22, |
588 | | - 'alt' => $alt, |
589 | | - ); |
590 | | - $linkAttribs['title'] = wfMsg( 'ogg-desc-link' ); |
591 | | - $descIcon = Xml::tags( 'a', $linkAttribs, |
592 | | - Xml::element( 'img', $imgAttribs ) ); |
593 | | - $thumb = ''; |
594 | | - } elseif ( $imgAttribs ) { |
595 | | - $thumb = Xml::tags( 'a', $linkAttribs, |
596 | | - Xml::element( 'img', $imgAttribs ) ); |
| 602 | + 'src' => $this->url, |
| 603 | + 'width' => $width, |
| 604 | + 'height' => $height, |
| 605 | + 'alt' => $alt ); |
| 606 | + $playerHeight = $height; |
597 | 607 | } else { |
598 | | - $thumb = ''; |
| 608 | + // Sound file |
| 609 | + if ( $height > 100 ) { |
| 610 | + // Use a big file icon |
| 611 | + global $wgStylePath; |
| 612 | + $imgAttribs = array( |
| 613 | + 'src' => "$wgStylePath/common/images/icons/fileicon-ogg.png", |
| 614 | + 'width' => 125, |
| 615 | + 'height' => 125, |
| 616 | + 'alt' => $alt, |
| 617 | + ); |
| 618 | + } else { |
| 619 | + // make an icon later if necessary |
| 620 | + $imgAttribs = false; |
| 621 | + $showDescIcon = !$this->noIcon; |
| 622 | + //$thumbDivAttribs = array( 'style' => 'text-align: right;' ); |
| 623 | + } |
| 624 | + $msgStartPlayer = wfMsg( 'ogg-play-sound' ); |
| 625 | + $playerHeight = 35; |
599 | 626 | } |
600 | | - $linkUrl = $linkAttribs['href']; |
601 | | - } else { |
602 | | - // We don't respect the file-link option, click-through to download is not appropriate |
603 | | - $linkUrl = false; |
604 | | - if ( $imgAttribs ) { |
605 | | - $thumb = Xml::element( 'img', $imgAttribs ); |
| 627 | + |
| 628 | + // Set $thumb to the thumbnail img tag, or the thing that goes where |
| 629 | + // the thumbnail usually goes |
| 630 | + $descIcon = false; |
| 631 | + if ( !empty( $options['desc-link'] ) ) { |
| 632 | + $linkAttribs = $this->getDescLinkAttribs( $alt ); |
| 633 | + if ( $showDescIcon ) { |
| 634 | + // Make image description icon link |
| 635 | + $imgAttribs = array( |
| 636 | + 'src' => "$scriptPath/info.png", |
| 637 | + 'width' => 22, |
| 638 | + 'height' => 22, |
| 639 | + 'alt' => $alt, |
| 640 | + ); |
| 641 | + $linkAttribs['title'] = wfMsg( 'ogg-desc-link' ); |
| 642 | + $descIcon = Xml::tags( 'a', $linkAttribs, |
| 643 | + Xml::element( 'img', $imgAttribs ) ); |
| 644 | + $thumb = ''; |
| 645 | + } elseif ( $imgAttribs ) { |
| 646 | + $thumb = Xml::tags( 'a', $linkAttribs, |
| 647 | + Xml::element( 'img', $imgAttribs ) ); |
| 648 | + } else { |
| 649 | + $thumb = ''; |
| 650 | + } |
| 651 | + $linkUrl = $linkAttribs['href']; |
606 | 652 | } else { |
607 | | - $thumb = ''; |
| 653 | + // We don't respect the file-link option, click-through to download is not appropriate |
| 654 | + $linkUrl = false; |
| 655 | + if ( $imgAttribs ) { |
| 656 | + $thumb = Xml::element( 'img', $imgAttribs ); |
| 657 | + } else { |
| 658 | + $thumb = ''; |
| 659 | + } |
608 | 660 | } |
609 | | - } |
610 | | - |
611 | | - $id = "ogg_player_" . OggTransformOutput::$serial; |
612 | | - |
613 | | - $playerParams = Xml::encodeJsVar( (object)array( |
614 | | - 'id' => $id, |
615 | | - 'videoUrl' => $url, |
616 | | - 'width' => $width, |
617 | | - 'height' => $playerHeight, |
618 | | - 'length' => $length, |
619 | | - 'offset' => $offset, |
620 | | - 'linkUrl' => $linkUrl, |
621 | | - 'isVideo' => $this->isVideo ) ); |
622 | | - |
623 | | - $s = Xml::tags( 'div', |
624 | | - array( |
625 | | - 'id' => $id, |
626 | | - 'style' => "width: {$width}px;" ), |
627 | | - ( $thumb ? Xml::tags( 'div', array(), $thumb ) : '' ) . |
628 | | - Xml::tags( 'div', array(), |
629 | | - Xml::tags( 'button', |
630 | | - array( |
631 | | - 'onclick' => "if (typeof(wgOggPlayer) != 'undefined') wgOggPlayer.init(false, $playerParams);", |
632 | | - 'style' => "width: {$width}px; text-align: center", |
633 | | - 'title' => $msgStartPlayer, |
634 | | - ), |
635 | | - Xml::element( 'img', |
636 | | - array( |
637 | | - 'src' => "$scriptPath/play.png", |
638 | | - 'width' => 22, |
639 | | - 'height' => 22, |
640 | | - 'alt' => $msgStartPlayer |
| 661 | + |
| 662 | + $id = "ogg_player_" . OggTransformOutput::$serial; |
| 663 | + |
| 664 | + $playerParams = Xml::encodeJsVar( (object)array( |
| 665 | + 'id' => $id, |
| 666 | + 'videoUrl' => $url, |
| 667 | + 'width' => $width, |
| 668 | + 'height' => $playerHeight, |
| 669 | + 'length' => $length, |
| 670 | + 'offset' => $offset, |
| 671 | + 'linkUrl' => $linkUrl, |
| 672 | + 'isVideo' => $this->isVideo ) ); |
| 673 | + |
| 674 | + $s = Xml::tags( 'div', |
| 675 | + array( |
| 676 | + 'id' => $id, |
| 677 | + 'style' => "width: {$width}px;" ), |
| 678 | + ( $thumb ? Xml::tags( 'div', array(), $thumb ) : '' ) . |
| 679 | + Xml::tags( 'div', array(), |
| 680 | + Xml::tags( 'button', |
| 681 | + array( |
| 682 | + 'onclick' => "if (typeof(wgOggPlayer) != 'undefined') wgOggPlayer.init(false, $playerParams);", |
| 683 | + 'style' => "width: {$width}px; text-align: center", |
| 684 | + 'title' => $msgStartPlayer, |
| 685 | + ), |
| 686 | + Xml::element( 'img', |
| 687 | + array( |
| 688 | + 'src' => "$scriptPath/play.png", |
| 689 | + 'width' => 22, |
| 690 | + 'height' => 22, |
| 691 | + 'alt' => $msgStartPlayer |
| 692 | + ) |
641 | 693 | ) |
642 | 694 | ) |
643 | | - ) |
644 | | - ) . |
645 | | - ( $descIcon ? Xml::tags( 'div', array(), $descIcon ) : '' ) |
646 | | - ); |
647 | | - return $s; |
| 695 | + ) . |
| 696 | + ( $descIcon ? Xml::tags( 'div', array(), $descIcon ) : '' ) |
| 697 | + ); |
| 698 | + return $s; |
| 699 | + } |
648 | 700 | } |
649 | 701 | } |
650 | 702 | |
Index: trunk/extensions/OggHandler/OggHandler.i18n.php |
— | — | @@ -27,6 +27,9 @@ |
28 | 28 | 'ogg-play-sound' => 'Play sound', |
29 | 29 | 'ogg-no-player' => 'Sorry, your system does not appear to have any supported player software. |
30 | 30 | Please <a href="http://www.mediawiki.org/wiki/Extension:OggHandler/Client_download">download a player</a>.', |
| 31 | + 'ogg-no-player-js' => 'Sorry, your system either has javascript disabled or does not have any supported player.<br> |
| 32 | +You can <a href="$1">Download the clip</a><br> or <br><a href="http://www.mediawiki.org/wiki/Extension:OggHandler/Client_download">download a player</a> |
| 33 | +to play the clip in your browser.', |
31 | 34 | 'ogg-no-xiphqt' => 'You do not appear to have the XiphQT component for QuickTime. |
32 | 35 | QuickTime cannot play Ogg files without this component. |
33 | 36 | Please <a href="http://www.mediawiki.org/wiki/Extension:OggHandler/Client_download">download XiphQT</a> or choose another player.', |