Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native HTML5 video player #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions Source/mediaboxAdv.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ var Mediabox;
buttonText: ['<big>&laquo;</big>','<big>&raquo;</big>','<big>&times;</big>'], // Array defines "previous", "next", and "close" button content (HTML code should be written as entity codes or properly escaped)
// buttonText: ['<big>«</big>','<big>»</big>','<big>×</big>'],
// buttonText: ['<b>P</b>rev','<b>N</b>ext','<b>C</b>lose'],
counterText: '({x} of {y})', // Counter text, {x} = current item number, {y} = total gallery length
counterText: '({x} / {y})', // Counter text, {x} = current item number, {y} = total gallery length
linkText: '<a href="{x}" target="_new">{x}</a><br/>open in a new tab</div>', // Text shown on iOS devices for non-image links
flashText: '<b>Error</b><br/>Adobe Flash is either not installed or not up to date, please visit <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" title="Get Flash" target="_new">Adobe.com</a> to download the free player.', // Text shown if Flash is not installed.
// General overlay options
Expand Down Expand Up @@ -396,6 +396,21 @@ var Mediabox;
preload = new Image();
preload.onload = startEffect;
preload.src = URL;
// HTML5 Video
} else if (URL.match(/\.mts|\.mp4|\.avi/i)) {
mediaType = 'video';
mediaWidth = mediaWidth || options.defaultWidth;
mediaHeight = mediaHeight || options.defaultHeight;
mediaId = "mediaId_"+new Date().getTime(); // Safari may not update iframe content with a static id.
preload = new Element('video', {
'src': URL,
'id': mediaId,
'width': mediaWidth,
'height': mediaHeight,
'frameborder': 0,
'controls': 1
});
startEffect();
// FLV, MP4
} else if (URL.match(/\.flv|\.mp4/i) || mediaType == 'video') {
mediaType = 'obj';
Expand Down Expand Up @@ -853,6 +868,9 @@ var Mediabox;
media.setStyles({backgroundImage: "none", display: ""});
preload.inject(media);
// if (Browser.safari) options.resizeOpening = false; // Prevents occasional blank video display errors in Safari, thanks to Kris Gale for the solution
} else if (mediaType == "video") {
media.setStyles({backgroundImage: "none", display: ""});
preload.inject(media);
} else if (mediaType == "obj") {
if (Browser.Plugins.Flash.version < "8") {
media.setStyles({backgroundImage: "none", display: ""});
Expand Down Expand Up @@ -973,4 +991,4 @@ Mediabox.scanPage = function() {
});
};

window.addEvents({domready: Mediabox.scanPage, resize: Mediabox.recenter}); // to recenter the overlay while scrolling, add "scroll: Mediabox.recenter" to the object
window.addEvents({domready: Mediabox.scanPage, resize: Mediabox.recenter}); // to recenter the overlay while scrolling, add "scroll: Mediabox.recenter" to the object