Skip to content

Instantly share code, notes, and snippets.

@alirobe
Last active June 21, 2018 01:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alirobe/c30c6fac29b5cb7100d3e26bb74437e3 to your computer and use it in GitHub Desktop.
Save alirobe/c30c6fac29b5cb7100d3e26bb74437e3 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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