Guest User

/template/index.html

a guest
Mar 24th, 2024
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Song requests</title>
  5. <style>
  6. body{
  7. margin: 0;
  8. padding: 0;
  9. }
  10. </style>
  11. </head>
  12. <body>
  13. <!--유튜브 플레이어-->
  14. <div id="player">1</div>
  15.  
  16. <script src="https://www.youtube.com/iframe_api"></script>
  17. <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  18.  
  19. <!--유튜브 플레이어 생성, 제어-->
  20. <script>
  21. // YouTube 플레이어를 생성
  22. var player;
  23. function onYouTubeIframeAPIReady() {
  24. player = new YT.Player('player', {
  25. width: '1600',
  26. height: '900',
  27. videoId: '{{ youtube_video_ids }}', // 여기에 동영상의 ID를 입력합니다.
  28. playerVars: {
  29. 'autoplay': 1, // autoplay 속성을 1로 설정하여 자동 재생합니다.
  30. 'controls': 1,
  31. 'rel': 1
  32. },
  33. events: {
  34. 'onStateChange': onPlayerStateChange
  35. }
  36. });
  37. }
  38.  
  39. // 플레이어의 상태 변경 이벤트 핸들러
  40. function onPlayerStateChange(event) {
  41. if (event.data == YT.PlayerState.ENDED) {
  42. $.ajax({
  43. url: '/delete_video',
  44. type: 'GET',
  45. dataType: 'json',
  46. success: function(response) {
  47. if (response.data !== null) {
  48. console.log("요청성공!")
  49. }
  50. }
  51. });
  52. }
  53. }
  54. </script>
  55. <!--새로고침 하는것-->
  56. <script>
  57.  
  58. // 주기적으로 데이터를 확인하고 페이지를 새로 고침하는 함수
  59. function checkAndRefresh() {
  60. $.ajax({
  61. url: '/check_data',
  62. type: 'GET',
  63. dataType: 'json',
  64. success: function(response) {
  65. if (response.data !== null) {
  66. // 새로운 데이터가 있는 경우 페이지를 새로 고침
  67. location.reload();
  68. }
  69. }
  70. });
  71.  
  72. }
  73.  
  74. // 주기적으로 데이터 확인 및 새로고침 실행 (예: 5초마다)
  75. setInterval(checkAndRefresh, 1500); // 5초마다 확인하도록 설정
  76. setInterval(function() {
  77. console.log("asdf");
  78. }, 1500);
  79.  
  80. </script>
  81. </body>
  82. </html>
  83.  
Advertisement
Add Comment
Please, Sign In to add comment