If you want to use custom elements, you need to insert a hyphen in the name of your tag to make sure that it will not be used in the future standard, for example: <ultimate-audio> .
You should also use version 1 of the Custom Elements specification, which uses customElements.define() instead of document.registerElement() to register a new element.
Finally, you cannot use the extends:'audio' parameter if you want to create a new tag.
You can use the class definition in all modern browsers:
Content ulimate-audio.html:
<template> <h3>UAI</h3> <nav> <button id=PlayBtn>Play</button> <button id=StopBtn>Stop</button> <input id=AutoplayCB type=checkbox disabled>Auto-Play <div>Source : <output id=SourceOut></output></div> </nav> </template> <script> ( function ( owner ) { class UAI extends HTMLElement { constructor () { super() this.model = {} this.view = {} } connectedCallback () { </script>
The user interface of your control is defined in <template> , where you can add a <style> element. Then you can use your tag as follows:
In the header include the user element:
<link rel="import" href="ultimate-audio.html">
In body use the new tag:
<ultimate-audio id=UA src="path/file.mp3" autoplay></ultimate-audio>
The play() , stop() methods, and the src and autoplay properties can be called by the javascript form:
UA.src = "path/file2.mp3" UA.play()
source share