Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@iyio/media-common

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@iyio/media-common - npm Package Compare versions

Comparing version 0.5.13 to 0.5.14

5

esm/src/lib/media-lib.d.ts
import { Size } from "@iyio/common";
import { GetImageDataStatsOptions, ImageStats, SnapShotResult, VideoSnapShotOptions as SnapshotOptions } from "./media-types";
import { GetImageDataStatsOptions, ImageStats, MediaRecordingResult, SnapShotResult, VideoSnapShotOptions as SnapshotOptions } from "./media-types";
export declare const getSnapshot: ({ source, type, width, height, viewBoxWidth, viewBoxHeight, flipHorizontal, flipVertical, includeStats, }: SnapshotOptions) => SnapShotResult | null;

@@ -16,3 +16,3 @@ export declare const getImageDataStats: (data: ImageData, { trueAverage }?: GetImageDataStatsOptions) => ImageStats;

export declare const getVideoInfoAsync: (src: string | Blob) => Promise<VideoInfo>;
export declare const getVideoAsync: (src: string | Blob) => Promise<{
export declare const getVideoAsync: (src: string | Blob, forPreview?: boolean) => Promise<{
video: HTMLVideoElement;

@@ -22,1 +22,2 @@ url: string;

}>;
export declare const mediaRecordingResultToBlob: (recordingResult: MediaRecordingResult) => Blob | undefined;

28

esm/src/lib/media-lib.js
import { __awaiter } from "tslib";
import { addQueryToPath, uuid } from "@iyio/common";
import { addQueryToPath, safeParseNumberOrUndefined, uuid } from "@iyio/common";
const getCanvas = () => {

@@ -189,3 +189,4 @@ const canvasHost = document.createElement('div');

const onMeta = () => {
resolve({ width: video.videoWidth, height: video.videoHeight, durationSeconds: video.duration });
var _a;
resolve({ width: video.videoWidth, height: video.videoHeight, durationSeconds: (_a = safeParseNumberOrUndefined(video.duration)) !== null && _a !== void 0 ? _a : 0 });
cleanUp();

@@ -202,3 +203,3 @@ };

};
export const getVideoAsync = (src) => {
export const getVideoAsync = (src, forPreview) => {
return new Promise((resolve, reject) => {

@@ -218,7 +219,26 @@ var _a, _b;

};
video.addEventListener('loadedmetadata', onMeta);
video.addEventListener('error', onError);
if (forPreview) {
video.currentTime = 0.1;
video.addEventListener('canplay', onMeta);
video.addEventListener('loadeddata', onMeta);
}
else {
video.addEventListener('loadedmetadata', onMeta);
}
video.src = blobUrl !== null && blobUrl !== void 0 ? blobUrl : src;
});
};
export const mediaRecordingResultToBlob = (recordingResult) => {
const first = recordingResult.data[0];
if (recordingResult.data.length === 0) {
return undefined;
}
else if (recordingResult.data.length === 1 && first && first.type === recordingResult.mimeType) {
return first;
}
else {
return new Blob(recordingResult.data, { type: recordingResult.mimeType });
}
};
//# sourceMappingURL=media-lib.js.map

@@ -24,1 +24,6 @@ export interface VideoSnapShotOptions {

}
export interface MediaRecordingResult {
data: Blob[];
recorder: MediaRecorder;
mimeType: string;
}
import { ReadonlySubject } from "@iyio/common";
import { Observable } from "rxjs";
import { MediaRecordingResult } from "./media-types";
export declare const defaultMediaRecordingAudioKBPerSecond = 2;

@@ -8,2 +9,3 @@ export declare const defaultMediaRecordingVideoKBPerSecond = 50;

stream?: MediaStream;
streams?: MediaStream[];
recorder?: MediaRecorder;

@@ -32,7 +34,2 @@ /**

}
export interface MediaRecordingResult {
data: Blob[];
recorder: MediaRecorder;
mimeType: string;
}
export declare class MediaRecording {

@@ -39,0 +36,0 @@ private readonly options;

@@ -64,2 +64,15 @@ import { __awaiter } from "tslib";

let recorder = this.options.recorder;
if (!recorder && this.options.streams) {
const stream = new MediaStream();
const streams = this.options.stream ?
[this.options.stream, ...this.options.streams] :
this.options.streams;
for (const s of streams) {
const tracks = s.getTracks();
for (const t of tracks) {
stream.addTrack(t);
}
}
recorder = new MediaRecorder(stream, getOptions());
}
if (!recorder && this.options.stream) {

@@ -66,0 +79,0 @@ recorder = new MediaRecorder(this.options.stream, getOptions());

{
"name": "@iyio/media-common",
"version": "0.5.13",
"version": "0.5.14",
"sideEffects": false,

@@ -13,3 +13,3 @@ "dependencies": {

"peerDependencies": {
"@iyio/common": "^0.5.13"
"@iyio/common": "^0.5.14"
},

@@ -16,0 +16,0 @@ "main": "./src/index.js",

import { Size } from "@iyio/common";
import { GetImageDataStatsOptions, ImageStats, SnapShotResult, VideoSnapShotOptions as SnapshotOptions } from "./media-types";
import { GetImageDataStatsOptions, ImageStats, MediaRecordingResult, SnapShotResult, VideoSnapShotOptions as SnapshotOptions } from "./media-types";
export declare const getSnapshot: ({ source, type, width, height, viewBoxWidth, viewBoxHeight, flipHorizontal, flipVertical, includeStats, }: SnapshotOptions) => SnapShotResult | null;

@@ -16,3 +16,3 @@ export declare const getImageDataStats: (data: ImageData, { trueAverage }?: GetImageDataStatsOptions) => ImageStats;

export declare const getVideoInfoAsync: (src: string | Blob) => Promise<VideoInfo>;
export declare const getVideoAsync: (src: string | Blob) => Promise<{
export declare const getVideoAsync: (src: string | Blob, forPreview?: boolean) => Promise<{
video: HTMLVideoElement;

@@ -22,1 +22,2 @@ url: string;

}>;
export declare const mediaRecordingResultToBlob: (recordingResult: MediaRecordingResult) => Blob | undefined;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getVideoAsync = exports.getVideoInfoAsync = exports.fetchBlobAsync = exports.imageSourceToImageDataAsync = exports.loadImageAsync = exports.getImageSizeAsync = exports.getContentTypeFileExt = exports.getImageDataStats = exports.getSnapshot = void 0;
exports.mediaRecordingResultToBlob = exports.getVideoAsync = exports.getVideoInfoAsync = exports.fetchBlobAsync = exports.imageSourceToImageDataAsync = exports.loadImageAsync = exports.getImageSizeAsync = exports.getContentTypeFileExt = exports.getImageDataStats = exports.getSnapshot = void 0;
const tslib_1 = require("tslib");

@@ -199,3 +199,4 @@ const common_1 = require("@iyio/common");

const onMeta = () => {
resolve({ width: video.videoWidth, height: video.videoHeight, durationSeconds: video.duration });
var _a;
resolve({ width: video.videoWidth, height: video.videoHeight, durationSeconds: (_a = (0, common_1.safeParseNumberOrUndefined)(video.duration)) !== null && _a !== void 0 ? _a : 0 });
cleanUp();

@@ -213,3 +214,3 @@ };

exports.getVideoInfoAsync = getVideoInfoAsync;
const getVideoAsync = (src) => {
const getVideoAsync = (src, forPreview) => {
return new Promise((resolve, reject) => {

@@ -229,4 +230,11 @@ var _a, _b;

};
video.addEventListener('loadedmetadata', onMeta);
video.addEventListener('error', onError);
if (forPreview) {
video.currentTime = 0.1;
video.addEventListener('canplay', onMeta);
video.addEventListener('loadeddata', onMeta);
}
else {
video.addEventListener('loadedmetadata', onMeta);
}
video.src = blobUrl !== null && blobUrl !== void 0 ? blobUrl : src;

@@ -236,2 +244,15 @@ });

exports.getVideoAsync = getVideoAsync;
const mediaRecordingResultToBlob = (recordingResult) => {
const first = recordingResult.data[0];
if (recordingResult.data.length === 0) {
return undefined;
}
else if (recordingResult.data.length === 1 && first && first.type === recordingResult.mimeType) {
return first;
}
else {
return new Blob(recordingResult.data, { type: recordingResult.mimeType });
}
};
exports.mediaRecordingResultToBlob = mediaRecordingResultToBlob;
//# sourceMappingURL=media-lib.js.map

@@ -24,1 +24,6 @@ export interface VideoSnapShotOptions {

}
export interface MediaRecordingResult {
data: Blob[];
recorder: MediaRecorder;
mimeType: string;
}
import { ReadonlySubject } from "@iyio/common";
import { Observable } from "rxjs";
import { MediaRecordingResult } from "./media-types";
export declare const defaultMediaRecordingAudioKBPerSecond = 2;

@@ -8,2 +9,3 @@ export declare const defaultMediaRecordingVideoKBPerSecond = 50;

stream?: MediaStream;
streams?: MediaStream[];
recorder?: MediaRecorder;

@@ -32,7 +34,2 @@ /**

}
export interface MediaRecordingResult {
data: Blob[];
recorder: MediaRecorder;
mimeType: string;
}
export declare class MediaRecording {

@@ -39,0 +36,0 @@ private readonly options;

@@ -67,2 +67,15 @@ "use strict";

let recorder = this.options.recorder;
if (!recorder && this.options.streams) {
const stream = new MediaStream();
const streams = this.options.stream ?
[this.options.stream, ...this.options.streams] :
this.options.streams;
for (const s of streams) {
const tracks = s.getTracks();
for (const t of tracks) {
stream.addTrack(t);
}
}
recorder = new MediaRecorder(stream, getOptions());
}
if (!recorder && this.options.stream) {

@@ -69,0 +82,0 @@ recorder = new MediaRecorder(this.options.stream, getOptions());

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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