HTML5 Audio not playing after src URL injected in - php

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

Related

Something that cause plain iframe not to show on php page?

<div class="grid-5-12">
<iframe width="200" height="120" src="http://www.saweb.info/videos/nightclub.mp4" frameborder="0"></iframe>
</div>
I copied above direct from an "admin page" from Firefox developer page source and it works as standalone, but on the admin page itself it doesn't appear (it always did)
It also doesn't show even without the div. (It's in a parsley form and the iframe show the "current selected video")
Tested in Chrome and it also doesn't display while I can't find any similar error on the internet.
Anyone perhaps has an idea why the iframe don't appear / disappeared please?
is not used for play videos but to display another page. Some browsers might support this way of importing a video. But correct way to use tag like this for your video link.
<video width="200" height="120" controls>
<source src="http://www.saweb.info/videos/nightclub.mp4" type="video/mp4">
</video>

php html audio player disappears

When I code the src with an .aac I cannot get the audio player to work
'<audio controls ><source type="audio/aac" src="'.$mTheMediaLocation.'" ></audio>'
If I Build the data from a data string then It's fine..
<audio controls id="myAudio"><source src="data:audio/aac;base64,'.base64_encode($mTheMediaData).'"></audio>'
I want the src to be a file, I'm aware of browser support etc. BUT if the one works surely there is a way to get the other to work aswell ?

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.

PHP Video Url with GET

So I have a video player with the following source code.
<video width="320" height="240" controls>
<source src=<?php echo $tryOne; ?> type="video/mp4">
</video>
It will echo something something similar to below and insert it as the source video.
'176.227.210.66/Kuroko%20no%20Basket%202%20Episode%205.mp4?st=zEws3h1Xg-to07f3as6KqA&e=1385059955'
However, the player will not load the the video. If I open page source and copy the generate url into the address bar and hit enter, it will go to the direct url and load the video just fine. I think that the player won't load the url because it has GET variables in it, and I need to know how to fix this. Please tell me how I can load a video in a player from the above url with GET variables.
Note: the player will load a video just fine if it is named without the get variables.
As per the HTML specification for <video>, you need a valid URL:
src = non-empty URL potentially surrounded by spaces.
The URL for the video.
In this case, it is missing the protocol information (http://) and it is not being recognized as a video src. Change the value of $tryOne to include the protocol information or manually prepend it to the variable when outputting to the page. It might also be a good idea to URL-encode the string.
For example:
<video width="320" height="240" controls>
<source src=<?php echo 'http://'.urlencode($tryOne); ?> type="video/mp4">
</video>
Live demo.

How to embed an audio file into a website with php?

I am attempting to embed a sound file of Bohemian Rhapsody into my website and have found this code snippet:
echo "<embed src=\"SONGURL.mp3\" autostart=\"true\" loop=\"true\" hidden=\"true\"> </embed>\n" ."<noembed><bgsound src=\"SONGURL.mp3\" loop=\"infinite\"></noembed>";
My question is how to make this apply to the song I want? Also, what part of this would I modify?
Well it seems that the HTML snippet being produced by the PHP snippet in question relies on some sort of plug-in (my guess would be Flash, but I'm not familiar with Flash at all) so it would be much more complicated than a simple edit of the HTML string. If you're willing to break backwards compatibility with old browsers, you could use the HTML5 audio tag (see for example https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_HTML5_audio_and_video).
In your case, given some filename $song_url, you could accomplish what it seems you want via string-building as
$html_snippet = "<audio src=\"$song_url\" autoplay loop></audio>";
echo $html_snippet;
To support multiple different formats (for example .ogg files for Firefox users) you can simply write
$html_snippet = <<<EOD
<audio autoplay loop>
Upgrade to a newer browser!
<source src="$song_url_mp3" type="audio/mpeg">
<source src="$song_url_ogg" type="audio/ogg">
</audio>
EOD;
This HTML tag will ensure that your audio plays automatically and loops forever. To give users standard music controls, simply add a controls attribute.

Categories