Error generating "Source: File" php


I have a problem when generating a player in php with JwPlayer, the problem is that the player takes the link of my page plus the link where the video is hosted link

To generate the video, the page where it is hosted uses JSON:

$id = $_GET['id'];
$url = "".$id."";
$json = file_get_contents($url);
$json_data = json_decode($json, true);

$host = $json_data["hosts"][0];
$path = $json_data["path"];

and I try to generate the link to the video in the following way:

<script type="text/javascript">
sources: [<?php echo '{file:"' . $host . '' . $path . '",label:"low",type: "video/mp4",default: true}'; ?>],
logo : {file: "",
    link: "",
    hide: true,
    abouttext: "",
    aboutlink: ""

and the following is generated:

<video src="/mipá"></video>

and should generate the following:

<video src=""></video>

Could you help me solve it?

asked by R.13 13.06.2016 в 10:11

1 answer


You are not using a schema in the link, so the browser understands that it is an internal link.

Try it like this:

$host = 'http://' . $json_data["hosts"][0]; 

to force an http schema,

$host = 'https://' . $json_data["hosts"][0]; 

for one https or

$host = '//' . $json_data["hosts"][0]; 

for a "schema free" link that will use the same schema that the client is currently using.

answered by 15.06.2016 / 14:35