Skip to content

Commit

Permalink
Merge pull request #286 from Smithsonian/rc-42
Browse files Browse the repository at this point in the history
Rc 42 merge
  • Loading branch information
gjcope authored Jun 27, 2024
2 parents c08cb20 + 49ed80c commit 44037f9
Show file tree
Hide file tree
Showing 25 changed files with 205 additions and 226 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "voyager",
"version": "0.41.0",
"version": "0.42.0",
"description": "Smithsonian DPO Voyager - 3D Explorer and Tool Suite",
"scripts": {
"start": "npm run server",
Expand Down
7 changes: 6 additions & 1 deletion source/client/components/CVAnnotationView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,12 @@ export default class CVAnnotationView extends CObject3D

fromData(data: IAnnotation[])
{
data.forEach(annotationJson => this.addAnnotation(new Annotation(annotationJson)));
const language = this.language.outs.language.value;
data.forEach(annotationJson => {
let a = new Annotation(annotationJson);
a.language = language;
this.addAnnotation(a);
});
this.emit<ITagUpdateEvent>({ type: "tag-update" });
}

Expand Down
28 changes: 0 additions & 28 deletions source/client/components/CVAnnotationsTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,12 @@ export default class CVAnnotationsTask extends CVTask

protected static readonly ins = {
mode: types.Enum("Mode", EAnnotationsTaskMode, EAnnotationsTaskMode.Off),
language: types.Option("Task.Language", Object.keys(ELanguageStringType).map(key => ELanguageStringType[key]), ELanguageStringType[ELanguageType.EN]),
audio: types.Option("Annotation.Audio", ["None"], 0),
selection: types.Event("Annotation.Selection")
};

protected static readonly outs = {
language: types.Enum("Interface.Language", ELanguageType, ELanguageType.EN),
};

ins = this.addInputs<CVTask, typeof CVAnnotationsTask.ins>(CVAnnotationsTask.ins);
outs = this.addOutputs<CVTask, typeof CVAnnotationsTask.outs>(CVAnnotationsTask.outs);

private _activeAnnotations: CVAnnotationView = null;
private _defaultScale = 1;
Expand Down Expand Up @@ -104,7 +99,6 @@ export default class CVAnnotationsTask extends CVTask
{
this.startObserving();
super.activateTask();
this.synchLanguage();
this.synchAudioOptions();

//this.selection.selectedComponents.on(CVAnnotationView, this.onSelectAnnotations, this);
Expand Down Expand Up @@ -133,15 +127,6 @@ export default class CVAnnotationsTask extends CVTask
this.emitUpdateEvent();
}

if(ins.language.changed) {
const newLanguage = ELanguageType[ELanguageType[ins.language.value]];

languageManager.addLanguage(newLanguage); // add in case this is a currently inactive language
languageManager.ins.language.setValue(newLanguage);
outs.language.setValue(newLanguage);
return true;
}

if(ins.audio.changed) {
const audioManager = this.activeDocument.setup.audio;
const id = ins.audio.value > 0 ? audioManager.getAudioList()[ins.audio.value - 1].id : "";
Expand All @@ -158,8 +143,6 @@ export default class CVAnnotationsTask extends CVTask
this.setAudio();
}

this.synchLanguage();

return true;
}

Expand Down Expand Up @@ -380,17 +363,6 @@ export default class CVAnnotationsTask extends CVTask
}
}

// Make sure this task language matches document
protected synchLanguage() {
const {ins} = this;
const languageManager = this.activeDocument.setup.language;

if(ins.language.value !== languageManager.outs.language.value)
{
ins.language.setValue(languageManager.outs.language.value, true);
}
}

// Update audio options
protected synchAudioOptions() {
const audioManager = this.activeDocument.setup.audio;
Expand Down
23 changes: 2 additions & 21 deletions source/client/components/CVArticlesTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export default class CVArticlesTask extends CVTask
lead: types.String("Article.Lead"),
tags: types.String("Article.Tags"),
uri: types.String("Article.URI"),
language: types.Option("Task.Language", Object.keys(ELanguageStringType).map(key => ELanguageStringType[key]), ELanguageStringType[ELanguageType.EN]),
};

protected static readonly outs = {
Expand Down Expand Up @@ -98,7 +97,6 @@ export default class CVArticlesTask extends CVTask
{
this.startObserving();
super.activateTask();
this.synchLanguage();
}

deactivateTask()
Expand All @@ -122,13 +120,6 @@ export default class CVArticlesTask extends CVTask
}
const languageManager = this.activeDocument.setup.language;

if(ins.language.changed) {
const newLanguage = ELanguageType[ELanguageType[ins.language.value]];

languageManager.addLanguage(newLanguage); // add in case this is a currently inactive language
languageManager.ins.language.setValue(newLanguage);
}

if (meta && ins.create.changed) {
const article = new Article();
const defaultFolder = CVMediaManager.articleFolder;
Expand Down Expand Up @@ -309,6 +300,7 @@ export default class CVArticlesTask extends CVTask
const ins = this.ins;
const outs = this.outs;
const meta = this.meta;
const languageManager = this.activeDocument.setup.language;
let article = this.reader.activeArticle;

if (meta && article && meta.articles.getById(article.id)) {
Expand All @@ -320,7 +312,7 @@ export default class CVArticlesTask extends CVTask
// if we don't have a uri for this language, create one so that it is editable
if(article.uri === undefined) {
const defaultFolder = CVMediaManager.articleFolder;
article.uri = `${defaultFolder}/new-article-${article.id}-${ELanguageType[ins.language.value]}.html`;
article.uri = `${defaultFolder}/new-article-${article.id}-${languageManager.codeString()}.html`;
this.ins.version.set();
}
else {
Expand All @@ -344,20 +336,9 @@ export default class CVArticlesTask extends CVTask
const article = this.activeArticle;
const {ins} = this;

this.synchLanguage();
this.onArticleChange();
}

// Make sure this task language matches document
protected synchLanguage() {
const {ins} = this;
const languageManager = this.activeDocument.setup.language;

if(ins.language.value !== languageManager.outs.language.value)
{
ins.language.setValue(languageManager.outs.language.value, true);
}
}

// Handle potential media manager name change
protected onAssetRename(event: IAssetRenameEvent) {
Expand Down
46 changes: 24 additions & 22 deletions source/client/components/CVAudioManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,29 +166,31 @@ export default class CVAudioManager extends Component
}
else {
const clip = this.audioClips[id];
const uri = clip.uris[language];
if(uri) {
const absUri = this.assetManager.getAssetUrl(uri);
clip.durations[language] = "pending";

const audioContext = new (window.AudioContext || window.webkitAudioContext)();
const request = new XMLHttpRequest();
request.open('GET', absUri, true);
request.responseType = 'arraybuffer';
request.onload = () => {
const blob = new Blob([request.response], { type: "audio/mpeg" });
const url = window.URL.createObjectURL(blob);
this._audioMap[uri] = url;
audioContext.decodeAudioData(request.response,
(buffer) => {
let duration = buffer.duration;
clip.durations[language] = duration.toString();
this.getPlayerById(id).requestUpdate();
}
)
Object.keys(clip.uris).forEach(language => {
const uri = clip.uris[language];
if(uri) {
const absUri = this.assetManager.getAssetUrl(uri);
clip.durations[language] = "pending";

const audioContext = new (window.AudioContext || window.webkitAudioContext)();
const request = new XMLHttpRequest();
request.open('GET', absUri, true);
request.responseType = 'arraybuffer';
request.onload = () => {
const blob = new Blob([request.response], { type: "audio/mpeg" });
const url = window.URL.createObjectURL(blob);
this._audioMap[uri] = url;
audioContext.decodeAudioData(request.response,
(buffer) => {
let duration = buffer.duration;
clip.durations[language] = duration.toString();
this.getPlayerById(id).requestUpdate();
}
)
}
request.send();
}
request.send();
}
});

return "pending";
}
Expand Down
35 changes: 8 additions & 27 deletions source/client/components/CVAudioTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import AudioTaskView from "../ui/story/AudioTaskView";
import { Node } from "@ff/graph/Component";
import CVDocument from "./CVDocument";
import CVAudioManager from "./CVAudioManager";
import { ELanguageStringType, ELanguageType } from "client/schema/common";
import { DEFAULT_LANGUAGE, ELanguageStringType, ELanguageType } from "client/schema/common";

////////////////////////////////////////////////////////////////////////////////

Expand All @@ -44,7 +44,6 @@ export default class CVAudioTask extends CVTask
filepath: types.String("Audio.Filepath", null),
captionPath: types.String("Audio.CaptionPath", null),
isNarration: types.Boolean("Audio.IsNarration", false),
language: types.Option("Task.Language", Object.keys(ELanguageStringType).map(key => ELanguageStringType[key]), ELanguageStringType[ELanguageType.EN]),
};

protected static readonly outs = {
Expand Down Expand Up @@ -83,8 +82,6 @@ export default class CVAudioTask extends CVTask
//this.nodeProvider.activeNode = this.nodeProvider.scopedNodes[0];

super.activateTask();

this.synchLanguage();
}

deactivateTask()
Expand All @@ -103,13 +100,7 @@ export default class CVAudioTask extends CVTask

const clip = audioManager.getAudioClip(ins.activeId.value);
const languageManager = this.activeDocument.setup.language;

if(ins.language.changed) {
const newLanguage = ELanguageType[ELanguageType[ins.language.value]];

languageManager.addLanguage(newLanguage); // add in case this is a currently inactive language
languageManager.ins.language.setValue(newLanguage);
}
const activeLanguage = languageManager.codeString();

if (ins.create.changed) {
const newId = Document.generateId();
Expand Down Expand Up @@ -138,8 +129,8 @@ export default class CVAudioTask extends CVTask

if (clip && (ins.title.changed || ins.filepath.changed || ins.captionPath.changed)) {
clip.name = ins.title.value;
clip.uris[ELanguageType[ins.language.value]] = ins.filepath.value;
clip.captionUris[ELanguageType[ins.language.value]] = ins.captionPath.value;
clip.uris[activeLanguage] = ins.filepath.value;
clip.captionUris[activeLanguage] = ins.captionPath.value;
audioManager.updateAudioClip(clip.id);
}
if (ins.isNarration.changed) {
Expand Down Expand Up @@ -172,27 +163,17 @@ export default class CVAudioTask extends CVTask
const ins = this.ins;
const audioManager = this.audioManager;
const clip = audioManager.getAudioClip(ins.activeId.value);
const languageManager = this.activeDocument.setup.language;
const activeLanguage = languageManager.codeString();

ins.title.setValue(clip ? clip.name : "", true);
ins.filepath.setValue(clip ? clip.uris[ELanguageType[ins.language.value]] : "", true);
ins.captionPath.setValue(clip ? clip.captionUris[ELanguageType[ins.language.value]] : "", true);
ins.filepath.setValue(clip ? clip.uris[activeLanguage] : "", true);
ins.captionPath.setValue(clip ? clip.captionUris[activeLanguage] : "", true);
ins.isNarration.setValue(clip ? this.audioManager.narrationId === clip.id : false, true);
}

protected onDocumentLanguageChange()
{
this.synchLanguage();
this.onAudioChange();
}

// Make sure this task language matches document
protected synchLanguage() {
const {ins} = this;
const languageManager = this.activeDocument.setup.language;

if(ins.language.value !== languageManager.outs.language.value)
{
ins.language.setValue(languageManager.outs.language.value, true);
}
}
}
2 changes: 1 addition & 1 deletion source/client/components/CVDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ export default class CVDocument extends CRenderGraph

const newTitle = this.titles[ELanguageType[language.outs.language.value]];
this.ins.title.setValue(newTitle);
const newIntro = this.intros[ELanguageType[language.outs.language.value]];
const newIntro = this.intros[ELanguageType[language.outs.language.value]] || "";
this.ins.intro.setValue(newIntro);
}

Expand Down
Loading

0 comments on commit 44037f9

Please sign in to comment.