Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css">
  7. <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
  8. <script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
  9.  
  10. <script>
  11. $(document).on("pagecreate",function(event){
  12. $(window).on("orientationchange",function(event){
  13.  
  14. document.getElementbyId("song").play();
  15.  
  16. });
  17. });
  18. </script>
  19. </head>
  20.  
  21. <body>
  22. <div id="drunk">
  23. <audio controls autoplay id="song">
  24. <source src="bdayDiddy.mp3" type="audio/mpeg">
  25. </audio></div>
  26. </body>
  27. </html>
  28.  
  29. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
  30. <!DOCTYPE html>
  31. <html>
  32. <head>
  33. <meta name="viewport" content="width=device-width, initial-scale=1">
  34. <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css">
  35. <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
  36. <script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
  37.  
  38.  
  39. <script>
  40. $(document).ready(function(event){
  41. $(window).on("orientationchange",function(event){
  42.  
  43. //initiate fake click to get around iOS 4+ autoplay ban
  44. function fakeClick(fn) {
  45. var $a = $('<a href="#" id="fakeClick"></a>');
  46. $a.bind("click", function(e) {
  47. e.preventDefault();
  48. fn();
  49. });
  50.  
  51. $("body").append($a);
  52.  
  53. var evt,
  54. el = $("#fakeClick").get(0);
  55.  
  56. if (document.createEvent) {
  57. evt = document.createEvent("MouseEvents");
  58. if (evt.initMouseEvent) {
  59. evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
  60. el.dispatchEvent(evt);
  61. }
  62. }
  63.  
  64. $(el).remove();
  65. }
  66.  
  67. $(function() { //should initiate auido in the div below?
  68. var audioo = $("#drunka").get(0);
  69.  
  70. fakeClick(function() {
  71. audioo.play();
  72. });
  73. });
  74.  
  75. });
  76. });
  77. </script>
  78. </head>
  79.  
  80. <body>
  81.  
  82. <div id="drunk">
  83. <audio controls autoplay id="drunka">
  84. <source src="bdayDiddy.mp3" type="audio/mpeg">
  85. </audio></div>
  86.  
  87. </body>
  88.  
  89. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement