Forums
New posts
Search forums
News
Security News
Technology News
Giveaways
Giveaways, Promotions and Contests
Discounts & Deals
Reviews
Users Reviews
Video Reviews
Support
Windows Malware Removal Help & Support
Inactive Support Threads
Mac Malware Removal Help & Support
Mobile Malware Removal Help & Support
Blog
Log in
Register
What's new
Search
Search titles only
By:
Search titles only
By:
Reply to thread
Menu
Install the app
Install
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Forums
Security
Guides - Privacy & Security Tips
How to script a music player quickly in HTML5 (fixed)
Message
<blockquote data-quote="Dejan" data-source="post: 7424" data-attributes="member: 69"><p>I thought I'd write a small tutorial on how to script a basic HTML5 music player, I'll be writing a guide on how to script a video player soon, but for now I'm having some issues with that, so hopefully this will suffice. HTML5 will be the new standard for HTML (which came in 1999), XHTML and HTML DOM. Although a basic knowledge of HTML will definitely help, HTML5 is much easier to work with and can be learned by even complete newbie's, if you want to learn the whole language (not just what I'm about to show you), visit W3Schools or another tutorial site for help.</p><p></p><p>Let's get started, first thing you need to know is which browsers HTML5 is compatible with, currently, all known browsers (Firefox, Chrome, Opera, Safari) are compatible with their latest versions, IE 9 although compatible, IE 8 isn't. Now for the specifics, here's a list of the formats browser will support:</p><p></p><p></p><p></p><p>For this tutorial I'm going to be using ogg since it's compatible with almost all browsers, you can follow this tutorial using any format from the ones above, if you want to convert an audio file or even video file to ogg, you can use this tool. Let's use Nyan Cat audio file for this one <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite110" alt=";)" title="Wink ;)" loading="lazy" data-shortname=";)" /> Open up a text editor such as Notepad, Wordpad or any other capable editor, I'm using gedit (ubuntu) for this, but it works the same, I recommend Notepad++ also. Now to start with the code, type in the standard HTML tags [php]<html> and </html>[/php] and also between those, type in the [php]<body> </body>[/php] tags, so it should look like this...</p><p></p><p>[php]<html></p><p><body></p><p></body></p><p></html>[/php]</p><p></p><p>Okay, now to fill in the info, to add the audio player, type in [php]<audio src="song.ogg" controls="controls"> </audio>[/php] between [php]<body> and </body>[/php]</p><p></p><p>[php]<html></p><p><body></p><p><audio src="song.ogg" controls="controls"> </p><p></audio></p><p></body></p><p></html>[/php]</p><p></p><p>Replace song.ogg with the name of the audio file, make sure to include the .format, for me it'll look like this....</p><p></p><p>[php]<html></p><p><body></p><p><audio src="Nyan.ogg" controls="controls"></p><p></audio></p><p></body></p><p></html>[/php]</p><p></p><p>Okay, now just save it as name.html and place it in the same directory (folder) as the audio file you want to use, now open it with your web browser (one that's compatible) and your done! But lets say you want to add some things, like a background color and a tiltle, for this add [php]<style> </style>[/php] and [php]<head> </head>[/php] between [php]<html> </html>[/php] It should look like this...</p><p></p><p>[php]<html></p><p><head></p><p></head> </p><p><style></p><p></style></p><p><body></p><p><audio src="Nyan.ogg" controls="controls"></p><p></audio></p><p></body></p><p></html>[/php]</p><p></p><p>And now type in body { background blue; color #FF0000 } between [php]<style> </style>[/php] Also add [php]<title>My amazing song</title>[/php] between the head tags....</p><p></p><p>[php]<html></p><p><head></p><p><title>My amazing song</title></p><p></head> </p><p><style></p><p> body {</p><p> background: blue;</p><p> color: #FF0000</p><p> }</p><p></style></p><p><body></p><p><audio src="Nyan.ogg" controls="controls"></p><p></audio></p><p></body></p><p></html>[/php]</p><p></p><p>And we're done! Now you'll have the background and title, but for extra functionality, here are some options, paste any of these after controls="controls" </p><p></p><p></p><p></p><p>And that's it! Here's an <a href="http://dejan.exofire.net/stuff/code.html" target="_blank">example</a> on my own site, it took me time to write this, so say thanks if it helped you <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite109" alt=":)" title="Smile :)" loading="lazy" data-shortname=":)" /></p></blockquote><p></p>
[QUOTE="Dejan, post: 7424, member: 69"] I thought I'd write a small tutorial on how to script a basic HTML5 music player, I'll be writing a guide on how to script a video player soon, but for now I'm having some issues with that, so hopefully this will suffice. HTML5 will be the new standard for HTML (which came in 1999), XHTML and HTML DOM. Although a basic knowledge of HTML will definitely help, HTML5 is much easier to work with and can be learned by even complete newbie's, if you want to learn the whole language (not just what I'm about to show you), visit W3Schools or another tutorial site for help. Let's get started, first thing you need to know is which browsers HTML5 is compatible with, currently, all known browsers (Firefox, Chrome, Opera, Safari) are compatible with their latest versions, IE 9 although compatible, IE 8 isn't. Now for the specifics, here's a list of the formats browser will support: For this tutorial I'm going to be using ogg since it's compatible with almost all browsers, you can follow this tutorial using any format from the ones above, if you want to convert an audio file or even video file to ogg, you can use this tool. Let's use Nyan Cat audio file for this one ;) Open up a text editor such as Notepad, Wordpad or any other capable editor, I'm using gedit (ubuntu) for this, but it works the same, I recommend Notepad++ also. Now to start with the code, type in the standard HTML tags [php]<html> and </html>[/php] and also between those, type in the [php]<body> </body>[/php] tags, so it should look like this... [php]<html> <body> </body> </html>[/php] Okay, now to fill in the info, to add the audio player, type in [php]<audio src="song.ogg" controls="controls"> </audio>[/php] between [php]<body> and </body>[/php] [php]<html> <body> <audio src="song.ogg" controls="controls"> </audio> </body> </html>[/php] Replace song.ogg with the name of the audio file, make sure to include the .format, for me it'll look like this.... [php]<html> <body> <audio src="Nyan.ogg" controls="controls"> </audio> </body> </html>[/php] Okay, now just save it as name.html and place it in the same directory (folder) as the audio file you want to use, now open it with your web browser (one that's compatible) and your done! But lets say you want to add some things, like a background color and a tiltle, for this add [php]<style> </style>[/php] and [php]<head> </head>[/php] between [php]<html> </html>[/php] It should look like this... [php]<html> <head> </head> <style> </style> <body> <audio src="Nyan.ogg" controls="controls"> </audio> </body> </html>[/php] And now type in body { background blue; color #FF0000 } between [php]<style> </style>[/php] Also add [php]<title>My amazing song</title>[/php] between the head tags.... [php]<html> <head> <title>My amazing song</title> </head> <style> body { background: blue; color: #FF0000 } </style> <body> <audio src="Nyan.ogg" controls="controls"> </audio> </body> </html>[/php] And we're done! Now you'll have the background and title, but for extra functionality, here are some options, paste any of these after controls="controls" And that's it! Here's an [url=http://dejan.exofire.net/stuff/code.html]example[/url] on my own site, it took me time to write this, so say thanks if it helped you :) [/QUOTE]
Insert quotes…
Verification
Post reply
Top