video autoplay is not working in my android version marshmallow - php

I need a video auto play in some part of my website ,but the video is not working in my android marshmallow.
Below is my code.
<video width="100%" height="30%" autoplay src="<?php echo HTTP_ROOT . 'files/youtube-video/' . $newName; ?>" ></video>
Give me some idea ,how can i fix it ,so that the video will play with page load .no extra event fire is required .
Thank you ,any suggestion will be highly appreciated .

Not sure why autoplay param doesn't work on your device, but you can try to add small JS function to your page which will play video.
Example of playing video on page load with pure js:
window.addEventListener("load", function(){
var vid = document.getElementById("myVideo");
vid.play();
});
P.S It will help only in case you see video on the page and can play it manually, it you don't ether your HTML code of video or video's url are not correct.

Related

Embedded video player not showing and not playing a video file

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>';

how to convert every youtube link i have on my wordpress posts into embed?

i am using the latest version of wordpress , i have around 10000 post right now on my website.
i have a nice plugin that makes my website looks a bit more fancey but i need to ad a simple code to each featured image and each embeded youtube video i have in my posts (if i could pick user who add it too that would be perfect ! ) to get it to work
i know that youtube embed code is
<iframe width="560" height="315" src="//www.youtube.com/embed/NrH9CqnzzRU?list=PLHPcpp4e3JVpXbtgyD-k-nCmwpbbMIHOh" frameborder="0" allowfullscreen></iframe>
what i need to do is to add
<div class="featuredvideo"><iframe width="560" height="315" src="//xxxxxxxxxxxxxxxxxxxxxxxxx" frameborder="0" allowfullscreen></iframe></div>
so i want to add those things before and and after "XXXX" s
i am not a programer so please give me the code
i know that AJAX can search entire folder with code like
<button>AJAX</button>
<br>
<div id = "container"></div>
<script type="text/javascript">
$("button").click(function(){
$.get("sample.html",function(data){
$("#container").html(data);
})
});
which will just get html from a file but that is now what i want to do here.
please help me , give me a plugin or a code to work with
thank you
To wrap the Youtube iframes with the div as required, just use this...
$(function() {
$("iframe[src*=www.youtube.com]").wrap("<div class=\"featuredvideo\" />");
});
That will run when the document has finished loading. It will find all iframes with the string www.youtube.com in the src attribute and wrap them in the required div.
Obviously, if you add any more iframes to the page later and it doesn't reload then you'll need to run that code again. If you did just that then it would wrap the iframes in the div again, which would be wrong. This will handle running the code multiple times...
function wrapYoutubeEmbeds() {
$("iframe[src*=www.youtube.com]").each(function() {
if (!$(this).parent().hasClass("featuredvideo")) {
$(this).wrap("<div class=\"featuredvideo\" />");
}
});
}
$(function() {
wrapYoutubeEmbeds();
});
It simply checks to see if each iframe is inside something with the class featuredvideo and ignores it if it is.

playing videos on second page php

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';
}

Make active div for youtube URL a different shade

I have a page where in the top middle there is a large youtube player. Below it there are a bunch of youtube thumbnails which are clickable. Clicking them changes the player video to the thumbnail that was clicked. The youtube ID is passed thru the URL.
I wanted to change the shade of the thumbnail background so that the active ("clicked") thumbnail was shaded.
The following code generates the linked thumbnails:
while ($row = mysql_fetch_array($result)) {
$tubeID = $row['videoinfo'];
echo
'<div class="vid"><img src="http://img.youtube.com/vi/' . $tubeID . '/0.jpg" width="225" height="175"/></div>';
}
And the following code uses the clicked thumbnail to display the video:
<iframe id="player" width="640" height="385" src="http://www.youtube.com/embed/<?php echo $_GET['id'] ?>" frameborder="0"></iframe>
I know I need to compare the thumbnail URL to the current URL and if they match and set an ID to that thumbnail which can be assigned properties in CSS... though I'm not sure how to do so. Can someone help?
edit : this sorta explain what BZ suggested.
I kicked out some php to make the answer more concise. Don't forget to add it back.
<div class="vid">
<a href="videos.php?id=$tubeID" id="m+$tubeID" onclick="changeVid(this);return false;">
<img src="http://img.youtube.com/vi/01/0.jpg" width="225" height="175"/>
</a>
</div>
<script type="text/javascript>
function changeVid(obj) {
document.getElementById('player').src = "videos.php?id="+ substr(obj.id,1)
document.getElementById(obj.id).style.visibility='visible'; //or other style
document.getElementById(obj.id).setAttribute("class", newClass); //For Most Browsers
document.getElementById(obj.id).setAttribute("className", newClass); //For IE; harmless to other browsers.
}
</script>
of course, I'd be a lot easier with a JS framework... (ie jquery)
Basically, when you click a link, the function is called, when it's done, return false; disable the page loading (ignoring the href).
The function will change the iframe source and then will add some custom styling to the link you clicked to load the new video.
I've thrown a "m" in the link ID, because id can't start with numbers...
edit : my function changeVid lack some reset function to remove the old thumbnail active state (easy way to solve it : remove the active state from all thumbnail then put the active state on the clicked thumbnail.)
In each link you could put an onclick attribute to do some javascript that would do the highlighting.

How we can play audio in html page

In my page i have a button called Play
In included windows media player using this tag
<embed id="wmpid" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" name="mediaplayer1" ShowStatusBar="false" EnableContextMenu="false" autostart="0" width="200" height="45" loop="false" src="/1.wma" />
The audio is starting when i click on the play contoller.
But when i click on the play button, that i created ,how i can play the audio
Thanks in advance
You have to use JavaScript to play the sound by clicking on a button.
<script>
function EvalSound(soundobj) {
var thissound= eval("document."+soundobj);
thissound.Play();
}
</script>
<embed src="success.wav" autostart=false width=0 height=0 name="sound1"
enablejavascript="true">
Here are examples of a link, an image and a button calling the function.
Click here
You need to handle events via JavaScript. Refer is-there-a-documented-javascript-api-for-windows-media-player
Personally I recommend Yahoo Media Player. Windows Media Player might not work on all platforms. Prefer a flash based player. You might need to convert wma to mp3.

Categories