Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renamed video to media #246

Merged
merged 2 commits into from Jan 17, 2015
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Next

Renamed instances of 'video' to 'media'

  • Loading branch information
ArtskydJ committed Jan 16, 2015
commit 366b8912a24f5e448c5dcf67854604e988c3df96
@@ -4,7 +4,7 @@ var debug = require('debug')('webtorrent:file-stream')
var inherits = require('inherits')
var path = require('path')
var stream = require('stream')
var VideoStream = require('./video-stream')
var MediaStream = require('./media-stream')

inherits(FileStream, stream.Readable)

@@ -108,8 +108,7 @@ FileStream.prototype.pipe = function (dst) {
: self._extname === '.mp3'
? 'audio/mpeg'
: undefined
// TODO: consider renaming VideoStream to MediaStream, since it supports audio as well.
return pipe.call(self, new VideoStream(dst, { type: type }))
return pipe.call(self, new MediaStream(dst, { type: type }))
} else
return pipe.call(self, dst)
}
@@ -1,32 +1,32 @@
module.exports = VideoStream
module.exports = MediaStream

var debug = require('debug')('webtorrent:video-stream')
var debug = require('debug')('webtorrent:media-stream')
var inherits = require('inherits')
var once = require('once')
var stream = require('stream')

var MediaSource = typeof window !== 'undefined' &&
(window.MediaSource || window.WebKitMediaSource)

inherits(VideoStream, stream.Writable)
inherits(MediaStream, stream.Writable)

function VideoStream (video, opts) {
function MediaStream (media, opts) {
var self = this
if (!(self instanceof VideoStream)) return new VideoStream(video, opts)
if (!(self instanceof MediaStream)) return new MediaStream(media, opts)
stream.Writable.call(self, opts)

self.video = video
self.media = media
opts = opts || {}
opts.type = opts.type || 'video/webm; codecs="vorbis,vp8"'

debug('new videostream %s %s', video, JSON.stringify(opts))
debug('new mediastream %s %s', media, JSON.stringify(opts))

self._mediaSource = new MediaSource()
self._playing = false
self._sourceBuffer = null
self._cb = null

self.video.src = window.URL.createObjectURL(self._mediaSource)
self.media.src = window.URL.createObjectURL(self._mediaSource)

var sourceopen = once(function () {
self._sourceBuffer = self._mediaSource.addSourceBuffer(opts.type)
@@ -43,7 +43,7 @@ function VideoStream (video, opts) {
window.vs = self
}

VideoStream.prototype._write = function (chunk, encoding, cb) {
MediaStream.prototype._write = function (chunk, encoding, cb) {
var self = this
if (!self._sourceBuffer) {
self._cb = function (err) {
@@ -60,12 +60,12 @@ VideoStream.prototype._write = function (chunk, encoding, cb) {
debug('appendBuffer %s', chunk.length)
self._cb = cb
if (!self._playing) {
self.video.play()
self.media.play()
self._playing = true
}
}

VideoStream.prototype._flow = function () {
MediaStream.prototype._flow = function () {
var self = this
debug('flow')
if (self._cb) {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.