New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

stream-to-device

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-to-device

Route audio streams to a specific hardware device

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

stream-to-device

Output a media stream (audio or video) to a specific hardware device

Install

npm install stream-to-device --save

API

var stream = streamToDevice(media, deviceId)

media is a Media Stream Object. deviceId is an identifier for each hardware device returned by enumerateDevices. If no device is specified, outputs to default hardware device.

stream.setDevice(deviceId)

Change output hardware device

stream.setMedia(media)

Change MediaStream

Example

Route microphone input to hardware device chosen from dropdown

const getMedia = require('getusermedia')
const enumerateDevices = require('enumerate-devices')
const streamToDevice = require('stream-to-device')

// get user media
getMedia({video: false, audio: true}, function (err, media) {
 	if (err) throw err

 	//route stream to specified device
 	var stream = streamToDevice(media, 'default')
	
	// create dropdown of available hardware devices
	enumerateDevices().then(function(devices) {
		var select = document.createElement('select');

		devices.forEach(function(d){
			if(d.kind==='audiooutput' || d.kind==='videooutput') {
				var option = document.createElement('option')
	  		    option.value = d.deviceId
	  		    option.text = d.label;
	  		    select.appendChild(option)
			}
		})

		document.body.appendChild(select)

		//set device on selection
		select.onchange = function(e){
			stream.setDevice(e.target.value)
		}
		
	}).catch(function(err) {
		throw(err)
	})

})

Keywords

FAQs

Package last updated on 25 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc