Techno download seiten

Download free techno royalty-free audio tracks and instrumentals for your next project.Missing: seiten.
Add to Cart
Buy a License

A new musical sequence in techno dance style, featuring vibrant and immersive melodies that radiate unstoppable energy and overwhelming power, creating an intense and electrifying atmosphere.

Add to Cart
Buy a License

This one is super modern dubstep music with radically syncopated rhythmic percussion sounds, techno riffs, heavy drums, and basses.

Add to Cart
Buy a License

Energizing progressive techno music with the driving hi-tech feel a high energy finale.

Add to Cart
Buy a License

"Paint Your Future" is energetic, experimental, electronic techno music featuring bass, analog drums, synth.

Techno background music

Related tags: MotivationEnergyElectronicTechnologyActionAnimatedVideoEnergeticRoboticDanceSeriousTenseBouncy

Add to Cart
Buy a License

Perfect for technology advertising, futuristic sci-fi movies and action games about alien invasion, robots, etc.

Add to Cart
Buy a License

"Sense of Life" is energetic, underground, club tech house music featuring classical analog house bass, drums, percussion and vocal ..

Add to Cart
Buy a License

There are few techno elements included and the sound of the piano is exceptionally stirring.

Techno royalty free music

Add to Cart
Buy a License

This track immerses you in a futuristic world where science and technology merge in perfect harmony.

Add to Cart
Buy a License

Perfect for any medical, science, and technology projects, video reviews, infographics, innovative and technological projects, promotional videos, slide shows, corporate projects, marketing, product launch, podcasts music, screensavers, television, media, commercial projects, presentations, video explainer, youtube, video tutorials, business, science projects, medical projects, education and more.

Add to Cart
Buy a License

An energetic and forceful royalty-free cyberpunk track with pulsating basslines, cinematic fxs, gritty guitars, and background vocals, best for action-packed scenes, thrilling video games, attention-grabbing commercials, adrenaline-fueled automotive films, or sports ..

Add to Cart
Buy a License

Very hot, driving and powerful acid techno track with trendy synth leads, deep sounds, and punchy beats.

Techno stock music

Add to Cart
Buy a License

Recommended usages: promotional media, uplifting marketing videos, Facebook, Youtube, Vimeo, television, radio, slideshow music, corporate presentations and advertising, films, documentaries, festivals, podcast intro music, videocast, phone on hold, education training, apps/games, audiobooks and projects related to technology, sports, design, fashion, and lifestyle.

Add to Cart
Buy a License

Great background music for your corporate and technological projects, viral marketing, web advertisements, energy-saving devices, green technology, the "smart home" function, and other media needs.

Add to Cart
Buy a License

An excellent choice for technological commercials, new product promo, scientific discoveries and innovations, futuristic commercials, time-lapse videos, car concepts, etc.

Music for Techno videos

Add to Cart
Buy a License

Get ready to elevate your workout routine with this upbeat and energetic electronic track.

Add to Cart
Buy a License

Great for extreme sports, testosterone action, car racing, robotic technology or any visual that need an energy boost.

Add to Cart
Buy a License

This royalty-free track will be perfect as background music for technology promo videos, science videos, sci-fi and documentary films, augmented reality videos, modern developments and innovations projects, design and engineering videos.

Add to Cart
Buy a License

Dark, electrifying, and pumping epic EDM track with a big dose of NRG.

Techno instrumental music

Add to Cart
Buy a License

Great as background music for motivational projects, innovation technologies, traveling videos, advertising, royalty free music for business videos and presentations, the unforgettable journey, and stories of success.

Add to Cart
Buy a License

Perfect for fantasy and tech videos, modern car commercials, exciting space travel, cosmology, gliding through the universe and stars, new technologies, and innovations.

Share this Melody

Link copied to clipboard

`; formDiv.innerHTML = svgContent; } // Function to initialize z-index for music players function initializeMusicPlayersZIndex() { var musicPlayers = document.querySelectorAll('.music_player'); // Adjust the starting zIndex, considering we are skipping the first player. var zIndex = musicPlayers.length; // Start loop from the second element (index 1) if it exists. for (let i = 1; i < musicPlayers.length; i++) { musicPlayers[i].style.zIndex = zIndex--; } } function wwwidth() { return Math.max( document.body.scrollWidth, document.documentElement.scrollWidth, document.body.offsetWidth, document.documentElement.offsetWidth, document.documentElement.clientWidth ); } // Function to collect filenames and prepare a mapping function collectFilenamesAndPrepareMapping() { const musicPlayers = document.querySelectorAll('.music_player'); const filenames = []; const filenameToFormDiv = new Map(); musicPlayers.forEach(player => { const filename = player.getAttribute('filename'); if (filename) { filenames.push(filename); const formDiv = player.querySelector('.waveform'); filenameToFormDiv.set(filename, formDiv); } }); return { filenames, filenameToFormDiv }; } function stopAllAudioExcept(currentAudio) { document.querySelectorAll('audio').forEach(function(audio) { if(audio !== currentAudio) { audio.pause(); var playButton = audio.closest('.music_player').querySelector('.play'); var pauseButton = audio.closest('.music_player').querySelector('.pause'); pauseButton.style.display = 'none'; playButton.style.display = 'inline-block'; } }); } function saveButtonClickData(player, click_type) { if(wwwidth() > 750) var isMobile = 0; else var isMobile = 1; var fname = ""; if(player) fname = player.getAttribute('filename'); else fname = ""; // Prepare data to send const params = new URLSearchParams({ clicktype: click_type, currentUrl: window.location.pathname, filename: fname, ismobile: isMobile }); // URL of the external service const externalUrl = `/get/mobile-action/?${params.toString()}`; // Send data to external URL fetch(externalUrl).catch((error) => { console.error('Error:', error); // Handle any errors }); } function stopAllAudioAndToggleButtons() { // Stop all playing audio var allAudioElements = document.querySelectorAll('audio'); allAudioElements.forEach(function(audio) { audio.pause(); audio.currentTime = 0; // Optional, if you want to reset the audio to the start }); // Hide all pause buttons and show play buttons var allPauseButtons = document.querySelectorAll('.pause'); var allPlayButtons = document.querySelectorAll('.play'); allPauseButtons.forEach(function(pauseButton) { pauseButton.style.display = 'none'; }); allPlayButtons.forEach(function(playButton) { playButton.style.display = 'inline-block'; }); } function getVolumeFromLocalStorage() { const settings = localStorage.getItem('ml.settings'); var volume = 0; if (settings) { try { const parsedSettings = JSON.parse(settings); if (parsedSettings.volume !== undefined) { volume = parsedSettings.volume; } } catch (e) { } } return volume; } function saveLoopSwitchStatus(status) { localStorage.setItem('loopSwitchStatus', status); } // Function to load the loop switch status from localStorage function loadLoopSwitchStatus() { return localStorage.getItem('loopSwitchStatus'); } // Function to initialize the loop switch function initializeLoopSwitch() { var loopSwitch = document.getElementById('looponofSwitch'); if (loopSwitch) { var savedStatus = loadLoopSwitchStatus(); if (savedStatus) { loopSwitch.checked = (savedStatus === 'loop_on'); } // Add event listener for switch changes loopSwitch.addEventListener('change', function () { var loopSwitchStatus = loopSwitch.checked ? 'loop_on' : 'loop_off'; saveLoopSwitchStatus(loopSwitchStatus); saveButtonClickData('', loopSwitchStatus); }); } } function initializeShareButton(player) { var shareButton = player.querySelector('.small_butt_share'); if (shareButton) { shareButton.addEventListener('click', function () { var existingShareWindow = player.querySelector('.share_window'); if (existingShareWindow) { existingShareWindow.remove(); existingShareWindow.style.display = 'none'; //alert("share window is on"); return 0; } // Clone the existing share window element var shareWindow = document.querySelector('#share_window').cloneNode(true); shareWindow.id = ''; // Remove the ID from the cloned element shareWindow.style.display = 'block'; // Make it visible var copiedMessage = shareWindow.querySelector('#share_copied'); copiedMessage.style.display = 'none'; saveButtonClickData(player, "share"); // Append the share window before the .top_line var topLine = player.querySelector('.top_line'); if (topLine) { player.insertBefore(shareWindow, topLine); } // Event listener to close the share window shareWindow.querySelector('.share_close').addEventListener('click', function () { shareWindow.remove(); }); // Function to get the URL function getTrackUrl() { var filename = player.getAttribute('filename'); return 'https://www.melodyloops.com/tracks/' + filename + '/'; } // Function to get the track name function getTrackName() { return player.getAttribute('tracktitle'); } // Event listener for copying link var copyLinkButton = shareWindow.querySelector('#share_copy_link'); copyLinkButton.addEventListener('click', function () { var url = getTrackUrl(); // Function to copy text to clipboard function copyTextToClipboard(text) { if (navigator.clipboard && navigator.clipboard.writeText) { return navigator.clipboard.writeText(text); } else { return new Promise(function (resolve, reject) { var textArea = document.createElement("textarea"); textArea.value = text; textArea.style.position = "fixed"; // Avoid scrolling to bottom document.body.appendChild(textArea); textArea.focus(); textArea.select(); try { document.execCommand('copy'); document.body.removeChild(textArea); resolve(); } catch (err) { document.body.removeChild(textArea); reject(err); } }); } } copyTextToClipboard(url).then(function() { // Hide all share buttons shareWindow.querySelectorAll('#share_copy_link, #share_facebook, #share_twitter, #share_email').forEach(function(button) { button.style.display = 'none'; }); // Show the copied message var copiedMessage = shareWindow.querySelector('#share_copied'); copiedMessage.style.display = 'block'; // Hide the share window after 5 seconds setTimeout(function () { shareWindow.remove(); }, 1500); }).catch(function(error) { console.error('Error copying text: ', error); }); }); // Event listener for Facebook sharing var facebookButton = shareWindow.querySelector('#share_facebook'); facebookButton.addEventListener('click', function () { var url = getTrackUrl(); var trackName = getTrackName(); var facebookUrl = 'https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(url) + '"e=' + encodeURIComponent('Listen to ' + trackName + ' on Melody Loops'); window.open(facebookUrl, '_blank'); shareWindow.remove(); }); // Event listener for Twitter sharing var twitterButton = shareWindow.querySelector('#share_twitter'); twitterButton.addEventListener('click', function () { var url = getTrackUrl(); var trackName = getTrackName(); var twitterUrl = 'https://twitter.com/intent/tweet?url=' + encodeURIComponent(url) + '&text=' + encodeURIComponent('Listen to ' + trackName + ' on Melody Loops'); window.open(twitterUrl, '_blank'); shareWindow.remove(); }); // Event listener for Email sharing var emailButton = shareWindow.querySelector('#share_email'); emailButton.addEventListener('click', function () { var url = getTrackUrl(); var trackName = getTrackName(); var subject = encodeURIComponent('Listen to ' + trackName + ' on Melody Loops'); var body = encodeURIComponent('Check out this track on Melody Loops: ' + url); var emailUrl = 'mailto:?subject=' + subject + '&body=' + body; window.location.href = emailUrl; shareWindow.remove(); }); }); } } // Function to initialize a single music player function initializeMusicPlayer(player) { var audioElement = player.querySelector('audio'); var duration = audioElement.duration; var playButton = player.querySelector('.play'); var pauseButton = player.querySelector('.pause'); var progressBar = player.querySelector('.progressbaa'); var timeDisplay = player.querySelector('.time'); var waveContainer = player.querySelector('.wave'); var blendBar = player.querySelector('.blend'); var hasBeenPlayed = false; var favoriteButton = player.querySelector('.small_butt_favorites'); var isFavorite = player.getAttribute('favorites') === '1'; var cartDropdown = player.querySelector('.cart_dropdown'); var cartButton = player.querySelector('.small_butt_cart'); var addToCartButton = player.querySelector('.add_to_cart'); var buyNowButton = player.querySelector('.buy_now'); var explosionDiv = player.querySelector('.favorites_explosion'); var cartActionDiv = player.querySelector('.cart_action'); var trackId = player.getAttribute('trackid'); var storedTrackIds = JSON.parse(localStorage.getItem('ml.cart::tracks') || '[]'); var cartTotal = document.querySelector('.cart_total'); var preloadingBar = player.querySelector('.preloading'); var isMobile = 1; var versionsList = player.querySelector('.versions'); var activeItem = versionsList.querySelector('.active_track'); var wasPassiveTrackPlayed = false; var clickProgress = 0; var audioVolume = getVolumeFromLocalStorage(); // Check if passive tracks are present var hasPassiveTracks = false; // Initialize a variable to keep track of passive tracks visibility var passiveTracksVisible = false; initializeShareButton(player); function handleVersionSelection(player, trackLi, isPassiveTrack) { var audioElement = player.querySelector('audio'); var waveformContainer = player.querySelector('.waveform'); var playButton = player.querySelector('.play'); var pauseButton = player.querySelector('.pause'); var baseFilename = player.getAttribute('filename'); var newUrlSuffix = trackLi.getAttribute('url') || ''; // Empty string for active_track stopAllAudioAndToggleButtons(); var allTracks = player.querySelectorAll('.active_track'); allTracks.forEach(function(track) { track.classList.remove('bold'); }); // Add 'bold' class to the clicked track trackLi.classList.add('bold'); // Update audio sources audioElement.querySelectorAll('source').forEach(function(source) { var extension = source.src.split('.').pop(); var newSrc = `https://cdn2.melodyloops.com/mp3/preview-${baseFilename}.${extension}`; source.src = newSrc; }); audioElement.load(); // Update waveform SVG fetch(`/i/svgw/${baseFilename}.svg`) .then(response => { if (!response.ok) { throw new Error('SVG not found'); } return response.text(); }) .then(svgData => { waveformContainer.innerHTML = svgData; waveformContainer.style.width = '100%'; }) .catch(error => { console.error('Error fetching SVG:', error); waveformContainer.innerHTML = ' '; waveformContainer.style.width = '100%'; }); saveButtonClickData(player, "versions"); if (audioVolume > 0) audioElement.volume = audioVolume; audioElement.play(); hasBeenPlayed = true; playButton.style.display = 'none'; pauseButton.style.display = 'inline-block'; } // Toggle the favorite class if favorites attribute is '1' if (isFavorite) { favoriteButton.classList.add('small_butt_favorites_active'); } // Check if the current player's track ID is in the stored track IDs if (storedTrackIds.includes(trackId)) { addToCartButton.classList.add('small_butt_cart_in'); } function updateCartTotal(cartTracks) { // Update the cart total element's innerHTML if (cartTotal) { cartTotal.innerHTML = cartTracks.length; } } function updatePreloadingBar() { if (audioElement.buffered.length > 0 && audioElement.duration > 0) { var bufferedEnd = audioElement.buffered.end(audioElement.buffered.length - 1); var percent = (bufferedEnd / audioElement.duration) * 100; preloadingBar.style.width = percent + '%'; } } // Event listener for when the browser is loading audio data audioElement.addEventListener('progress', updatePreloadingBar); // Check loading progress periodically, as 'progress' event might not always fire var loadingCheckInterval = setInterval(updatePreloadingBar, 1000); // Clean up the interval when the audio is fully loaded audioElement.addEventListener('canplaythrough', function() { clearInterval(loadingCheckInterval); }); // Add to Cart addToCartButton.addEventListener('click', function() { var cartTracks = JSON.parse(localStorage.getItem('ml.cart::tracks') || '[]'); var tracksLookup = JSON.parse(localStorage.getItem('ml.tracksLookup') || '{}'); // Check if the track ID is not already in the cart if (!cartTracks.includes(trackId)) { cartTracks.push(trackId); localStorage.setItem('ml.cart::tracks', JSON.stringify(cartTracks)); saveButtonClickData(player, "add"); // Construct track details object var duration = player.getAttribute('duration'); var title = player.getAttribute('tracktitle'); var favorite = player.getAttribute('favorites') === '1'; var authorName = player.getAttribute('author_name'); var authorUrl = player.getAttribute('author_url'); var audioSources = Array.from(player.querySelectorAll('audio source')).map(source => source.src); // Update tracksLookup tracksLookup[trackId] = { "refs": 1, "track": { "id": trackId, "availableDurations": [], "ext": "", "progress": 0, "duration": duration, "favorite": favorite, "title": title, "sources": audioSources, "author": { "name": authorName, "url": authorUrl, } } }; localStorage.setItem('ml.tracksLookup', JSON.stringify(tracksLookup)); const actionRect = cartActionDiv.getBoundingClientRect(); const centerX = actionRect.width / 2 - 15; // Center X position const centerY = actionRect.height / 2 - 15; // Center Y position for (let i = 0; i < 10; i++) { const star = document.querySelector('.cart_note').cloneNode(true); const randomColor = `#${Math.floor(Math.random()*16777215).toString(16)}`; // Set initial position of stars at the top with random x-coordinate star.style.left = Math.random() * actionRect.width + 'px'; star.style.top = '0px'; // Apply random color for each star star.querySelectorAll('.svg-style').forEach(element => { element.style.fill = randomColor; element.style.stroke = randomColor; }); cartActionDiv.appendChild(star); // Make star visible and move to center setTimeout(() => { star.style.opacity = '1'; // Make star visible star.style.transform = `translate(${centerX - star.offsetLeft}px, ${centerY - star.offsetTop}px)`; }, 20 * i); // Hide star after moving to center setTimeout(() => { star.style.opacity = '0'; // Fade out setTimeout(() => star.remove(), 100); // Remove after fade out }, 300 + 10 * i); // Adjust timing as needed } // Change cart button to active state addToCartButton.classList.add('small_butt_cart_in'); } // Hide the cart dropdown if (cartDropdown) { cartDropdown.style.display = 'none'; } updateCartTotal(cartTracks); }); //On click Buy Now button go to checkout buyNowButton.addEventListener('click', function() { // Redirect to the checkout page with the track ID saveButtonClickData(player, "buy"); window.location.href = '/order/checkout/?id=' + encodeURIComponent(trackId); }); //On click Download button var downloadButton = player.querySelector('.small_butt_download_word'); var freeButton = player.querySelector('.small_butt_free'); var filename = player.getAttribute('filename'); if(downloadButton) downloadButton.addEventListener('click', function() { // Redirect to the download URL saveButtonClickData(player, "longo"); window.location.href = '/my-music/longoloops/' + encodeURIComponent(filename) + '/'; }); if(freeButton) freeButton.addEventListener('click', function() { // Redirect to the download URL saveButtonClickData(player, "longo_free"); window.location.href = '/my-music/longoloops/' + encodeURIComponent(filename) + '/'; }); //UPDATE Favorites var favoritesTotal = document.querySelector('.favorites_total'); favoriteButton.replaceWith(favoriteButton.cloneNode(true)); favoriteButton = player.querySelector('.small_butt_favorites'); // Reassign the explosionDiv after replacing the favoriteButton explosionDiv = player.querySelector('.favorites_explosion'); favoriteButton.addEventListener('click', function() { // Toggle class on favorite button var isFavorite = player.getAttribute('favorites') === '1'; if (!isFavorite) { // Star explosion effect inside favorites_explosion div for (let i = 0; i < 30; i++) { const star = document.createElement('div'); star.className = 'star'; // Position stars at the center of explosionDiv star.style.left = '50%'; star.style.top = '50%'; const angle = Math.random() * Math.PI * 2; const distance = Math.random() * 10 + 25; const deltaX = Math.cos(angle) * distance; const deltaY = Math.sin(angle) * distance; explosionDiv.appendChild(star); setTimeout(() => { star.style.transform = `translate(${deltaX}px, ${deltaY}px)`; star.style.opacity = '0'; setTimeout(() => star.remove(), 500); }, 10); } saveButtonClickData(player, "favsadd"); player.setAttribute('favorites', '1'); } else { saveButtonClickData(player, "favsdel"); player.setAttribute('favorites', '0'); } favoriteButton.classList.toggle('small_butt_favorites_active'); // Send request to server fetch('/get/favorites/?trid=' + trackId) .then(response => response.text()) // assuming the response is plain text .then(data => { // Update favorites total if (favoritesTotal) { favoritesTotal.innerHTML = data; } }) .catch(error => { console.error('Error fetching favorites:', error); }); }); // Function to update the progress bar and time display function updateProgress() { var progressWidth = (audioElement.currentTime / audioElement.duration) * 100; progressBar.style.width = progressWidth + '%'; blendBar.style.width = progressWidth + '%'; timeDisplay.textContent = formatTime(audioElement.currentTime); // Show .time only if progress width is more than 40px if (progressWidth > 0) { progressBar.style.display = 'block'; blendBar.style.display = 'block'; if(clickProgress > 0 && audioElement.currentTime > (clickProgress + 0.2)) { progressBar.style.transition = 'all 0.5s ease-out'; clickProgress = 0; } if (progressBar.offsetWidth > 40) { timeDisplay.style.display = "block"; } else { timeDisplay.style.display = "none"; } } else { progressBar.style.display = 'none'; blendBar.style.display = 'none'; } } // Function to format time in mm:ss function formatTime(seconds) { var minutes = Math.floor(seconds / 60); var seconds = Math.floor(seconds % 60); return minutes.toString().padStart(2, '0') + ':' + seconds.toString().padStart(2, '0'); } function onPlayButtonClick() { player.scrollIntoView({ behavior: 'smooth', block: 'center' }); stopAllAudioExcept(audioElement); if (audioVolume > 0) audioElement.volume = audioVolume; audioElement.play(); playButton.style.display = 'none'; pauseButton.style.display = 'inline-block'; hasBeenPlayed = true; saveButtonClickData(player, "play"); if (window.location.href.includes('longoloops')) { saveButtonClickData(player, "longo_play"); } } function onPauseButtonClick() { audioElement.pause(); pauseButton.style.display = 'none'; playButton.style.display = 'inline-block'; saveButtonClickData(player, "pause"); } playButton.addEventListener('click', onPlayButtonClick); pauseButton.addEventListener('click', onPauseButtonClick); // Update the progress bar and time as the audio plays audioElement.addEventListener('timeupdate', function() { var timeRemaining = duration - audioElement.currentTime; if (timeRemaining <= 0.0) { audioElement.currentTime = 0.0; audioElement.play(); } updateProgress(); }); // Click on wave container to seek waveContainer.addEventListener('click', function (e) { if (hasBeenPlayed) { progressBar.style.transition = 'none'; var waveWidth = waveContainer.clientWidth; var clickPosition = e.offsetX; var clickRatio = clickPosition / waveWidth; audioElement.currentTime = clickRatio * audioElement.duration; clickProgress = audioElement.currentTime; saveButtonClickData(player, "progress"); } }); function onAudioEnded() { var loopSwitch = document.getElementById('looponofSwitch'); var isLoopEnabled = loopSwitch ? loopSwitch.checked : true; progressBar.style.width = '0%'; blendBar.style.width = '0%'; timeDisplay.textContent = formatTime(0); hasBeenPlayed = false; updateProgress(); if (isLoopEnabled) { hasBeenPlayed = true; audioElement.currentTime = 0.0; audioElement.play(); } else { var allPlayers = document.querySelectorAll('.music_player'); var currentIndex = Array.prototype.indexOf.call(allPlayers, player); var nextTrack = allPlayers[currentIndex + 1]; if (nextTrack) { nextTrack.querySelector('.play').click(); } } } // Remove the previous 'ended' event listener, if any if (audioElement._onAudioEnded) { audioElement.removeEventListener('ended', audioElement._onAudioEnded); } // Add the new 'ended' event listener and store it on the element to remove later audioElement._onAudioEnded = onAudioEnded; audioElement.addEventListener('ended', onAudioEnded); } function clearAllPlayers() { var players = document.querySelectorAll('.music_player'); players.forEach(function(player) { var audioElement = player.querySelector('audio'); var playButton = player.querySelector('.play'); var pauseButton = player.querySelector('.pause'); var waveContainer = player.querySelector('.wave'); // Remove all event listeners playButton.replaceWith(playButton.cloneNode(true)); pauseButton.replaceWith(pauseButton.cloneNode(true)); waveContainer.replaceWith(waveContainer.cloneNode(true)); // Remove the previous 'ended' event listener, if any if (audioElement._onAudioEnded) { audioElement.removeEventListener('ended', audioElement._onAudioEnded); } // Mark player as not initialized player._initialized = false; }); } // Function to initialize music players function initializeMusicPlayers(isAjax = false) { const { filenames, filenameToFormDiv } = collectFilenamesAndPrepareMapping(); if (!isAjax) { // Generate waveform for the first player only if (filenameToFormDiv.size > 0) { generateWaveformForDiv(filenameToFormDiv.values().next().value); } // Add scroll event listener to generate waveforms lazily window.addEventListener('scroll', function() { filenameToFormDiv.forEach((formDiv, filename) => { const rect = formDiv.getBoundingClientRect(); if (rect.top < window.innerHeight && !formDiv.dataset.waveformGenerated) { generateWaveformForDiv(formDiv); formDiv.dataset.waveformGenerated = "true"; // Mark it as generated } }); }, { passive: true }); } else { // For AJAX-loaded content, generate all waveforms immediately filenameToFormDiv.forEach((formDiv) => { generateWaveformForDiv(formDiv); }); } initializeMusicPlayersZIndex(); var players = document.querySelectorAll('.music_player'); players.forEach(function(player) { if (!player._initialized) { initializeMusicPlayer(player); player._initialized = true; // Mark the player as initialized } }); } // Event listener for DOMContentLoaded to handle initial page load //document.addEventListener('DOMContentLoaded', function () { initializeLoopSwitch(); initializeMusicPlayers(); // }); // Function to be called after new content is loaded via AJAX // Adjust onNewContentLoaded for AJAX content function initializeScrollButtons() { const scrollUpButton = document.querySelector('.scroll_up'); const scrollDownButton = document.querySelector('.scroll_down'); const container = document.getElementById('music_players_container'); const musicPlayers = document.querySelectorAll('.music_player'); if (!scrollUpButton || !scrollDownButton) { return; } function updateScrollButtons() { const scrollTop = document.documentElement.scrollTop || document.body.scrollTop; const scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight; const clientHeight = document.documentElement.clientHeight || window.innerHeight; if (scrollTop > 50) { scrollUpButton.style.display = 'block'; } else { scrollUpButton.style.display = 'none'; } if (scrollTop + clientHeight < scrollHeight - 50) { scrollDownButton.style.display = 'block'; } else { scrollDownButton.style.display = 'none'; } } function scrollUp() { window.scrollTo({ top: 0, behavior: 'smooth' }); saveButtonClickData("", "scroll_up"); } function scrollDown() { if (container) { container.scrollIntoView({ behavior: 'smooth', block: 'end' }); } else if (musicPlayers.length > 0) { const lastPlayer = musicPlayers[musicPlayers.length - 1]; const lastPlayerRect = lastPlayer.getBoundingClientRect(); window.scrollTo({ top: window.scrollY + lastPlayerRect.top - window.innerHeight + lastPlayerRect.height, behavior: 'smooth' }); } saveButtonClickData("", "scroll_down"); } // Remove existing event listeners to avoid duplication scrollUpButton.removeEventListener('click', scrollUp); scrollDownButton.removeEventListener('click', scrollDown); window.removeEventListener('scroll', updateScrollButtons); // Add event listeners scrollUpButton.addEventListener('click', scrollUp); scrollDownButton.addEventListener('click', scrollDown); window.addEventListener('scroll', updateScrollButtons); // Initial call to update the visibility of the buttons updateScrollButtons(); } document.addEventListener('DOMContentLoaded', function() { initializeScrollButtons(); initializeMusicPlayers(); }); document.addEventListener('DOMContentLoaded', function() { initializeScrollButtons(); initializeMusicPlayers(); }); function onNewContentLoaded() { // Call with true to indicate this is for AJAX-loaded content initializeLoopSwitch(); initializeMusicPlayers(true); initializeScrollButtons(); } function navigateToAuthor(element) { const url = element.getAttribute('data-author-url'); if (url) { window.location.href = url; } }

1 - 24 of 442


Next