LuboEM LuboEM - 1 month ago 11
PHP Question

Change video size from URL?

Helou :)

I have this following code

<?php
$koncovka = $_GET["url"];
$url_parsovani = "http://www.streamuj.tv/video/$koncovka";
$width = "640";
$height = "360";


Once I get on the video URL for example http://video.24tv.cz/index.php?url=6697adb1d9a00acde7a3 it gives me the preset width and height of the video.

Can you help me to transfer code, so I can change the video size from URL?
For example I would like to use this URL to set the video size to 960x540

http://video.24tv.cz/index.php?url=6697adb1d9a00acde7a3?remote=1&width=960&height=540

Answer

Change

$width = "640";
$height = "360";

To the parameters read from the url (don't forget to validate the input).

$width = isset($_GET['width']) && is_numeric($_GET['width']) ? $_GET['width'] : '360';

$height = isset($_GET['height']) && is_numeric($_GET['height']) ? $_GET['height'] : '640';

It checks if there is a GET parameter passed and if it's of numeric type, otherwise is sets to a default value.

Comments