Darren Brinx
Darren Brinx

Reputation: 23

Creating a dynamic embed code

I'm having issues creating a dynamic embed. I basically need it to change dynamically (e.g index.php?channel=randomname), but I want it so when they input the name it changes the name in the embed to what they put.

<object type="application/x-shockwave-flash"
        data="http://www.justin.tv/widgets/live_embed_player.swf?channel={$id}"
        id="live_embed_player_flash" 
        height="300" 
        width="400" 
        bgcolor="#000000">
<param name="allowFullScreen" value="true"/>
<param name="allowScriptAccess" value="always" />
<param name="allowNetworking" value="all" />
<param name="movie" value="http://www.justin.tv/widgets/live_embed_player.swf" />
<param name="flashvars" value="hostname=www.justin.tv&channel={$id}&auto_play=false&start_volume=25" />
</object>

But at the same time I'd like a default video when it's index.php or an invalid link. How can I do this?

Upvotes: 0

Views: 275

Answers (2)

kewlashu
kewlashu

Reputation: 1109

Assuming you are getting the $id properly in php, you have to change

{$id}

to

<?php echo $id;?> or <?=$id?>

Upvotes: 0

ಠ_ಠ
ಠ_ಠ

Reputation: 3078

Let's say $_GET['channel'] is your channel that you got from whatever form.

<?php

    if(isset($_GET['channel'])){
        $channel = $_GET['channel'];
    }
    else{
        $channel = /* default channel value */;
    }

    echo '<object type="application/x-shockwave-flash" data="http://www.justin.tv/widgets/live_embed_player.swf?channel=$channel" id="live_embed_player_flash" height="300" width="400" bgcolor="#000000"><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always" /><param name="allowNetworking" value="all" /><param name="movie" value="http://www.justin.tv/widgets/live_embed_player.swf" /><param name="flashvars" value="hostname=www.justin.tv&channel=$channel&auto_play=false&start_volume=25" /></object>'

?>

Upvotes: 1

Related Questions