I am developing a PHP backend to my mobile app.
There is a part where I need to show and play a hosted video file.
This is how am I trying it:
$data[$i]['video'] = '<video controls width="500", height="300><source src="pacientes/'.$data[$i]['video'].'" type= "video/mp4; codecs="avc1.42E01E, mp4a.40.2"></video>';
Here hou have the value for $data[$i]['video'] that should be an example of the kind of video files I will find in he backend
32365bec-7ec8-4b16-a91c-58e12f68cdba1575964120438935622.mp4
And here yoy have the video file URL
https://capenergy-app.com/administrar/application/admin/pacientes/32365bec-7ec8-4b16-a91c-58e12f68cdba1575964120438935622.mp4
And here you a screenshot from the video player using the above code to show it.
The video is not played when clicking on the play button, and the video duration is set to 0:00.
What do I need to change to my code to show the video and let me play it?
You must put the full video path at the source's src
<source src="full_path" > </source>
Double check spelling, for example: some " are missing. And there is no need to add a , after attributes.
Fix:
$data[$i]['video'] = '<video controls width="500" height="300"><source src="pacientes/'.$data[$i]['video'].'" type= "video/mp4"; codecs="avc1.42E01E, mp4a.40.2"></video>';
Related
I am using audio.js audio player in angularjs. but it is not working properly.
I have different audio Urls which are being passed through $scope to ng-src.when i click on any audio. it plays the audio. when i stop it and play the another audio. it still plays the previous audio. it seems that modal value is not getting cleared. everytime it will only play that audio which i have played first.
<audio ng-src="{{audioUrl}}" preload="false" id="callaudio" />
here audioUrl remians the very first url and doesn't get changed while clicking on other links.it still plays the same audio.
i chacked the value of audioUrl in console. it changed every time when i click on any link.
but in ng-src={{audioUrl}} it remains same.
kindly help me.I am breaking my head for last two days.
thanks
Try this
< audio>
<source src = "{{audio.Url}}"type = "{{audio.AudioType}}" >
< /audio>
I have something like this on page load:
echo "<td class='audio'><audio controls><source src></audio></td>";
I then make an ajax call based on click to pull relative audio URL's from an API I'm working with to be used as the src.
Upon visiting one of those audio URL's in a separate tab, the audio does in fact play. My thinking is that it's not playing where I need it to because it doesn't get a source until it needs it (used ajax to cut down on load time due to rather large API calls).
Any thoughts?
Your source tag is missing the filetype information. Even is src is replaced by src="your_path/your_file.mp3", it also needs for example type="audio/mpeg" for an mp3-file. The full generated HTML code would have to be something like
<audio controls>
<source src="your_path/your_file.mp3" type="audio/mpeg">
</audio>
This is work me,or may be you can remove the <source src=""> tag and add src="" inside of the <audio> tag
https://shty.ml?j2n7MxkhKm
When you enter this link then click the Preview button
full screen button in video tag missing when page containing video is loaded externally on another pages div
I have a page external.php . In this page when i use the following code
echo
'<video width="400" controls>
<source src="movie.mp4" type="video/mp4">
</video>';
i get a video with full screen button in it on chrome.But when i try to load this external.php on another page (home.php) div the video is coming but the full screen button is missing.But in IE there is no such problem.
You can either solve this via CSS OR Fullscreen API.
1. CSS
I think you can accomplish this by changing the css for the #document fragments, these are DOM1 specs and supported by all browsers, but about the styling, I'm not sure. The following solution is webkit specific.
You need just to write this code in your css:
video::-webkit-media-controls-fullscreen-button {}
2. Full screen API
If you want to accomplish it by Fullscreen API check below demo first:
Demo Full screen video
As you can see a very simple demo showing HTML5 video in full screen, make sure you're using Chrome dev, webkit or firefox nightly.
For more detail you can check it here.
Browsers may provide a user interface, but shouldn't provide a programmable one.
before i get burried in trying to create the code, I was hoping to get some advice before moving forward.
I am creating a video sharing app for a client.
The videos are highly confidential, so i want to store them outside the root and stream them when a user enters a link into a browser, which triggers a php script to access the file and play it.
Is this possible?
I can seem to find any info on any forums or Google.
Can I stream it direct to the browser?
I had this working when the files were inside the root.
I am holding the url of the file in a var:
$file_url = "../users/$u_id/$folder_name/$file_name";
And trying to stream the video using html5 player video.js using this:
<div id="video_box">
<video id="example_video_1" class="video-js vjs-default-skin"
controls preload="auto" width="500" height="350"
poster="images/img_name.png"
data-setup='{"example_option":true}'>
<source src="$file_url" type='$file_type' />
</video>
</div>
Many thanks
Alan
This is kind of stupid question but is there any way to play videos just by using two pages, I mean like instead of creating an html page for every video I upload to my website, can I have only two php pages and then pass the video from the first page and play on the second one?
I know about passing variables in url but I am kinda confused on how to do this.
I actually embedded my videos from google drive and have a format like
<iframe src="https://docs.google.com/file/d/0B5ZMsnZoUVNSWHhxeGc/preview" width="640" height="385"></iframe>
would it be possible to do like
<a href="play.php?video='test.mp4'>Click to play</a>
or like
$video= 'test.mp4';
<a href="play.php?vid='$video'>Click to play</a>
play.php
$video = $_GET['vid']
if(!empty(($video)){
//then play the video here.
}
I'm expecting you're usnig HTML5.
Let's say there's a list of videos on the first page, and you click on a name of video and it redirects you to second page. Pass the video url (or any identifier for server to know which video) in the link. You can do it like
Cats!!
This will send vid_url as a GET variable on second page. page2.php is, as you can imagine, very simple
<?php
$vid = $_GET['vid'];
//echo $vid;
echo "<video width='320' height='240' controls>
<source src=".$vid." type='video/mp4'>
Your browser does not support the video tag.
</video>"
?>
Of course, you'll do something more elaborate than simply using "echo" for formatted HTML output.
Yes. Instead of empty use isset:
if (isset($_GET["vid"])){
$video = $_GET['vid'];
//play video
}
Play This Video
And On Play.php page add this code
if(isset($_GET['video'])&&!empty($_GET['video']))
{
$Video = $_GET['video'];
// Use the Source of your video anyway you like to play the video
}else
{
echo 'No video selected to play';
}