Es posible de hacer un embed de cierto ID de un video de youtube?

  • Autor Autor MajesticCat
  • Fecha de inicio Fecha de inicio
MajesticCat

MajesticCat

VIP
Kappa
Verificación en dos pasos activada
Verificado por Whatsapp
¡Ha verificado su Paypal!
Verificado por Binance
Suscripción a IA
Hola,

Estoy desarrollando un nuevo sistema de descargar videos/audio de youtube.

Actualmente tengo este codigo que me proporciona la imagen y me la muestra correctamente

HTML:
$this->fullInfo['video_id'] = $videoId;
$videoId = $fullInfo['video_id'];
$baseInfo['previewUrl'] = "https://img.youtube.com/vi/$videoId/hqdefault.jpg";

Lo que quiero saber es que si se peude hacer un embed con el videoId para que muestre tambien el reproductor..!

Intente con:
HTML:
<iframe width="420" height="315"
src="https://www.youtube.com/embed/$id_video">
</iframe>

y con

<iframe width="420" height="315"
src="https://www.youtube.com/embed/$videoId">
</iframe>

Pero nada que me funciona, aqui se puede ver una imagen de como sale el embed
hKGd1ydUTaCTHKpsI9sBgg.png


Como podria hacer lo que quiero lograr?

Saludos
 
[MENTION=79817]jesushiguerey[/MENTION] Deberia ser asi por que es php

PHP:
<iframe width="420" height="315" src="https://www.youtube.com/embed/<?php echo $id_video; ?>"></iframe>
 
[MENTION=79817]jesushiguerey[/MENTION] Deberia ser asi por que es php

PHP:
<iframe width="420" height="315" src="https://www.youtube.com/embed/<?php echo $id_video; ?>"></iframe>

Hola amigo, gracias por tu respuesta, tambien intente lo mismo pero igual no agarra el id del video ..

Saludos!
 
Aqui es como obtengo la imagen
HTML:
    {
        $fullInfo = $this->getFullInfo();
        $baseInfo = array();
        $baseInfo['name'] = $fullInfo['title'];
        $videoId = $fullInfo['video_id'];
        $baseInfo['previewUrl'] = "https://img.youtube.com/vi/$videoId/hqdefault.jpg";
        $html = $fullInfo['html'];
        if (preg_match('/<p id="eow-description"[^>]+>(.+)<\/p>/', $html, $matches)) {
            $baseInfo['description'] = strip_tags(str_replace('<br />', "\n", $matches[1]));
        }
        return $baseInfo;
    }

y Aqui el id

HTML:
if (is_null($this->fullInfo)) {
             preg_match("/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/i", $this->url, $matches);
             $videoId = $matches[7];
             $clearContent = file_get_contents("https://www.youtube.com/watch?v=$videoId");
             preg_match('/ytplayer.config = (\{.+});ytplayer/', $clearContent, $mathes);
            $configData = json_decode($mathes[1], true);
            $streamList = explode(',', $configData['args']['url_encoded_fmt_stream_map']);
            $configData['args']['url_encoded_fmt_stream_map'] = array();
            foreach ($streamList AS $stream) {
                parse_str($stream, $res);
                $configData['args']['url_encoded_fmt_stream_map'][] = $res;
             }
             $streamList = explode(',', $configData['args']['adaptive_fmts']);
             $configData['args']['adaptive_fmts'] = array();
             foreach ($streamList AS $stream) {
                parse_str($stream, $res);
                $configData['args']['adaptive_fmts'][] = $res;
            }
;
 
PHP:
<iframe width="420" height="315" src="https://www.youtube.com/embed/<?=$videoId?>"></iframe>
No estas imprimiendo la variable con php como menciono el compañero [MENTION=1597]YeltsinGraphs[/MENTION]

Haz un echo o usa empty() para comprobar que no este vacia la variable, y puedes usar parse_url() (nativa de php) para obtener el id mas facil y evitar posibles errores 🙂
 

Temas similares

Atrás
Arriba