Very Basic JS Coding, and SoundManager2 or not?

青春壹個敷衍的年華 提交于 2019-12-12 18:47:05

问题


I would like to include an audio/possible video player on my website with the following attributes:

  • Must be placeable via a <div>;
  • Styled via CSS;
  • Can read all ID3 info;
  • Can pull the file from a database (probably GoDaddy's Easy Database);
  • No flash;
  • Transferrable to smartphones etc.

I have been herded to SoundManager2 which appears to fit the bill, but I seem to be having real trouble just making a clickable image to begin playing my mp3. I have zero JS skills so am going from silly basic and building up slowly. I suppose I have two questions:

  1. Is there another media player that is better suited?
  2. I can't create a Fiddle with what I have so far, but this is the very simple HTML - what is going wrong?:

    <html>
    <head>
    
    <script src="script/soundmanager2.js"></script>
    
    <script>
    
    // Path to Flash Files
    soundManager.url = 'swf/';
    soundManager.onload(function(){
      // SM2 is ready to Play Audio
    
    // Create "mySound"
    soundManager.createSound({
    id:"mySound",
    url:"audiofiles/my.mp3",
    onfinish:function(){window.location.href='index.html}});
    };
    
    // Play File
    //soundManager.play('mySound','my.mp3');});
    </script>
    
    </head>
    
    <body>
    <img src="image.jpg" alt="Previous" border="0" width="400" height="400" onclick="soundManager.play('mySound',{volume:100})";>
    </body>
    </html>
    

I had copied this code from another website, but I have a sneaking suspicion that the code was incomplete, so any help would be...err...helpful.


回答1:


I operate the website you say you took the code from. I updated it and it should work. Make sure you do both sections in the tutorial. The second section assumes that you are using the same file structure as the first. This should work completley fine now:

http://en.wikiaudio.org/SoundManager2:How_to_play_and_trigger_sound



来源:https://stackoverflow.com/questions/10077496/very-basic-js-coding-and-soundmanager2-or-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!