enable audio for videos #2499

This commit is contained in:
r888888888
2015-08-26 13:54:14 -07:00
parent 36da788503
commit ef59ae8886
4 changed files with 19 additions and 4 deletions

View File

@@ -77,3 +77,13 @@ $preview_flagged_color: #F00;
text-align: center; text-align: center;
} }
@mixin audio-icon {
content: "";
position: absolute;
width: 20px;
height: 20px;
color: white;
background-color: rgba(0,0,0,0.5);
margin: 2px;
text-align: center;
}

View File

@@ -26,9 +26,13 @@ article.post-preview {
margin: auto; margin: auto;
} }
&[data-tags~=animated]:before, &[data-file-ext=swf]:before, &[data-file-ext=webm]:before, &[data-file-ext=zip]:before { &[data-tags~=animated]:before, &[data-file-ext=swf]:before, &[data-file-ext=webm]:before, &[data-file-ext=mp4]:before, &[data-file-ext=zip]:before {
@include animated-icon; @include animated-icon;
} }
&[data-has-audio=true]:before {
@include audio-icon;
}
} }
#iqdb-similar { #iqdb-similar {

View File

@@ -85,9 +85,9 @@ class Upload < ActiveRecord::Base
end end
end end
def validate_no_audio def tag_audio
if is_video? && video.audio_channels.present? if is_video? && video.audio_channels.present?
raise "video must not have audio channels" self.tag_string = "#{tag_string} audio"
end end
end end
@@ -112,7 +112,7 @@ class Upload < ActiveRecord::Base
calculate_hash(file_path) calculate_hash(file_path)
validate_md5_uniqueness validate_md5_uniqueness
validate_md5_confirmation validate_md5_confirmation
validate_no_audio tag_audio
validate_video_duration validate_video_duration
calculate_file_size(file_path) calculate_file_size(file_path)
if has_dimensions? if has_dimensions?

View File

@@ -68,6 +68,7 @@ class PostPresenter < Presenter
def self.data_attributes(post) def self.data_attributes(post)
%{ %{
data-id="#{post.id}" data-id="#{post.id}"
data-has-audio="#{post.has_tag?('audio')}"
data-tags="#{h(post.tag_string)}" data-tags="#{h(post.tag_string)}"
data-pools="#{post.pool_string}" data-pools="#{post.pool_string}"
data-uploader="#{h(post.uploader_name)}" data-uploader="#{h(post.uploader_name)}"