-
Notifications
You must be signed in to change notification settings - Fork 167
Fix 87 initialising transcript media v2 #114
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
Conversation
in ifPresentRetrieveTranscriptFromLocalStorage = () => {
- if (this.refs.timedTextEditor!== undefined) {
- if (this.refs.timedTextEditor.isPresentInLocalStorage(this.props.mediaUrl)) {
- console.log('was already present in local storage');
- this.refs.timedTextEditor.loadLocalSavedData(this.props.mediaUrl);
+ if (this.timedTextEditorRef.current!== undefined) {
+ if (this.timedTextEditorRef.current.isPresentInLocalStorage(this.props.mediaUrl)) {
+ console.info('was already present in local storage');
+ this.timedTextEditorRef.current.loadLocalSavedData(this.props.mediaUrl);
} else {
console.info('not present in local storage');
}
}
} in red how it was (when it was working), in green how it is current PR (not working) seems like it can be simplified as ifPresentRetrieveTranscriptFromLocalStorage = () => {
if (this.timedTextEditorRef!== undefined) {
if (this.timedTextEditorRef.isPresentInLocalStorage(this.props.mediaUrl)) {
console.info('was already present in local storage');
this.timedTextEditorRef.loadLocalSavedData(this.props.mediaUrl);
} else {
console.info('not present in local storage');
}
}
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the console.logs and it's all good! 👍
Not ready for mergeJust done further testing, doesn't work in conjunction with local storage. See QA docs |
current issue, when initialising component in this branch:
crash error
if (this.timedTextEditorRef.current.isPresentInLocalStorage(this.props.mediaUrl)) { |
when component not initialised with media and transcript at same time
can add from url or from local media and it would restore session. Note that even if we know it's the same file, those are teo different sessions, as local media uses the file name, and url uses the full url to more uniquely identify transcriptions
Ready for review/MergeDigged out old PRs and Issues addressing this problem and fixed it.
When adding from local media, See demo app in // https://stackoverflow.com/questions/8885701/play-local-hard-drive-video-file-with-html5-video-tag
handleChangeLoadMedia(files) {
console.log(files);
const file = files[0];
const type = file.type;
// check if is playable
const videoNode = document.createElement('video');
const canPlay = videoNode.canPlayType(type);
if (canPlay) {
const fileURL = URL.createObjectURL(file);
// videoNode.src = fileURL
this.setState({
// transcriptData: kaldiTedTalkTranscript,
mediaUrl: fileURL,
fileName: file.name
});
}
else {
alert('select a valid audio or video file');
}
} When testing Recognising whether is the same file, across url input string QA doc - It might also be good to clean up this notes and add them the docs or make an ADR. |
TL;DR: to recap at high level When initialising the component there might be a race condition between media url + transcript Json content if not provided at same time This can cause problem when retrieving from local storage complicating things even further, if the media url comes from local media (and therefore as blob url ) then then url string is not a unique identifier that can be used to save and retrieve from local storage. as a workaround added an optional file name to use local storage with local media |
Is your Pull Request request related to another issue in this repository ?
Recently noticed in PR #111 but also present in current master and flagged in this issue #113
Originally logged as this issue #87 and addressed as this PR #88
Describe what the PR does
When initialising the TranscriptEditor component you might have
And it also needs to work, when saving to local storage and retrieving data from it.
In PR #88 fix all these scenarios but in current master
3
is not working.This PR tries to figure out the differences between current master and previously fixed PR #88
State whether the PR is ready for review or whether it needs extra work
Not ready for merge, just using the diff to see what's the difference with current master.
Additional context
The idea is to rebase, and re-visit once these PRs have been added to master.