Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This is an iOS compatible method of embedding a video from SharePoint, if blob storage is not enabled.
<!--
via: https://www.linkedin.com/pulse/play-video-file-from-sharepoint-document-library-mobile-hai-nguyen
alt: https://threewill.com/sharepoint-videos-in-ios-safari-iphone-ipad-unforgiving/
-->
<video controls="true" style="min-height:360px;width:100%;">
<source src="/PublishingImages/your-video.mp4">
Sorry, your browser does not support playback of this video.
</video>
<script>
if (/iPhone|iPad|iPod/i.test(navigator.userAgent) || document.location.search.indexOf('video-ios-test') != -1) {
var source = jQuery("video source[src$=mp4]").attr('src');
var req = new XMLHttpRequest();
req.open('GET', source, true);
req.responseType = 'blob';
req.onload = function () {
if (this.status === 200) {
var videoBlob = this.response;
var vid = URL.createObjectURL(videoBlob);
jQuery('#iOSVideo').html('<a href="'+vid+'">Video ready! Click here to watch.</a>')
jQuery("video source[src$=mp4]").attr('src', vid)
} else {
jQuery('#iOSVideo').html('sorry, video could not be loaded.');
}
}
req.onerror = function () {
jQuery('#iOSVideo').html('sorry, there was an error loading the video.');
}
req.send();
jQuery('video').after('<span id="iOSVideo">Please wait, video is loading... <i class="fa fa-spinner fa-spin"></i></span>');
jQuery('video').hide().attr('controls', 'false');
}
</script>
@alirobe

This comment has been minimized.

Copy link
Owner Author

@alirobe alirobe commented Jun 21, 2018

this should be saved as a text file in the style library, and referenced through a CEWP file link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment