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.
Related
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
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 ?
my php code to fetch all sound files, random way, in a folder is this:
$files = glob("audio/*.mp3");
$random = $files[array_rand($files)];
and to play them i use:
<audio src="<?php echo $random; ?>" width="400" height="200" controls></audio>
What i want is to play the sound files pressing a HTML button tag and not seeing the default HTML5 audio player. Just like Spotify or similar.
I tried making it with button onclick="function()" but with javascript wich is a client language i don't know a way to loop all files in my folder, just like i did with the php code above.
Any ideas? Many thanks...
Few minutes after asking i solved the question by myself. Been dealing with this four a couple of hours, so here it is:
<a onclick="this.firstChild.play()"><audio src="<?php echo $random; ?>"></audio>►</a>
Used the browser DOM and a html special caracter & #9658;. It does the trick, in spite of not allowing the use of an icon image.
Thanks to all :)
I'm desperately (hours of research and no luck so far) trying to create a PHP page which can be used as a path for video embedding. I'm doing this so that I can give out a path to 3rd parties, that they can use for embedding, which won't change, even if I have to host the video elsewhere.
I've tried using the code referenced here...
Reading mp4 files with PHP
... but it doesn't work at all for me.
The video files will be hosted on a CDN and 3rd parties will need fixed links that they can embed on their own sites like:
<div data-swf="$resourcePath/resources/flowplayer.commercial-5.4.3/flowplayer.swf" class="flowplayer is-splash play-button" data-ratio="0.5625">
<video>
<source type="video/mp4" src="http://www.mycdndomain.com/embed/loader.php?v=1"/>
</video>
</div>
Thanks in advance.
-Josh
Currently I am using the standard way to embed an pdf to the browser, however, the built-in pdf viewer for my target browser is not working as expected. I would like to force (Chrome, Firefox and IE8 (if possible, but IE9+ is also ok)) to use the adobe reader. The problem is , I can only change this option manually. Is there any way to change the option in HTML/ JS/ PHP ? Thanks.
<OBJECT data="YourFile.pdf" TYPE="application/x-pdf" TITLE="SamplePdf"
WIDTH=200 HEIGHT=100>
shree
</object>
I try to find the solution and someone suggested header, not working unfortunately e.g.
Content-Type: application/pdf
Content-Disposition: inline; filename.pdf
You can use Google PDF viewer to embed pdf files on to your website. Use this link https://docs.google.com/viewer
Example:
<iframe src="https://docs.google.com/viewer?url={HTTP PATH OF THE PDF FILE}&embedded=true" width="600" height="780" style="border: none;"></iframe>
https://docs.google.com/viewer?url=http://research.google.com/archive/bigtable-osdi06.pdf
Check out PDFObject which is a Javascript library to embed PDFs in HTML files. It handles browser compatibility pretty well and will most likely work on IE8.
In your HTML, you could set up a div to display the PDFs:
<div id="pdfRenderer"></div>
Then, you can have Javascript code to embed a PDF in that div:
var pdf = new PDFObject({
url: "https://sample.pdf",
id: "pdfRendered",
pdfOpenParams: {
view: "FitH"
}
}).embed("pdfRenderer");
Cheers
Trick Chrome and Firefox (and maybe other browsers) into displaying the PDFs using the Adobe Reader plugin (for full PDF Open Parameters support among other benefits) by using one of the following 'Adobe PDF in XML Format' types in your embed code:
application/vnd.adobe.pdfxml
application/vnd.adobe.x-mars
This works fine as of my answer today and I'm hopeful it will continue to work fine. I'm using it currently with standard PDF files as a workaround for embedding PDF files in the browser that need to use the Adobe PDF plugin rather than the browser's built-in PDF rendering. Even though my PDF files are standard (non-XML) files, they appear to load just fine with this new application type parameter.
<OBJECT data="YourFile.pdf" TYPE="application/vnd.adobe.pdfxml" TITLE="SamplePdf"
WIDTH=200 HEIGHT=100>
shree
</object>