Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save steffentchr/655019 to your computer and use it in GitHub Desktop.
Save steffentchr/655019 to your computer and use it in GitHub Desktop.
Example on how to embed and interact with 23 Video players via JA API through both Flash and HTML5
<div id="videoContainer"></div>
<script src="http://stream.umbraco.org/resources/um/script/swfobject/swfobject.js"></script>
<script>
function getFlexApp(appName) {
if (navigator.appName.indexOf ("Microsoft") !=-1) {
return window[appName];
} else {
return document[appName];
}
}
var videoEmbedMethod = null;
if(swfobject.hasFlashPlayerVersion('9.0.0'){
videoEmbedMethod = 'flash';
swfobject.embedSWF("http://stream.umbraco.org/453933.swf", "videoContainer", "625", "352", "9.0.0", "/resources/um/script/swfobject/expressInstall.swf", {search:'hartvig', showBigPlay:'0'}, {allowscriptaccess:'always', allowfullscreen:'true'}, {id:'video', name:'video'});
function play() {getFlexApp('video').playVideo();}
function pause() {getFlexApp('video').pauseVideo();}
} else {
videoEmbedMethod = 'html5';
var video = null;
function buildPlayer(o) {
if (!o.photos || o.photos.length==0) return;
var p = o.photos[0];
video = document.createElement('video');
video.setAttribute('src', 'http://' + o.site.domain + p.video_medium_download);
video.setAttribute('poster', 'http://' + o.site.domain + p.standard_download);
video.setAttribute('controls', 'true');
video.setAttribute('preload', 'none');
video.setAttribute('tabindex', 0);
video.setAttribute('width', p.video_medium_width);
video.setAttribute('height', p.video_medium_height);
video.innerHTML = "";
document.getElementById('videoContainer').appendChild(video);
}
document.write(unescape("%3Cscript src='http://stream.umbraco.org/api/photo/list?search=hartvig&size=1&callback=buildPlayer&format=json' type='text/javascript'%3E%3C/script%3E"));
}
function play(){
if(videoEmbedMethod=='flash')
getFlexApp('video').playVideo();
else if(videoEmbedMethod=='flash')
if(video) video.play();
}
function pause(){
if(videoEmbedMethod=='flash')
getFlexApp('video').pauseVideo();
else if(videoEmbedMethod=='flash')
if(video) video.pause();
}
</script>
<div id="videoContainer"></div>
<script src="http://stream.umbraco.org/resources/um/script/swfobject/swfobject.js"></script>
<script>
function getFlexApp(appName) {
if (navigator.appName.indexOf ("Microsoft") !=-1) {
return window[appName];
} else {
return document[appName];
}
}
swfobject.embedSWF("http://stream.umbraco.org/453933.swf", "videoContainer", "625", "352", "9.0.0", "/resources/um/script/swfobject/expressInstall.swf", {search:'hartvig', showBigPlay:'0'}, {allowscriptaccess:'always', allowfullscreen:'true'}, {id:'video', name:'video'});
function play() {getFlexApp('video').playVideo();}
function pause() {getFlexApp('video').pauseVideo();}
</script>
<div id="videoContainer"></div>
<script>
var video = null;
function buildPlayer(o) {
if (!o.photos || o.photos.length==0) return;
var p = o.photos[0];
video = document.createElement('video');
video.setAttribute('src', 'http://' + o.site.domain + p.video_medium_download);
video.setAttribute('poster', 'http://' + o.site.domain + p.standard_download);
video.setAttribute('controls', 'true');
video.setAttribute('preload', 'none');
video.setAttribute('tabindex', 0);
video.setAttribute('width', p.video_medium_width);
video.setAttribute('height', p.video_medium_height);
video.innerHTML = "";
document.getElementById('videoContainer').appendChild(video);
}
function play(){if(video) video.play();}
function pause(){if(video) video.pause();}
</script>
<script src="http://stream.umbraco.org/api/photo/list?search=hartvig&size=1&callback=buildPlayer&format=json"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment