Custom html5 audio tag, how to add volume buttons?


No

I'm just creating a directive to set up live streaming based on HTML5 tags, but I need to add a volume button, how to achieve it?

see instructions

var app = angular.module('app', []);

app.directive('audioPlay', function() {
  return {
    restrict: 'E',
    link: function(scope, element, attr) {

      scope.playOrPause = true;

      var player = element.children('.player')[0];

      scope.playMusic = function() {
        scope.playOrPause = false;
        player.play();
      }

      scope.stopMusic = function() {
        scope.playOrPause = true;
        player.pause();
      }

    }
  };
});

Here is the corresponding html

<div ng-app='app'>
      <audio-play>
        <audio class="player">
          <source src="http://fire.wavestreamer.com:9711/UrbanetRadio"/>
        </audio>
        <button class="button button-clear"
                ng-click="playMusic()"
                ng-hide="!playOrPause">
          PLAY
        </button>
        <button class="button button-clear"
                ng-click="stopMusic()"
                ng-show="!playOrPause">
          PAUSE
        </button>
      </audio-play>
</div>

I don't want to use controlsattr for basic html5 audio , I am doing it myself, what I need is help with the volume buttons.

Yauheni Leichanok

Here is some code that might be useful. You can input type="range"use as volume control:

<input type="range" ng-model="volume" ng-change="changeVolume($event)" step="0.1" min="0" max="1">

and use volumethe audio element's properties to change the sound level :

scope.changeVolume = function(event) {
    player.volume = scope.volume; // from 0 to 1
};

You can also bind the entered value to the model, or use a button instead of a slider - there are many variations, but you get the idea :)

Related


Custom html5 audio tag, how to add volume buttons?

No I'm just creating a directive to set up live streaming based on HTML5 tags, but I need to add a volume button, how to achieve it? see instructions var app = angular.module('app', []); app.directive('audioPlay', function() { return { restrict: 'E',

Bind HTML5 <audio> tagged controls to custom buttons in Angular

Jamie I have an audio player in my template that uses a <audio>tag , but I want to use my own styles for the player, so I set the actual local audio player with that tag to hidden display: none;. Then I want to bind the controls of the hidden player to my own

Bind HTML5 <audio> tagged controls to custom buttons in Angular

Jamie I have an audio player in my template that uses a <audio>tag , but I want to use my own styles for the player, so I set the actual local audio player with that tag to hidden display: none;. Then I want to bind the controls of the hidden player to my own

Bind HTML5 <audio> tagged controls to custom buttons in Angular

Jamie I have an audio player in my template that uses a <audio>tag , but I want to use my own styles for the player, so I set the actual local audio player with that tag to hidden display: none;. Then I want to bind the controls of the hidden player to my own

How to add drive link in audio tag in html?

Setaron I am using audio tag in my html code to play audio in my webpage, I have a doubt, without passing audio directly to audio tag, I want to use google drive link (the link contains an audio). Please help me achieve this. .. <audio controls autoplay> <sour

How to bind audio track volume slider to physical volume buttons

Jeff Janes I want to tie the slider action of the volume controls with the volume buttons, so if those buttons are used, the slider will adjust as well. I thought it was possible, but I'm not sure. Currently, I have a working slider volume control, but it has

How to load file into html5 audio tag

Mason Wright How can I load audio files from tag <input type="file">to audio tag? I tried: <input type="file" id="file"></input> <script> var file = document.getElementById("file"); var audio = document.createElement("audio"); audio.src = file.value; document.

How to load file into html5 audio tag

Mason Wright How can I load audio files from tag <input type="file">to audio tag? I tried: <input type="file" id="file"></input> <script> var file = document.getElementById("file"); var audio = document.createElement("audio"); audio.src = file.value; document.

How to load file into html5 audio tag

Mason Wright How can I load audio files from tag <input type="file">to audio tag? I tried: <input type="file" id="file"></input> <script> var file = document.getElementById("file"); var audio = document.createElement("audio"); audio.src = file.value; document.

How to force HTML5 audio tag to reload (changing) file

Joe I have a code in javascript that generates a wav file which I then attach to the button so it can be played: function makeWav(){ $.get(("../testsound/getsound.pl?text="+document.myform.outputtext.value)); setTimeout(callback, 500);

How to load file into html5 audio tag

Mason Wright How can I load audio files from tag <input type="file">to audio tag? I tried: <input type="file" id="file"></input> <script> var file = document.getElementById("file"); var audio = document.createElement("audio"); audio.src = file.value; document.

How to load file into html5 audio tag

Mason Wright How can I load audio files from tag <input type="file">to audio tag? I tried: <input type="file" id="file"></input> <script> var file = document.getElementById("file"); var audio = document.createElement("audio"); audio.src = file.value; document.

Audio tag HTML5

viking I made a web application with HTML, CSS and JS. I parse the xml with the url with any song and then install the player with this song. I write the following code for JS to change the song: var newSongHtml = '<div class="navbar-header" id="playersongs">'

Audio tag HTML5

viking I made a web application with HTML, CSS and JS. I parse the xml with the url with any song and then install the player with this song. I write the following code for JS to change the song: var newSongHtml = '<div class="navbar-header" id="playersongs">'

Audio tag HTML5

viking I made a web application with HTML, CSS and JS. I parse the xml with the url with any song and then install the player with this song. I write the following code for JS to change the song: var newSongHtml = '<div class="navbar-header" id="playersongs">'

Audio tag HTML5

viking I made a web application with HTML, CSS and JS. I parse the xml with the url with any song and then install the player with this song. I write the following code for JS to change the song: var newSongHtml = '<div class="navbar-header" id="playersongs">'

How to set specific starting volume for <audio> tag

Almir I only have basic knowledge of HTML and CSS, and have googled extensively trying to find an answer to this question - all seem to point to JavaScript and/or jQuery. I tried it but it doesn't work. My audio file starts playing when my website loads. I wan

Volume control for HTML5 audio tags

Reynolds Is it possible that the audio tab only shows the volume setting and not the rest? Hope you can help me. kiva I think the answer is no, because browsers will process your files and each browser will have a different player. Since <audio>markup doesn't

Volume control for HTML5 audio tags

Reynolds Is it possible that the audio tab only shows the volume setting and not the rest? Hope you can help me. kiva I think the answer is no, because browsers will process your files and each browser will have a different player. Since <audio>markup doesn't

How to use slider to change HTML5 audio volume or track position?

username I know .play()and .stop()method. However, is there a way to link the slider to that volume? Or slide to track position? Is that possible? And thanks for the help. Thanks! Rocco C. Burjan jQuery UI makes it very simple: $(function() { var $aud = $("

How to use slider to change HTML5 audio volume or track position?

username I know .play()and .stop()method. However, is there a way to link the slider to that volume? Or slide to track position? Is that possible? And thanks for the help. Thanks! Rocco C. Burjan jQuery UI makes it very simple: $(function() { var $aud = $("

HTML5 _ How to add hyperlink to video tag

hi fight How can I add a hyperlink on a website to start a video from the time indicated in src1, src2 and src3 of .html5-doc? It should be done by anyone with access to the site. <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Page Title</title> <

HTML5 _ How to add hyperlink to video tag

hi fight How can I add a hyperlink on a website to start a video from the time indicated in src1, src2 and src3 of .html5-doc? It should be done by anyone with access to the site. <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Page Title</title> <

HTML5 audio tag in React

George Weld I want to use a simple HTML5 audio tag in my React app. My component looks like this: import React from 'react' class AudioPlayer extends React.Component { render() { return ( <div> <audio ref="audio_tag" src="./static/music/fo

Using HTML5 audio tag in Reactjs

Patrick Kenney I'm trying to use HTML5 tags <audio>in React , but it's not rendering. This is my first time using React, so I might be missing something obvious. I'm using an existing Drupal front end and rebuilding it in React. All my other HTML works, but HT

HTML5 audio tag in React

George Weld I want to use a simple HTML5 audio tag in my React app. My component looks like this: import React from 'react' class AudioPlayer extends React.Component { render() { return ( <div> <audio ref="audio_tag" src="./static/music/fo