D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
skyconb
/
newsyacine
/
Filename :
watch.php
back
Copy
<?php // =============================================== // watch.php (صفحة عرض الفيديو الموحدة - مع زر نسخ كود التضمين) // =============================================== include 'db_connect.php'; $path_prefix = "/"; $base_url = "http://" . $_SERVER['HTTP_HOST'] . $path_prefix; $video_id = $_GET['id'] ?? null; $video = null; if ($video_id) { $stmt = $conn->prepare("SELECT title, m3u8_link, iframe_link, thumbnail_url FROM videos WHERE id = ?"); $stmt->bind_param("i", $video_id); $stmt->execute(); $result = $stmt->get_result(); $video = $result->fetch_assoc(); $stmt->close(); } $conn->close(); $video_title = $video['title'] ?? 'فيديو غير موجود'; $og_image_url = $base_url . ($video['thumbnail_url'] ?? 'default_share_image.jpg'); // 🎯 إنشاء كود iframe للمشاركة (يجب أن يكون رابط مطلق) $share_iframe_code = ''; if ($video) { $share_url = $base_url . 'watch.php?id=' . urlencode($video_id); // يمكنك تعديل width و height حسب الحاجة (القياس 16:9) $share_iframe_code = '<iframe src="' . $share_url . '" width="640" height="360" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe>'; } ?> <!DOCTYPE html> <html lang="ar" dir="rtl"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title><?php echo htmlspecialchars($video_title); ?></title> <meta property="og:title" content="<?php echo htmlspecialchars($video_title); ?>" /> <meta property="og:description" content="شاهد البث المباشر أو الفيديو المسجل لـ <?php echo htmlspecialchars($video_title); ?>" /> <meta property="og:image" content="<?php echo $og_image_url; ?>" /> <meta property="og:url" content="<?php echo $base_url . 'watch.php?id=' . $video_id; ?>" /> <meta property="og:type" content="video.other" /> <script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script> <style> body { font-family: Tahoma, sans-serif; margin: 0; background-color: #121212; color: white; display: flex; flex-direction: column; align-items: center; padding-top: 60px; } /* [CSS الخاص بـ .main-nav و .video-container...] */ .main-nav { position: fixed; top: 0; right: 0; left: 0; background-color: #2c3e50; padding: 10px 0; box-shadow: 0 2px 5px rgba(0,0,0,0.2); z-index: 1000; } .main-nav ul { max-width: 900px; margin: 0 auto; list-style: none; padding: 0 20px; display: flex; justify-content: flex-start; } .main-nav ul li a { color: white; text-decoration: none; padding: 10px 15px; transition: background-color 0.3s; margin-left: 10px; font-weight: bold; border-radius: 4px; } .main-nav ul li a:hover { background-color: #34495e; } .video-container { width: 100%; max-width: 900px; background-color: #000; } #videoPlayer { width: 100%; aspect-ratio: 16 / 9; display: block; } .video-info { max-width: 900px; width: 100%; padding: 20px; } .error-message { text-align: center; padding: 50px; background: #e74c3c; color: white; border-radius: 8px; margin-top: 50px; } .iframe-live iframe { width: 100%; aspect-ratio: 16 / 9; border: none; } /* 🎯 تنسيق زر النسخ ومنطقة التضمين */ .embed-section { background: #1e1e1e; padding: 15px; border-radius: 8px; margin-top: 20px; max-width: 900px; width: 100%; box-sizing: border-box; } .embed-section h3 { margin-top: 0; color: #1abc9c; border-bottom: 1px solid #333; padding-bottom: 5px; } #embedCode { width: calc(100% - 100px); /* مساحة لزر النسخ */ padding: 8px; background: #000; color: #ddd; border: 1px solid #333; border-radius: 4px; font-size: 0.9em; overflow-x: auto; display: inline-block; box-sizing: border-box; vertical-align: top; direction: ltr; /* مهم لكود iframe */ text-align: left; /* مهم لكود iframe */ } #copyButton { width: 90px; padding: 8px; background-color: #3498db; color: white; border: none; border-radius: 4px; cursor: pointer; transition: background-color 0.3s; margin-right: 5px; } #copyButton:hover { background-color: #2980b9; } </style> </head> <body> <nav class="main-nav"> <ul> <li><a href="<?php echo $base_url; ?>">الرئيسية</a></li> <li><a href="<?php echo $base_url . 'articles_list.php'; ?>">الاخبار</a></li> <li><a href="<?php echo $base_url . 'video.php'; ?>">مباشر</a></li> </ul> </nav> <div class="video-container"> <?php if ($video): ?> <?php if (!empty($video['iframe_link'])): ?> <div class="iframe-live"> <?php echo $video['iframe_link']; ?> </div> <?php elseif (!empty($video['m3u8_link'])): ?> <video id="videoPlayer" controls autoplay poster="<?php echo $og_image_url; ?>"></video> <script> var video = document.getElementById('videoPlayer'); var videoSrc = '<?php echo htmlspecialchars($video['m3u8_link']); ?>'; if (Hls.isSupported()) { var hls = new Hls(); hls.loadSource(videoSrc); hls.attachMedia(video); hls.on(Hls.Events.MANIFEST_PARSED, function() { video.play(); }); } else if (video.canPlayType('application/vnd.apple.mpegurl')) { video.src = videoSrc; video.addEventListener('loadedmetadata', function() { video.play(); }); } else { console.error('HLS playback not supported.'); } </script> <?php else: ?> <div class="error-message">لم يتم تحديد رابط M3U8 أو رابط بث مباشر لهذا الفيديو.</div> <?php endif; ?> <?php else: ?> <div class="error-message">عفواً، الفيديو المطلوب غير موجود.</div> <?php endif; ?> </div> <?php if ($video): ?> <div class="video-info"> <h2><?php echo htmlspecialchars($video_title); ?></h2> </div> <div class="embed-section"> <h3>كود تضمين الفيديو (Embed Code)</h3> <div id="embedCode"><?php echo htmlspecialchars($share_iframe_code); ?></div> <button id="copyButton" onclick="copyEmbedCode()">نسخ الكود</button> </div> <script> function copyEmbedCode() { var embedCodeElement = document.getElementById('embedCode'); // إنشاء عنصر textarea مؤقت لاحتواء النص var tempTextarea = document.createElement("textarea"); tempTextarea.value = embedCodeElement.innerText; // استخدام innerText لجلب النص فقط // وضعه خارج الشاشة tempTextarea.style.position = "fixed"; tempTextarea.style.left = "-9999px"; tempTextarea.style.top = "0"; document.body.appendChild(tempTextarea); // تحديد ونسخ النص tempTextarea.select(); document.execCommand("copy"); // إزالة العنصر المؤقت document.body.removeChild(tempTextarea); // تحديث حالة الزر var button = document.getElementById('copyButton'); button.innerText = 'تم النسخ!'; setTimeout(function() { button.innerText = 'نسخ الكود'; }, 2000); } </script> <?php endif; ?> </body> </html>