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

Add audio preview of uploaded files #768

Merged
merged 1 commit into from
Nov 4, 2016
Merged
Show file tree
Hide file tree
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
10 changes: 8 additions & 2 deletions app/assets/javascripts/resources/upload_localized_resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ onResourcesWorkflow(function(){
this.filename = ko.observable(hash.filename);
this.uploadedfile = null;

this.playUrl = ko.computed(function(){
if(this.isSaved()) {
return "/projects/" + project_id + "/resources/" + this.parent().id() + "/localized_resources/" + this.id() + "/play_file";
} else {
return null
}
}, this);

this.url = ko.computed(function(){
if(this.isSaved()) {
Expand Down Expand Up @@ -64,7 +71,7 @@ onResourcesWorkflow(function(){
return false;
}

return downloadURL("/projects/" + project_id + "/resources/" + this.parent().id() + "/localized_resources/" + this.id() + "/play_file");
return downloadURL(this.playUrl());
}

UploadLocalizedResource.prototype.preserveCurrentValues= function() {
Expand All @@ -90,4 +97,3 @@ onResourcesWorkflow(function(){
}
}
})

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%script{type: "text/html", id: "upload_localized_resource_template"}
.file-name
/ ko if: uploadStatus() == 'standBy' && !hasAudio()
%span.alert-orange-b Select a file to upload
%span.alert-orange-b Select a file
/ /ko
/ ko if: hasAudio()
%span.clickable.audio-name{'data-bind' => 'text: "File: " + filename(), click: download'}
Expand All @@ -23,6 +23,12 @@
%input{:type => 'file', 'data-bind' => 'fileupload: url, fileuploadAdd: add'}
Replace
/ /ko
/ ko if: hasAudio() && (uploadStatus() == 'ok' || uploadStatus() == 'standBy')
%br
%audio{'controls' => true, "style" => "width: 250px"}
%source{'data-bind' => 'attr: { src: playUrl }'}
%br
/ /ko
%br{clear: 'all'}
.w22
%textarea{:rows => 6, :placeholder => 'Write here a description of the recording, either as a reminder for you or as a reference for the person that will record the message.', 'data-bind' => 'value: description'}
6 changes: 6 additions & 0 deletions app/views/resources/_upload_localized_resource_template.haml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
%input{:type => 'file', 'data-bind' => 'fileupload: url, fileuploadAdd: add, fileuploadprogressall: showProgress'}
Replace
/ /ko
/ ko if: hasAudio() && (uploadStatus() == 'ok' || uploadStatus() == 'standBy')
%br
%audio{'controls' => true, "style" => "width: 450px", "preload" => "none"}
Copy link
Member

Choose a reason for hiding this comment

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

Do we care about compatibility with old browsers? What does this do if the browser doesn't support the <audio> element or the audio format?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IE9+ supports audio tag. And the call flow designer currently does not work in IE8:

screen shot 2016-11-04 at 11 34 53 am

%source{'data-bind' => 'attr: { src: playUrl }'}
%br
/ /ko
.w100
%textarea{:rows => 6, :placeholder => 'Write here a description of the recording, either as a reminder for you or as a reference for the person that will record the message.', 'data-bind' => 'value: description, visible: $parent.editing()'}
%span.i18b-file{ko(visible: '! $parent.editing()')}
Expand Down