dia

Forbes’s list of self-made American women has two with India connect




dia

Netflix to make first original series in India




dia

Axis Bank unveils India’s first certified green bond on LSE




dia

Greenko raises $230 million from ADIA, GIC




dia

By 2021, India to have 810 m smartphone subscriptions




dia

RBI panel to study FinTech business in India




dia

Umang Bedi is new Facebook India head




dia

Arundhati Bhattacharya leads 4 Indian women on Forbes global power list




dia

Media & Entertainment to be $40 billion industry by 2020: PwC




dia

‘India is a bright spot in global smartphone scene’




dia

Most employees in India prefer to work from home

In terms of gender, women are motivated to work more for promotions while men seek to increase their influence at work.




dia

Ikea to start production unit in India




dia

Jaguar makes cars affordable in India to woo new buyers




dia

Hyundai Motor India's ₹27,870 crore IPO subscribed 9% so far on Day 1

This is the largest IPO in India, surpassing LIC's initial share sale of ₹21,000 crore.




dia

Hyundai Motor India's record ₹27,870 crore IPO fully subscribed

The ₹27,870 crore initial share sale got bids for 14,07,68,187 shares against 9,97,69,810 shares on offer, translating into 1.41 times the subscription, as per NSE data till 13:21 hours




dia

Hyundai Motor India’s IPO sees muted response from retail investors, issue subscribed 2.37 times

The IPO received lowest retail subscription among some of the big IPOs that had hit the Indian capital markets




dia

Hyundai Motor India debuts at BSE at a discount of 1.48%, falls nearly 6% post listing

This is the biggest ever IPO to have ever hit in the Indian capital markets




dia

Hyundai Motor India shares jump 6%

Hyundai shares climbed 5.91% to ₹1,928.15 from the previous close on the BSE. At the NSE, the stock surged 6% to ₹1,928.90




dia

Mediation should be given priority in family dispute cases: Chief Justice




dia

Nature of barriers determines first passage times in heterogeneous media

Soft Matter, 2024, 20,8353-8362
DOI: 10.1039/D4SM00908H, Paper
Moumita Dasgupta, Sougata Guha, Leon Armbruster, Dibyendu Das, Mithun K. Mitra
The nature of barriers control the first passage times in heterogenous media. For entropic barriers, the first passage times increases monotonically with increasing number of barriers, while for energetic barriers, passage times show a non-monotonic behaviour with increasing barriers.
The content of this RSS Feed (c) The Royal Society of Chemistry




dia

Building a Dictaphone Using Media Recorder and getUserMedia

Chris Mills brushes up his shorthand and shows how the MediaStream Recording API in modern browsers can be used to capture audio directly from the user’s device. Inching ever closer to the capabilities of native software, it truly is an exciting time to be a web developer.


The MediaStream Recording API makes it easy to record audio and/or video streams. When used with MediaDevices.getUserMedia(), it provides an easy way to record media from the user’s input devices and instantly use the result in web apps. This article shows how to use these technologies to create a fun dictaphone app.

A sample application: Web Dictaphone

To demonstrate basic usage of the MediaRecorder API, we have built a web-based dictaphone. It allows you to record snippets of audio and then play them back. It even gives you a visualisation of your device’s sound input, using the Web Audio API. We’ll just concentrate on the recording and playback functionality in this article, for brevity’s sake.

You can see this demo running live, or grab the source code on GitHub. This has pretty good support on modern desktop browsers, but pretty patchy support on mobile browsers currently.

Basic app setup

To grab the media stream we want to capture, we use getUserMedia(). We then use the MediaRecorder API to record the stream, and output each recorded snippet into the source of a generated <audio> element so it can be played back.

We’ll first declare some variables for the record and stop buttons, and the <article> that will contain the generated audio players:

const record = document.querySelector('.record');
const stop = document.querySelector('.stop');
const soundClips = document.querySelector('.sound-clips');

Next, we set up the basic getUserMedia structure:

if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
   console.log('getUserMedia supported.');
   navigator.mediaDevices.getUserMedia (
      // constraints - only audio needed for this app
      {
         audio: true
      })

      // Success callback
      .then(function(stream) {

      })

      // Error callback
      .catch(function(err) {
         console.log('The following `getUserMedia` error occured: ' + err);
      }
   );
} else {
   console.log('getUserMedia not supported on your browser!');
}

The whole thing is wrapped in a test that checks whether getUserMedia is supported before running anything else. Next, we call getUserMedia() and inside it define:

  • The constraints: Only audio is to be captured for our dictaphone.
  • The success callback: This code is run once the getUserMedia call has been completed successfully.
  • The error/failure callback: The code is run if the getUserMedia call fails for whatever reason.

Note: All of the code below is found inside the getUserMedia success callback in the finished version.

Capturing the media stream

Once getUserMedia has created a media stream successfully, you create a new Media Recorder instance with the MediaRecorder() constructor and pass it the stream directly. This is your entry point into using the MediaRecorder API — the stream is now ready to be captured into a <Blob>, in the default encoding format of your browser.

const mediaRecorder = new MediaRecorder(stream);

There are a series of methods available in the MediaRecorder interface that allow you to control recording of the media stream; in Web Dictaphone we just make use of two, and listen to some events. First of all, MediaRecorder.start() is used to start recording the stream once the record button is pressed:

record.onclick = function() {
  mediaRecorder.start();
  console.log(mediaRecorder.state);
  console.log("recorder started");
  record.style.background = "red";
  record.style.color = "black";
}

When the MediaRecorder is recording, the MediaRecorder.state property will return a value of “recording”.

As recording progresses, we need to collect the audio data. We register an event handler to do this using mediaRecorder.ondataavailable:

let chunks = [];

mediaRecorder.ondataavailable = function(e) {
  chunks.push(e.data);
}

Last, we use the MediaRecorder.stop() method to stop the recording when the stop button is pressed, and finalize the Blob ready for use somewhere else in our application.

stop.onclick = function() {
  mediaRecorder.stop();
  console.log(mediaRecorder.state);
  console.log("recorder stopped");
  record.style.background = "";
  record.style.color = "";
}

Note that the recording may also stop naturally if the media stream ends (e.g. if you were grabbing a song track and the track ended, or the user stopped sharing their microphone).

Grabbing and using the blob

When recording has stopped, the state property returns a value of “inactive”, and a stop event is fired. We register an event handler for this using mediaRecorder.onstop, and construct our blob there from all the chunks we have received:

mediaRecorder.onstop = function(e) {
  console.log("recorder stopped");

  const clipName = prompt('Enter a name for your sound clip');

  const clipContainer = document.createElement('article');
  const clipLabel = document.createElement('p');
  const audio = document.createElement('audio');
  const deleteButton = document.createElement('button');

  clipContainer.classList.add('clip');
  audio.setAttribute('controls', '');
  deleteButton.innerHTML = "Delete";
  clipLabel.innerHTML = clipName;

  clipContainer.appendChild(audio);
  clipContainer.appendChild(clipLabel);
  clipContainer.appendChild(deleteButton);
  soundClips.appendChild(clipContainer);

  const blob = new Blob(chunks, { 'type' : 'audio/ogg; codecs=opus' });
  chunks = [];
  const audioURL = window.URL.createObjectURL(blob);
  audio.src = audioURL;

  deleteButton.onclick = function(e) {
    let evtTgt = e.target;
    evtTgt.parentNode.parentNode.removeChild(evtTgt.parentNode);
  }
}

Let’s go through the above code and look at what’s happening.

First, we display a prompt asking the user to name their clip.

Next, we create an HTML structure like the following, inserting it into our clip container, which is an <article> element.

<article class="clip">
  <audio controls></audio>
  <p>_your clip name_</p>
  <button>Delete</button>
</article>

After that, we create a combined Blob out of the recorded audio chunks, and create an object URL pointing to it, using window.URL.createObjectURL(blob). We then set the value of the <audio> element’s src attribute to the object URL, so that when the play button is pressed on the audio player, it will play the Blob.

Finally, we set an onclick handler on the delete button to be a function that deletes the whole clip HTML structure.

So that’s basically it — we have a rough and ready dictaphone. Have fun recording those Christmas jingles! As a reminder, you can find the source code, and see it running live, on the MDN GitHub.


This article is based on Using the MediaStream Recording API by Mozilla Contributors, and is licensed under CC-BY-SA 2.5.


About the author

Chris Mills manages the MDN web docs writers’ team at Mozilla, which involves spreadsheets, meetings, writing docs and demos about open web technologies, and occasional tech talks at conferences and universities. He used to work for Opera and W3C, and enjoys playing heavy metal drums and drinking good beer.

More articles by Chris




dia

Inspired by Persia, Indian in design

Anjalee and Arjun Kapoor on their latest collection ‘Persian Flora’ and the importance of connecting with people and places




dia

Uniqlo turns three in the India market; launches second edition of its collaboration with Italian luxury fashion house Marni

Headquartered in Tokyo, the Japanese apparel brand focusses on technology and sustainability, and its latest collection of fleece jackets is made of recycled PET bottles



  • Life &amp; Style

dia

Sahodaran’s 2023 calendar highlights India’s textile heritage

It was the effort of four photographers, 14 models, and three stylists, and was shot at four locations



  • Life &amp; Style

dia

What’s the deal with Indian food?

One simple step to modify our perfectly balanced native diet to suit today’s lifestyle




dia

Time to act against early-onset diabetes

Catching diabetes in its early stages could mean lesser complications later




dia

Editorial. Monetary easing in the West good news for India

But food inflation could hold the RBI’s hand in reversing its interest rate cycle in the near future




dia

Editorial. India Inc Q1 results provide little fuel for market rally

A surge in prices of fuel, metals and industrial feedstock led to a spike in production and operating costs this quarter, denting profit growth




dia

Editorial. Escalation of West Asia conflict could hurt India

In August this year, petroleum exports fell 37 per cent to $5.95 billion




dia

Editorial. China market stimulus may not impact India’s FPI flows

While foreign funds may be buying Chinese equity for the short-term, the Indian market offers better returns for long-term investors




dia

Indian banks increased their overseas presence during 2023-24 : RBI Survey

During the year, the number of branches and employees of foreign banks in India also expanded by 0.6 per cent and 1.4 per cent, respectively



  • Money &amp; Banking

dia

SBI named Best Bank in India for 2024 by Global Finance Magazine

SBI Chairman CS Setty accepted the award



  • Money &amp; Banking

dia

Indian Bank posts 36% rise in Q2 net at ₹2,707 crore on the back of reduced slippages

For the first half of the fiscal, the bank’s net profit exceeded ₹5,000 crore, totalling ₹5,110 crore, up from ₹3,697 crore



  • Money &amp; Banking

dia

Indian Overseas Bank launches online Re-KYC service for hassle-free updates

This new digital service allows customers to update their KYC information without visiting the bank branch, utilising three accessible channels: the IOB website, SMS, or email



  • Money &amp; Banking

dia

Use-case approach to drive digital payments, says Worldline India CEO

The payments firm has set up POS terminals at villages in Tamil Nadu for payment of taxes and also for devotees making payments to temples.



  • Money &amp; Banking

dia

Deutsche Bank infuses ₹5,113 crore capital into India operations

Over the last decade, the bank has significantly increased its capital investments, tripling the capital base for Deutsche Bank Group in India



  • Money &amp; Banking

dia

Finance Minister launches five Nari Shakti branches of Union Bank of India for women entrepreneurs

Union Bank of India opens Nari Shakti branches in Bengaluru, Chennai, Visakhapatnam, and Jaipur



  • Money &amp; Banking

dia

Bitcoin nears $80k, little progress on crypto regulation in India

A report by Chainalysis says India leads the world on global adoption index for crypto this year




dia

Bank of India reports 63% jump in Q2FY25 net profit at ₹2,374 crore

The profitability comes despite the public sector bank seeing 111 per cent y-o-y jump in loan loss provisions at ₹1,427 crore 



  • Money &amp; Banking

dia

Naked Island - Sober / directed by: Élise Simard ; produced by: Michael Fukushima, Jelena Popovic, Maral Mohammadian ; production agency: National Film Board of Canada (Montreal)

Montreal : National Film Board of Canada, 2017




dia

YSRCP social media activist Varra Ravindra Reddy sent to judicial remand

Police form district-level teams to monitor ‘defamatory posts’




dia

The U.K. and ‘leaving lessons’ from the Indian Ocean

In its decolonisation in the Indian Ocean, the U.K. must ensure that all island nations agree to maintain the fully protected environmental status of the Chagos archipelago




dia

India needs to move from legalese to ‘legal-easy’

The language used in Indian laws needs to be simpler to read and understand, which will ensure inclusive justice




dia

Ensuring private sector collaborations in India’s national climate strategy

For this, the Competition Commission of India needs to focus on the interplay between competition law and sustainability




dia

The fading allure of media endorsements

Should media houses in the U.S. be endorsing political candidates? The question is gaining more traction with every election cycle




dia

India’s SDG focus and its human development issues

Countries that aspire to achieve sustainable development need to take steps to boost human development




dia

Forecasting better in India, come rain or shine

With improvements, the ‘Mausam Mission’ will transform how weather information can help India become climate smart




dia

The case for a nature restoration law in India

The law enacted by the European Union recently is a model worth following




dia

The private sector holds the key to India’s e-bus push

If there is to be scale in the electric bus market in India, private sector participation is critical




dia

The essential skill of ‘media and information literacy’

The complex digital environment poses governance challenges, making it important to create an ‘Internet of Trust’ for a safe digital world