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

accept other audio formats for AudioTaskView #302

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions source/client/ui/story/AudioTaskView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,19 @@ export default class AudioTaskView extends TaskView<CVAudioTask>
}

const id = element.parentElement.parentElement.id;
const fileProp = id == "filename" ? this.task.ins.filepath : this.task.ins.captionPath;
const extText = id == "filename" ? ".mp3" : ".vtt";

if(filename.toLowerCase().endsWith(extText)) {
const type = (id == "filename")? "audio": "subs";
const fileProp = (type == "audio") ? this.task.ins.filepath : this.task.ins.captionPath;

const ext = filename.toLowerCase().split(".").pop();
if(type === "subs" && ext != "vtt"){
Notification.show(`Unable to load - Only ${type === "subs"?".vtt":".mp3,.m4a"} files are currently supported.`, "warning");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this restructuring, the type === "subs" check isn't really necessary anymore

}else if(type === "audio" && ["mp3","m4a","flac","ogg","wav"].indexOf(ext) === -1){
Notification.show(`Unable to load - Unsupported audio format .${ext}`, "warning");
}else{
if(type === "audio" && ext !== "mp3" && ext != "wav"){
// Only mp3 and wav have 100% browser support
Notification.show(`.${ext} audio file are not supported by some browsers`, "info", 3000);
}
if(newFile !== null) {
const mediaManager = this.system.getMainComponent(CVMediaManager);
mediaManager.uploadFile(filename, newFile, mediaManager.root).then(() => fileProp.setValue(filename)).catch(e => {
Expand All @@ -172,9 +181,6 @@ export default class AudioTaskView extends TaskView<CVAudioTask>
fileProp.setValue(filename);
}
}
else {
Notification.show(`Unable to load - Only ${extText} files are currently supported.`, "warning");
}

element.classList.remove("sv-drop-zone");
this._dragCounter = 0;
Expand Down