javascript - Playing music that is linked and not loaded? -


this odd question, fun recreated spotify layout app in codepen, want add functionality, there way can music play using js or jquery?

my first thought embed video , hide behind play button, doesn't quite work me.

is there way can set var set = url, use onclick or toggle command play url?

the way think going be:

var expireprettylow = 'url:www.fake.com'  $('#play').toggle(     function(){ //play youtube link?  ); 

i hope makes sense, there api can call mp3s? don't want upload them since it's linking, not trying make product out of this, add portfolio.

for reference here codepen link.

thanks whatever advice/direction can give me!

edit: clarify, 'linked' , not 'loaded' accomplish linking url (ie: href="") opposed saving in directory , loading through filepath (ie: music/tracks/expire-prettylow.mp3)

user blank audio tag , set play button's onclick "var newsrc = newsource.com/song.mp3; playtrack()", , have playtrack() function load , play song. here's example of code changes source of audio element plays new source.

<script> function playtrack(){     var music = document.getelementbyid("myaudio");     music.src = newsrc;     music.load();     music.play(); } </script> <audio id="myaudio" src=""> audio tag not supported </audio> click song play it: <ul>     <li onclick="newsrc = 'http://fidelak.free.fr/reprises/the%20doors%20-%20people%20are%20strange.mp3'; playtrack()">people strange</li>     <li onclick="newsrc = 'http://mp3light.net/assets/songs/14000-14999/14781-december-1963-oh-what-a-night-four-seasons--1411568407.mp3'; playtrack()">oh night</li> </ul> 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -