Skip to content

Commit

Permalink
rename video types to video type
Browse files Browse the repository at this point in the history
  • Loading branch information
binarykitchen committed Nov 1, 2024
1 parent e277446 commit 9a24a6c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import VideomailEvents from "./types/events";
import { PartialVideomailClientOptions } from "./types/options";
import RecordingStats from "./types/RecordingStats";
import Videomail from "./types/Videomail";
import { VideoTypes } from "./types/VideoTypes";
import { VideoType } from "./types/VideoType";

export type { Videomail };
export type { VideomailEvents };
export type { PartialVideomailClientOptions };
export type { RecordingStats };
export { VideoTypes };
export { VideoType };

export default VideomailClient;
2 changes: 1 addition & 1 deletion src/types/VideoTypes.ts → src/types/VideoType.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export enum VideoTypes {
export enum VideoType {
WebM = "webm",
MP4 = "mp4",
}
16 changes: 8 additions & 8 deletions src/util/Browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import UAParser, { IResult } from "ua-parser-js";
import { VideomailClientOptions } from "../types/options";
import createError from "./error/createError";
import canPlayType from "./html/media/canPlayType";
import { VideoTypes } from "../types/VideoTypes";
import { VideoType } from "../types/VideoType";

const FALLBACK_VIDEO_TYPE = VideoTypes.MP4;
const FALLBACK_VIDEO_TYPE = VideoType.MP4;

class Browser {
private options: VideomailClientOptions;
private result: IResult;
private videoType: VideoTypes | undefined;
private videoType: VideoType | undefined;

public constructor(options: VideomailClientOptions) {
this.options = options;
Expand Down Expand Up @@ -84,14 +84,14 @@ class Browser {

public getVideoType(video: HTMLVideoElement) {
if (!this.videoType) {
if (canPlayType(video, VideoTypes.MP4)) {
this.videoType = VideoTypes.MP4;
} else if (canPlayType(video, VideoTypes.WebM)) {
this.videoType = VideoTypes.WebM;
if (canPlayType(video, VideoType.MP4)) {
this.videoType = VideoType.MP4;
} else if (canPlayType(video, VideoType.WebM)) {
this.videoType = VideoType.WebM;
}
}

if (this.videoType !== VideoTypes.WebM && this.videoType !== VideoTypes.MP4) {
if (this.videoType !== VideoType.WebM && this.videoType !== VideoType.MP4) {
// We only support these two. Anything else defaults to the fallback
this.videoType = FALLBACK_VIDEO_TYPE;
}
Expand Down
4 changes: 2 additions & 2 deletions src/util/html/media/canPlayType.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { VideoTypes } from "../../../types/VideoTypes";
import { VideoType } from "../../../types/VideoType";

function canPlayType(video: HTMLVideoElement, type: VideoTypes) {
function canPlayType(video: HTMLVideoElement, type: VideoType) {
const canPlayType = video.canPlayType(`video/${type}`);

// definitely cannot be played here
Expand Down
6 changes: 3 additions & 3 deletions src/wrappers/visuals/replay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Videomail from "../../types/Videomail";
import pretty from "../../util/pretty";
import { PreviewParams } from "../../types/events";
import { UnloadParams } from "../container";
import { VideoTypes } from "../../types/VideoTypes";
import { VideoType } from "../../types/VideoType";

class Replay extends Despot {
private readonly visuals: Visuals;
Expand Down Expand Up @@ -392,11 +392,11 @@ class Replay extends Despot {
}

public setMp4Source(src?: string, bustCache?: boolean) {
this.setVideoSource(VideoTypes.MP4, src, bustCache);
this.setVideoSource(VideoType.MP4, src, bustCache);
}

public setWebMSource(src?: string, bustCache?: boolean) {
this.setVideoSource(VideoTypes.WebM, src, bustCache);
this.setVideoSource(VideoType.WebM, src, bustCache);
}

public getVideoType() {
Expand Down

0 comments on commit 9a24a6c

Please sign in to comment.