I have an external file that renders a video on my site using a dynamic URL with a token and an expire date. It looks like this:
https://www.thevideositeurl.com/embed/231231/
I add it to my page this way:
$vid = 231231;
$url = file_get_contents("https://www.thevideositeurl.com/embed/{$vid}/")
echo $url ;
And it then renders the javascript bellow and also some html
<script type="text/javascript">
var sources = [
{
type:"video/mp4",
src:"https://cdn.myvenue.com/media/clips/491355/clip_saple_hd.mp4?expire=1525179619&token=1e52da03af581764724c0e2c428a9faa",
res:"VideoSample",
label: "VideoSample"
}
];
videojs("video", {
nativeControlsForTouch: true,
autoplay: false,
controls: true,
width:'100%',
fluid: true,
loop: false,
muted: false,
poster: "https://cdn.static.myvenue.com/media/assets/images/image.jpg",
etc., etc., etc.
The problem is that I just need to get the video URL (remember: it's dynamic):
https://cdn.myvenue.com/media/clips/491355/clip_saple_hd.mp4?expire=1525179619&token=1e52da03af581764724c0e2c428a9faa
Is this possible?
Assuming you want to get to the first object (or maybe you only have one) in your sources array you can get the video url like this;
var videoURL = sources[0].src;
Update // for PHP code, based on a modified version of @Moti's regex
echo $url;
preg_match('/https:\/\/cdn\.myvenue\.com\/[^\"]*/', $url, $matches, PREG_OFFSET_CAPTURE);
$videoURL = ($matches[0][0]);
echo $videoURL;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With