(function () { /*** Get included script tag, here we will embed player */ var existing_script_tag = document.getElementById( 'filesfm_embed_js__dk8dvupsj' ); /*** Embed container ***/ var embed_container_id = 'filesfm_embed_container__dk8dvupsj__2w44ewj6w9u9zkx2'; var embed_container = document.createElement( 'div' ); embed_container.id = embed_container_id; embed_container.className = "filesfm__embed_player__container"; embed_container.style.position = 'relative'; existing_script_tag.parentNode.insertBefore( embed_container, existing_script_tag ); /* Set container size */ embed_container.style.width = '100%'; embed_container.style.height = 'auto'; embed_container.style.minHeight = '30px'; embed_container.style.maxHeight = '100%'; embed_container.style.maxWidth = '100%'; embed_container.style.overflow = 'hidden'; var autoload = true; var autoplay = false; var poster_img_orginal_width = null; var poster_img_orginal_height = null; var poster_url = null; var poster = null; /*** If autoplay is disabled and we have poster, show poster and play button, init player on click ***/ if ( ! autoload && ! autoplay ) { if ( poster_url ) { var posterImg = new Image(); posterImg.onload = function() { poster_img_orginal_width = this.width; poster_img_orginal_height = this.height; poster = document.createElement( 'img' ); poster.id = embed_container_id + '_poster'; poster.src = poster_url; poster.style.width = '100%'; poster.style.maxHeight = '100%'; poster.style.display = 'block'; poster.style.opacity = '1'; poster.style.margin = '0 auto'; // poster.style.position = "relative"; // temp fix for public profile -> don't center the image TODO if ( typeof( publicProfile ) === "undefined" || !publicProfile ) { // poster.style.top = "50%"; // poster.style.transform = "translateY(-50%)" } poster.onload = function ( event ){ poster.proportion = poster.height / poster.width; refreshSize(); } embed_container.appendChild( poster ); /* poster.onload = function (){ embed_container.style.height = window.getComputedStyle(poster,null).getPropertyValue("height"); } */ }; posterImg.src = poster_url; window.addEventListener('resize', refreshSize); } var play_button_id = "filesfm_embed_palyer__play_button__dk8dvupsj__2w44ewj6w9u9zkx2"; var play_button = document.createElement('svg'); embed_container.appendChild( play_button ); play_button.outerHTML = getPlayButton(); play_button = document.getElementById( play_button_id ); play_button.style.zIndex=1; play_button.style.position="absolute"; play_button.style.cursor='pointer'; play_button.style.top = "50%"; play_button.style.left = "50%"; play_button.style.height = "10vh"; play_button.style.minHeight = "60px"; play_button.style.width = "10vh"; play_button.style.minWidth = "60px"; play_button.style.transform = "translate( -50%, -50% )"; play_button.className = "filesfm_embed_palyer__play_button"; play_button.onclick = function () { play_button.style.display = 'none'; autoplay = true; initPlayer() }; } else { initPlayer(); } function initPlayer () { /*****************************/ /* Embed preloader */ var preloader = document.createElement( 'svg' ); embed_container.appendChild( preloader ); preloader.outerHTML = getPreloader(); preloader = document.getElementById("preloader_dk8dvupsj__2w44ewj6w9u9zkx2"); /*****************************/ /******************************************************/ /* If WebTorrent library is not included, include it. */ if ( typeof( FilesFm_P2P ) == 'undefined' ) { var script = document.createElement( 'script' ); script.type = 'text/javascript'; script.async = true; script.onload = function () { // Construct player filesfm_ep_loaded(); }; script.src = 'https://files.fm/webtorrent/FilesFm_P2P/filesfm_p2p.min.js?v=1002'; existing_script_tag.parentNode.insertBefore( script, existing_script_tag ); } else { // Construct player filesfm_ep_loaded(); } /******************************************************/ } var resResizeTimeout = null; function refreshSize() { if ( poster && poster.proportion && poster.width ) { if ( resResizeTimeout !== null ) clearTimeout( resResizeTimeout ); resResizeTimeout = setTimeout (function (){ if ( poster_img_orginal_width != null ) { if ( poster_img_orginal_width > poster_img_orginal_height ) { embed_container.style.width = poster_img_orginal_width; embed_container.style.height = 'auto'; } else { embed_container.style.width = 'auto'; embed_container.style.height = document.getElementById( embed_container.id ).offsetHeight; } if ( document.getElementById( embed_container.id ).offsetHeight > document.getElementById( embed_container.id ).parentElement.offsetHeight ) { embed_container.style.width = 'auto'; embed_container.style.height = document.getElementById( embed_container.id ).parentElement.offsetHeight; } if ( document.getElementById( embed_container.id ).offsetWidth > document.getElementById( embed_container.id ).parentElement.offsetWidth ) { embed_container.style.width = document.getElementById( embed_container.id ).parentElement.offsetWidth; embed_container.style.height = 'auto'; } } else { embed_container.style.height = (poster.width * poster.proportion) + 'px'; } }, 50); } } /* Construct player, download one file and append it to container. */ function filesfm_ep_loaded() { if ( ! FilesFm_P2P.WEBRTC_SUPPORT ) { showErrorMessagedk8dvupsj__2w44ewj6w9u9zkx2( 'Sorry, your web browser does not support downloading with WebTorrent, please use another browser.' ) } else { var config = { tracker: { rtcConfig: { "iceServers": [{"urls": ["stun:stun.files.fm:443"], "username": "filesfm", "credential": "password", "credentialType": "password"},{"urls": ["turn:stun.files.fm:443"], "username": "filesfm", "credential": "password", "credentialType": "password" }] } } }; config.WebRequests_QueryString = 'PHPSESSID=de08e8d605ae9e05307998dcadb24e8bb057acd6'; var objFilesFmP2P = new FilesFm_P2P(config); var files_fm__torrent = null; objFilesFmP2P.addTorrent( 'file', 'dk8dvupsj', function ( torrent ){ files_fm__torrent = torrent; // Torrent file downloaded files_fm__torrent.on( 'ready', function () { // Send presentation type to WebSeed (file download/view) this.presentation_type = 'view'; // Remove default selection (whole torrent) this.deselect( 0, this.pieces.length - 1, false ) // Select only required file, deselect all other. // Append required file to container and do some setup. this.files.forEach( function ( file ) { if ( file.name != 'Royal Blue [Vegeta New Form] Dragon Ball Super Epic Orchestr.mp3' ) { file.deselect(); } else { if (current_file!==null) return; var mimetype = file._getMimeType(); current_file = file; // Append only certain file types if (mimetype && ( mimetype.indexOf('video/mp4')===0 || mimetype.indexOf('video/m4v')===0 || mimetype.indexOf('video/m4a')===0 || mimetype.indexOf('video/mkv')===0 || mimetype.indexOf('video/webm')===0 || mimetype.indexOf('video/ogg')===0 || mimetype.indexOf('audio')===0 || mimetype.indexOf('image')===0 || mimetype.indexOf('application/pdf')===0 )) { // Embed file to container file.appendTo( embed_container, { autoplay: autoplay}, function (err, elem){ if ( poster ) poster.style.display = 'none'; if ( document.getElementById("preloader_dk8dvupsj__2w44ewj6w9u9zkx2") ) document.getElementById("preloader_dk8dvupsj__2w44ewj6w9u9zkx2").style.display = 'none'; } ) var content_dom = embed_container.lastChild; content_dom.style.width = '100%'; content_dom.style.minWidth = '100%'; content_dom.style.minHeight = '35px'; content_dom.style.border = 'none'; if ( poster_url && content_dom.tagName.toLowerCase() == 'video') { if ( poster ) poster.style.display = 'none'; if ( document.getElementById("preloader_dk8dvupsj__2w44ewj6w9u9zkx2") ) document.getElementById("preloader_dk8dvupsj__2w44ewj6w9u9zkx2").style.display = 'none'; content_dom.poster = poster_url; //content_dom.muted = true; } } else { file.getBlobURL(function (err, url){ if ( document.getElementById("preloader_dk8dvupsj__2w44ewj6w9u9zkx2") ) document.getElementById("preloader_dk8dvupsj__2w44ewj6w9u9zkx2").style.display = 'none'; var link = document.createElement('a'); link.href = url; link.innerHTML = 'SAVE AS'; embed_container.appendChild(link); }); } } } ) }); /*******************************************************************************/ /*******************************************************************************/ var current_file = null; } ) } } function getPreloader() { return '' + ''; } function getPlayButton() { return '
'; } })(); function showErrorMessagedk8dvupsj__2w44ewj6w9u9zkx2 ( strErrorMessage ) { var error_container = document.createElement('div'); error_container.style.padding = '10px'; error_container.style.fontSize = '14px'; error_container.style.lineHeight = '20px'; error_container.style.border = '1px solid #ebccd1'; error_container.style.borderRadius = '2px'; error_container.style.color = 'a94442'; error_container.style.backgroundColor = '#f2dede'; error_container.innerHTML = strErrorMessage; // Hide preloader if (document.getElementById('filesfm_embed_container__dk8dvupsj__2w44ewj6w9u9zkx2')) document.getElementById('filesfm_embed_container__dk8dvupsj__2w44ewj6w9u9zkx2').style.display = 'none'; // Hide container if (document.getElementById('preloader_dk8dvupsj__2w44ewj6w9u9zkx2')) document.getElementById('preloader_dk8dvupsj__2w44ewj6w9u9zkx2').style.display = 'none'; var existing_script_tag = document.getElementById('filesfm_embed_js__dk8dvupsj'); existing_script_tag.parentNode.insertBefore(error_container, existing_script_tag); }