How we can play audio in html page - php

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.

Related

video autoplay is not working in my android version marshmallow

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.

full screen button in video tag missing

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.

How to play in the same web page MPG video/audio files without making another new tab or new browser window?

I have 100 training, lecture, guide video files which has size 30MB to 1GB each of them. And they are all .mp4/mpg format. There is no web player i have found to play it in the inline html.
So this is what i am doing now let them download it. But i am looking for a way how to play those files using a web based media player so that the quality is not drop and it looks like same page without target="_blank", but with iframe?
Current code is like this:
<a href="/1/720p.mpg" target="_blank">
<img src="/img/icon/playivr.png" style="border:0px;">
</a>
<a href="/1/1080p.mpg" target="_blank">
<img src="/img/icon/playivr.png" style="border:0px;">
</a>
You could try use object tag for that:
<object data="data/test.mpg" type="video/mpeg" width="320" height="255">
<param name="src" value="data/test.mpg">
<param name="autoplay" value="false">
<param name="autoStart" value="0">
alt : test.mpg
</object>
But this will work only if user have a plugin.
The better way would be to convert videos to flv format using ffmpeg for example and play using some flash-based player. It's better since flash in installed on about 99% of computers.
Google chrome latest version supports HTML 5 tag "VIDEO"
<video width="1024" height="768" controls="controls">
<source src="file:HaveFun.mp4" type="video/mp4" />
</video>
Latest firefox browser supports the "video" tag but is unable to play mp4 files.
you can convert them to swf and run them as a flash or upload them to youtube then do the embedding thing. or be creative and use FLASH software and do your own player.
there is this Quick time thing but its isn't nice at all

How to I check to see if the browser supports flash?

I have a flash banner that I want to replace with a static image if the clients browser doesn't have flash enabled.
I was wondering if I can do this with php - or if anyone knows of a good method
Thanks
Allow the <object> (your Flash movie) to degrade:
<object width="640" height="480">
<param name="movie" value="yourflash.swf">
<img src="yourimage.png">
</object>
This will show the image if the Flash video can't load, too.
You can only do this with javascript, using the navigator.plugins interface. Something like:
if(typeof navigator.plugins['Shockwave Flash']!=='undefined'){ }
However, a far more reliable solution that doesn't require any javascript would be simply to position your fallback image "behind" the flash object so that if the flash doesn't turn up, the image will show through. You can either put an <img/> tag inside the flash <object/> or you can put a CSS background-image on the object.
http://code.google.com/p/swfobject/
This is what I use when i need to embed flash and it checks for relavent support and what elements are needed.
I don't think you can check with PHP, you can do it with javascript or Actionscript from SWF file. Here is the official detection kit:
http://www.adobe.com/products/flashplayer/download/detection_kit/
You could use SWFobject
With SWFobject you display alternative code by default, e.g.
<div id="myContent">
<p>Alternative content</p>
</div>
This is then replaced where possible with flash content like this:
<script type="text/javascript">
swfobject.embedSWF("myContent.swf", "myContent", "300", "120", "9.0.0");
</script>
It does have a dependency on JavaScript though which is its only major drawback

embedding audio in html - ie and firefox using php

I'm trying to create an audio captcha system for the visually impaired. I have a system that will glue several wave files together, but I'm having trouble embedding them in ie and firefox.
<script type="text/javascript">
function EvalSound(soundobj)
{
var thissound=document.getElementById(soundobj);
thissound.Play();
}
</script>
<embed src="createaudiocaptcha.php?x=46765" autostart="false" width="0" height="0" id="sound1" enablejavascript="true">
<img src="gfx/speaker.gif" border="0" alt="Audio capture for visually impaired">
using this works, however ie (vista) will just play the sound straight away, it should wait until the speaker has been clicked. IE on win xp seems to lock up for some reason.
I have tried changing the embed for this:
<object type="application/x-mplayer2" height="0" width="0" id="sound1">
<param name="src" value="createaudiocaptcha.php?x=19329">
<param name="autostart" value="0">
<param name="playcount" value="1">
</object>
however ie on winxp still sems to lock up - ie on vista plays the sound straight away and firefox will not play it saying no play() function.
does anybody know why ie on windows xp would lock up? -
Suggestion appreciated
There's an audio service that essentially does this exact thing called ReCaptcha (http://recaptcha.net/).
You can read a review of the service on ReadWriteWeb if you would like to know more about it.
Google also offers an audio captcha. There's an article on the official Google blog here.
I am doing the SAME thing as you with the SAME script. My IE begged me to install the plugin for Media Player. Once I clicked the ActiveX bar at the top if IE to install it... no more locking up. Check your Security Options in IE and/or update Java to the latest and greatest. For what it's worth... I did get mine working on IE and FF with 5 different sounds once the plugin was installed. Oh... and I put around the lines.... one in front and the /object at the end. Maybe that will help you??!?
Scriptaculos has a pretty good Sound library. You can play and stop with it; it should fulfill your needs.
Why not only embed the audio file as needed. Write the embed/object tag out with JavaScript only when someone has clicked "I need the audio captcha"
put some tags on the page like:
Please play the audio Captcha<br />
<div id="audioCaptcha">
</div>
Then the getMeTheAudio() function fills in the innerHTML of the audioCaptcha div with the embed/object. You could sniff the browser type if you want to be fancy.
You will find multiple possible options in the link below ,
http://www.phon.ucl.ac.uk/home/mark/audio/play.htm#

Categories