templates/movie/recommendations.html.twig line 1

Open in your IDE?
  1. {% extends 'layouts/layout.html.twig' %}
  2. {% block recommendation %}
  3.     <style>
  4.         body, html {
  5.             margin: 0;
  6.             padding: 0;
  7.             font-family: 'Arial', sans-serif;
  8.             background-color: #141414;
  9.             color: white;
  10.             height: 100%; /* Full height */
  11.             overflow: auto; /* Hide overflow */
  12.         }
  13.         .deluxe-header {
  14.             background-color: #000;
  15.             padding: 20px;
  16.             color: white;
  17.             text-align: center;
  18.             font-size: 24px;
  19.             box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  20.         }
  21.         .deluxe-hero {
  22.             position: relative;
  23.             width: 100%;
  24.             height: 66vh; /* Adjusted height */
  25.             overflow: hidden; /* Hide overflow */
  26.         }
  27.         .deluxe-hero iframe {
  28.             position: absolute;
  29.             top: -160px; /* Adjust top to cut off borders */
  30.             left: 0;
  31.             width: 120%;
  32.             height: calc(100% + 260px); /* Increase height to cut off borders */
  33.             border: none; /* Remove any border */
  34.         }
  35.         .deluxe-overlay {
  36.             position: absolute;
  37.             bottom: 0%; /* Align with the bottom of the video */
  38.             right: 0.0%;
  39.             width: 30%; /* Adjust width as needed */
  40.             height: 20vh; /* Adjust height to match video bottom */
  41.             background: rgba(0, 0, 0, 0.93);
  42.             color: white;
  43.             padding: 20px;
  44.             display: flex;
  45.             align-items: right;
  46.             justify-content: right;
  47.             clip-path: polygon(100% 100%, 0 100%, 100% 0); /* Triangle cut */
  48.             animation: slideInRight 3s ease-out forwards; /* Animation */
  49.             z-index: 1000; /* High z-index to ensure visibility on top */
  50.         }
  51.         .deluxe-overlay-link
  52.         {
  53.             margin-top:100px;
  54.             color: white; /* Ensures the link is white */
  55.             text-decoration: none; /* Removes underline from the link */
  56.             font-size: 22px; /* Adjust size as needed */
  57.             font-weight: bold; /* Makes the text bold */
  58.             display: block; /* Ensures the link fills the container for better clickability */
  59.             text-align: right; /* Centers the text within the link */
  60.         }
  61.         .deluxe-link {
  62.             color: white; /* Ensures the link is white */
  63.             text-decoration: none; /* Removes underline from the link */
  64.             font-size: 18px; /* Adjust size as needed */
  65.             font-weight: bold; /* Makes the text bold */
  66.             display: block; /* Ensures the link fills the container for better clickability */
  67.             text-align: center; /* Centers the text within the link */
  68.         }
  69.         .deluxe-overlay-left {
  70.             position: absolute;
  71.             bottom: 0%; /* Align with the bottom of the video */
  72.             left: 0.0%;
  73.             width: 25%; /* Adjust width as needed */
  74.             height: 100%; /* Adjust height to match video bottom */
  75.             color: white;
  76.             padding: 20px;
  77.             display: flex;
  78.             align-items: right;
  79.             justify-content: right;
  80.             animation: slideIn 3s ease-out forwards; /* Animation */
  81.             z-index: 1000; /* High z-index to ensure visibility on top */
  82.             background: rgb(0,0,0,1);
  83.             color: white; /* Ensures the link is white */
  84.             text-decoration: none; /* Removes underline from the link */
  85.             font-size: 18px; /* Adjust size as needed */
  86.             font-weight: bold; /* Makes the text bold */
  87.             display: block; /* Ensures the link fills the container for better clickability */
  88.             text-align: center; /* Centers the text within the link */
  89.         }
  90.         @keyframes slideIn {
  91.             from {
  92.                 transform: translateX(-400%);
  93.             }
  94.             to {
  95.                 transform: translateX(0%);
  96.             }
  97.         }
  98.          @keyframes slideInRight {
  99.             from {
  100.                 transform: translateX(400%);
  101.             }
  102.             to {
  103.                 transform: translateX(0%);
  104.             }
  105.         }
  106.         .deluxe-content {
  107.             padding: 20px;
  108.             text-align: center;
  109.         }
  110.         .deluxe-movie-grid {
  111.             width: 100%;
  112.             padding: 20px;
  113.             background: rgba(0, 0, 0, 0.7);
  114.             display: flex;
  115.             flex-wrap: wrap;
  116.             justify-content: space-around;
  117.             margin-bottom: 20px;
  118.         }
  119.         .deluxe-movie-left {
  120.             width: 250px;
  121.             margin: 15px 2px;
  122.             box-sizing: border-box;
  123.             transition: transform 0.3s ease;
  124.             cursor: pointer;
  125.             z-index: 10000;
  126.         }
  127.         .deluxe-movie-left img {
  128.             margin-left: 40px;
  129.             width: 150%;
  130.             height: auto;
  131.             display: block;
  132.         }
  133.         .deluxe-movie {
  134.             width: 11.0%;
  135.             margin: 15px 2px;
  136.             box-sizing: border-box;
  137.             transition: transform 0.3s ease;
  138.             cursor: pointer;
  139.         }
  140.         .deluxe-movie:hover {
  141.             transform: scale(1.1);
  142.         }
  143.         .deluxe-movie img {
  144.             width: 100%;
  145.             height: auto;
  146.             display: flex;
  147.             content-align: center;
  148.         }
  149.         .deluxe-movie-info {
  150.             text-align: center;
  151.             background: rgba(0, 0, 0, 0.8);
  152.             padding: 10px;
  153.             text-overflow: ellipsis;
  154.             overflow: hidden;
  155.             white-space: nowrap;
  156.         }
  157.         .deluxe-link {
  158.             text-decoration: none;
  159.             color: inherit;
  160.         }
  161.         .deluxe-link-left {
  162.             text-decoration: none;
  163.             color: inherit;
  164.         }
  165.     </style>
  166. <body>
  167. {% set skippedFirst = false %}
  168.     <!-- <div class="deluxe-header">Deluxe Movie Showcase</div> -->
  169.    <div class="deluxe-hero" id="deluxe-hero">
  170.    {% if movies.current is defined and movies.current %}
  171.      <a class="deluxe-overlay-link" href="/movie-detail/{{ movies.current.id }}"> <div class="deluxe-overlay" id="deluxe-overlay">  {{ movies.current.title }} <p style="font-size: 12px;">More Details</p></a></div>
  172.          <div class="deluxe-overlay-left"> 
  173.          <div class="deluxe-movie-left">
  174.                 <a class="deluxe-link-left" href="/movie-detail/{{ movies.current.id }}">
  175.                     <img src="{{ movies.current.getImageURL().getUrl() }}" alt="{{ movies.current.title }}">
  176.                 </a>
  177.             </div></div>
  178.     <!-- YouTube video will be loaded here -->
  179.     <div id="youtube-player"></div>
  180. </div>
  181.      {% endif %}
  182.     <div class="deluxe-content">
  183.         <h1>Recommendations</h1>
  184.         <p>Explore our curated collection of films.</p>
  185.     </div>
  186.     <div class="deluxe-movie-grid">
  187.         <!-- Dynamic content will be inserted here via PHP Twig -->
  188.         {% for movie in movies %}
  189.             {% if (skippedFirst) %}
  190.             <div class="deluxe-movie">
  191.                 <a class="deluxe-link" href="/movie-detail/{{ movie.id }}">
  192.                     <img src="{{ movie.getImageURL().getUrl() }}" alt="{{ movie.title }}">
  193.                     <div class="deluxe-movie-info">{{ movie.title }}</div>
  194.                 </a>
  195.             </div>
  196.             {% endif %}
  197.             {% set skippedFirst = true %}
  198.             
  199.         {% endfor %}
  200.     </div>
  201.     <!-- Load the YouTube IFrame Player API -->
  202.     <script src="https://www.youtube.com/iframe_api"></script>
  203.     <script>
  204.         function onDeluxePlayerReady(event) {
  205.             console.log("Player ready");
  206.             event.target.unMute();
  207.             event.target.setVolume(20);
  208.             event.target.playVideo();
  209.             setTimeout(function() {
  210.                 var overlay = document.getElementById('deluxe-overlay');
  211.                 if (overlay) {
  212.                     overlay.style.display = 'block';
  213.                     console.log("Overlay added");
  214.                 } else {
  215.                     console.error('Overlay element not found');
  216.                 }
  217.             }, 10000); // Show overlay after 10 seconds
  218.         }
  219.         function onDeluxePlayerStateChange(event) {
  220.             if (event.data === YT.PlayerState.ENDED) {
  221.                 deluxePlayer.playVideo();
  222.             }
  223.         }
  224.     </script>
  225.     <script src="https://www.youtube.com/iframe_api"></script>
  226. <script>
  227.     var deluxePlayer;
  228.     function onYouTubeIframeAPIReady() {
  229.         var firstMovieName = document.getElementById('deluxe-overlay').innerHTML; // Replace this with dynamic data if available
  230.         console.log(firstMovieName);
  231.         searchYouTube(firstMovieName + " trailer Movie TV Series", function(videoId) {
  232.             deluxePlayer = new YT.Player('youtube-player', {
  233.                 videoId: videoId,
  234.                 playerVars: {
  235.                     autoplay: 1,
  236.                     controls: 0,
  237.                     modestbranding: 1,
  238.                     rel: 0,
  239.                     showinfo: 0,
  240.                 },
  241.                 events:
  242.                 {
  243.                     'onReady': onDeluxePlayerReady
  244.                 }
  245.             });
  246.         });
  247.     }
  248.    function searchYouTube(query, callback) {
  249.     var apiKey = 'AIzaSyABUXy24BFAgNuEjKHVLE1D7YfEti0pB5Y'; // Replace with your actual YouTube API Key
  250.     var url = `https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=1&q=${encodeURIComponent(query)}&key=${apiKey}`;
  251.     fetch(url)
  252.         .then(response => {
  253.             if (!response.ok) {
  254.                 throw new Error('Network response was not ok');
  255.             }
  256.             return response.json();
  257.         })
  258.         .then(data => {
  259.             if (data.items && data.items.length > 0) {
  260.                 var videoId = data.items[0].id.videoId;
  261.                 callback(videoId);
  262.             } else {
  263.                 console.error('No videos found');
  264.             }
  265.         })
  266.         .catch(error => console.error('Error fetching YouTube videos:', error));
  267. }
  268. </script>
  269. {%  endblock %}