0

ok, so this is what I am trying to do. when a button is clicked on another page I want it to send a sound to local storage and then get that sound to go into a playlist so it gets saved to the playlist.

$('#btn1').on('click', function () {
    localStorage.setItem('mallard',"sound/duckcal.mp3");
    
    $("coin").attr('src',"gotit");
});
let gotIt = localStorage.getItem('mallard');
var playlist = document.getElementsByClassName("playlist");
console.log(playlist);
<!DOCTYPE html>
<html>
<head>
 <title></title>
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <meta charset="utf-8">
 <link rel="stylesheet" type="text/css" href="call.css">
</head>
<body>

 <div class="playlist">
  
  <audio controls id="coin" preload="auto" src=""></audio>
  
  <ul class="onlist">
   <li data-id="0" data-audio="">sound</li>
  </ul>
 </div>
   <a href="calls.html" class="back">Back to Calls</a>
  </div>

  
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script type="text/javascript" src="script/animal.js"></script>
  <script type="text/javascript" src="script/playlist.js"></script>
</body>
</html>
  • What issues are you having? – Russ J Mar 06 '19 at 02:44
  • 1
    localStorage can only store data in string format, and has max size of 10MB. If I don't understand it wrong, then you are trying to store mp3 file content in localStorage. It's not recommended to do so. – blaz Mar 06 '19 at 02:49
  • So what would be the best way to get a mp3 saved into a playlist so when you exit out and come back it will still be there. – Haden Breckenridge Mar 06 '19 at 03:13
  • this answer might help you https://stackoverflow.com/questions/43816266/saving-audio-to-localstorage-for-playback – thedudecodes Mar 06 '19 at 06:03
  • thanks but if local storage, not a good way to do it then I like to find a way that works better any clues – Haden Breckenridge Mar 06 '19 at 07:08

0 Answers0