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
|
<?php
/**
* Adds iframe output ( bug 25862 )
*
* This enables iframe based embeds of the wikimeia player with the following syntax:
*
* <iframe src="http://commons.wikimedia.org/wiki/File:Folgers.ogv?embedplayer=yes"
* width="240" height="180" frameborder="0" ></iframe>
*
*/
class TimedMediaIframeOutput {
/**
* The iframe hook check file pages embedplayer=yes
* @param $title Title
* @param $article Article
* @param bool $doOutput
* @return bool
*/
static function iframeHook( &$title, &$article, $doOutput = true ) {
global $wgRequest, $wgOut, $wgEnableIframeEmbed;
if( !$wgEnableIframeEmbed )
return true; //continue normal output iframes are "off" (maybe throw a warning in the future)
// Make sure we are in the right namespace and iframe=true was called:
if( is_object( $title ) && $title->getNamespace() == NS_FILE &&
$wgRequest->getVal('embedplayer') == 'yes' &&
$wgEnableIframeEmbed &&
$doOutput ){
if ( self::outputIframe( $title ) ) {
// Turn off output of anything other than the iframe
$wgOut->disable();
}
}
return true;
}
/**
* Output an iframe
* @param $title Title
* @throws Exception
*/
static function outputIframe( $title ) {
global $wgEnableIframeEmbed, $wgOut, $wgUser, $wgBreakFrames;
if( !$wgEnableIframeEmbed ){
return false;
}
// Setup the render parm
$file = wfFindFile( $title );
if ( !$file ) {
// file was removed, show wiki page with warning
return false;
}
$params = array(
'fillwindow' => true
);
$videoTransform = $file->transform( $params );
// Definitely do not want to break frames
$wgBreakFrames = false;
$wgOut->allowClickjacking();
$wgOut->addModules( array( 'embedPlayerIframeStyle', 'mw.EmbedPlayer' ) );
$wgOut->sendCacheControl();
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8" />
<title><?php echo $title->getText() ?></title>
<?php
echo Html::element( 'meta', array( 'name' => 'ResourceLoaderDynamicStyles', 'content' => '' ) );
?>
<?php
echo implode( "\n", $wgOut->getHeadLinksArray() );
echo implode( "\n", $wgOut->getHeadLinksArray() );
?>
<style type="text/css">
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
overflow:hidden;
}
img#bgimage {
position:fixed;
top:0;
left:0;
width:100%;
height:100%;
}
.videoHolder {
position:relative;
}
</style>
<?php echo $wgOut->getHeadScripts(); ?>
<script>
window.RLQ = window.RLQ || [];
window.RLQ.push( function() {
mw.loader.using( 'mw.MwEmbedSupport', function() {
mw.setConfig('EmbedPlayer.RewriteSelector', '');
} );
// Turn off rewrite selector. This prevents automatic conversion of
// <video> tags, since we are going to do that ourselves later.
} );
</script>
</head>
<body>
<img src="<?php echo $videoTransform->getUrl() ?>" id="bgimage" ></img>
<div id="videoContainer" style="visibility:hidden">
<?php echo $videoTransform->toHtml(); ?>
</div>
<?php echo $wgOut->getBottomScripts(); ?>
<script>
window.RLQ.push( function() {
mw.loader.using( 'mw.MwEmbedSupport', function() {
// only enable fullscreen if enabled in iframe
mw.setConfig('EmbedPlayer.EnableFullscreen', document.fullscreenEnabled || document.webkitFullscreenEnabled || document.mozFullScreenEnabled || false );
$('#bgimage').remove();
mw.setConfig( 'EmbedPlayer.IsIframeServer', true );
// rewrite player
$( '#<?php echo TimedMediaTransformOutput::PLAYER_ID_PREFIX . '0' ?>' ).embedPlayer(function(){
// Bind window resize to reize the player:
var fitPlayer = function(){
$( '#<?php echo TimedMediaTransformOutput::PLAYER_ID_PREFIX . '0' ?>' )
[0].updateLayout();
}
$( window ).resize( fitPlayer );
$('#videoContainer').css({
'visibility':'visible'
} );
fitPlayer();
} );
} );
} );
</script>
</body>
</html>
<?php
return true;
}
}
|