How to automatically run many video in sequence with php - php

I am trying to run many videos 1 by 1 in sequence or random
and my code is like this below
<div class="fullscreen-bg">
<video loop muted autoplay poster="assets/img/poster.png" class="fullscreen-bg__video">
<source src="assets/clip/clip<?php echo(rand(4,5,6)); ?>.mp4" type="video/mp4">
</video>
</div>
and it's just playing random only 1 video and after that, it's stopped.I want to do is keep playing other videos without stopping.
Thank you in advance!

I hope it's help full for you I Get reference from PHP: load one of 3 html snippets randomly
PHP:
$videos = array('cloud', 'bath', 'train');
$i = rand(0, count($videos) - 1); // between 0 and $videos count minus 1
HTML:
<video loop autoplay class="StretchtoFit">
<source src="assets/videos/<?= $videos[$i]; ?>.mp4" type="video/mp4">
<source src="assets/videos/<?= $videos[$i]; ?>.ogg" type="video/ogg">
<source src="assets/videos/<?= $videos[$i]; ?>.webm" type="video/webm">
</video>

Related

how to use alternate content for <video> element

I mean what should i do so as not to display video files missing in a database row? I am new to php and this is my code.
<video width="100%" controls preload="auto">
<source src="postfiles/<?php echo $res['file']; ?>"
type='video/webm;codecs="vp8, vorbis"' />
<source src="postfiles/<?php echo $res['file']; ?>"
type='video/mp4;codecs="avc1.42E01E, mp4a.40.2"'/>
</video>
The contents of the <video> element can be used as fallbacks in the case of no support or no content. Just as you have a second video codec in case of missing support for the first one, you can also have image or text in case there's no support for video at all, or no video to play. Perhaps something like this:
<video width="100%" controls preload="auto">
<source src="postfiles/<?=$res['file']?>" type='video/webm;codecs="vp8, vorbis"' />
<source src="postfiles/<?=$res['file']?>" type='video/mp4;codecs="avc1.42E01E, mp4a.40.2"'/>
<p class="error">No video found</p>
</video>
Or if you want to prevent the client from even trying to download videos that don't exist:
<video width="100%" controls preload="auto">
<?php if (!empty($res["file"])):?>
<source src="postfiles/<?=$res['file']?>" type='video/webm;codecs="vp8, vorbis"' />
<source src="postfiles/<?=$res['file']?>" type='video/mp4;codecs="avc1.42E01E, mp4a.40.2"'/>
<p>No browser support for videos</p>
<?php else:?>
<p class="error">No video found</p>
<?php endif;?>
</video>

Get filename from paths in codeigniter

HI guys i am trying to get the image/video filename from path
Here i have paths in my php variable like this from database
E:/xampp/htdocs/pes/new/movie.mp4
E:/xampp/htdocs/pes/new/flowers.jpg
And i am trying to get new/movie.mp4 or new/flowers.jpg from above paths and display it in img tag or video tag
<img src="new/flowers.jpg" alt="Trulli" width="500" height="333">
or
<video width="400" controls>
<source src="new/movie.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video>
Can anyone help me how to do that
Thanks in advance
Hope this will help you :
Set your base_url in your config.php
$config['base_url']='http://localhost/pes/'
and ur image src should be like this :
<img src="<?=site_url('new/'.$image); ?>" alt="Trulli" width="500" height="333">
Try with base_url(). Set your base_url in config.php for example www.xyz.com/ Update your code like this:
<img src="<?php echo base_url() ?>new/flowers.jpg" alt="Trulli" width="500" height="333">
And video frame:
<video width="400" controls>
<source src="<?php echo base_url() ?>new/movie.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video>
Hope this will help you!
If all paths are relative to FCPATH, FCPATH = 'E:/xampp/htdocs/pes', you can use:
<img src="<?php echo base_url(str_replace(FCPATH, '', 'E:/xampp/htdocs/pes/new/flowers.jpg')) ?>" alt="Trulli" width="500" height="333">
or
<video width="400" controls>
<source src="<?php echo base_url(str_replace(FCPATH, '', 'E:/xampp/htdocs/pes/new/movie.mp4')) ?>" type="video/mp4">
Your browser does not support HTML5 video.
</video>

Run video according to URL

I need help. I have a file "video.php"
Where it contains an html5 player.
I want instead
www.mysite.com/myvideo.mp4
Be it
Www.mysite.com/video.php?file=myvideo.mp4
I want the src of the video to change according to what is typed in the url.
video.php
<video width="480" height="320" controls>
<source src=" **Name typed in the url** " type="video/mp4">
</video>
This will work:
<video width="480" height="320" controls>
<source src="<?php echo $_GET['file']?>" type="video/mp4">
</video>

Upload video and stream video on laravel

My app can already upload and save the video to public/files folder. my only problem is when im displaying (let's say a 1 minute long video) it doesn't play but when i play 2 seconds long video its working. i don't know why is this happening.
i have this is my controller
$input = Input::file('vid');
$fileinput = $input->getClientOriginalName();
$input = Input::file('vid')->move($destination,$fileinput);
$post = New Post();
$post->title = Input::get('title');
$post->content = nl2br(Input::get('content'));
$post->videos = $fileinput;
$users->post()->save($post);
and in my views
<video width="600" height="500" controls>
<source src="{{ asset('img/'. $posts->videos)}}" type="video/mp4">
<source src="{{ asset('img/'. $posts->videos)}}" type="video/ogg">
<source src="{{ asset('img/'. $posts->videos)}}" type="video/webm">
Your browser does not support the video tag.
</video>
i just want to understand why this is happening thanks

How to insert audio/mp3 in Cakephp?

<?php echo $this->Html->media('musica.mp3'); ?>
I'm trying this in the view.ctp (USING CAKEPHP 2.5....)
try:
<audio controls>
<source src="musica.ogg" type="audio/ogg">
<source src="musica.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>

Categories