seocahill / abairt

1 stars 0 forks source link

réitigh an taifead cnaipe ar chrome #9

Closed seocahill closed 3 years ago

seocahill commented 3 years ago
pry(#<ActiveStorage::Attached::One>):1> ff.blob
=> #<ActiveStorage::Blob:0x00007f8c91ee22d8
 id: 2,
 key: "430rne0ieywogi4qcx9nthmqwnce",
 filename: "audio.ogg",
 content_type: "audio/ogg",
 metadata: {"identified"=>true, "analyzed"=>true},
 service_name: "local",
 byte_size: 11813,
 checksum: "BjoFGr3RWH51VvNch4MRXw==",
 created_at: Sat, 20 Feb 2021 09:15:49.608244000 UTC +00:00>

[16] pry(#<ActiveStorage::Attached::One>):1> cd ..[17] pry(main)> media.blob
=> #<ActiveStorage::Blob:0x00007f8c8951c7b0
 id: 1,
 key: "ob7nvmyyf260kgh4ntyb3ux0pnpa",
 filename: "audio.ogg",
 content_type: "video/webm",
 metadata: {"identified"=>true, "analyzed"=>true},
 service_name: "local",
 byte_size: 16470,
 checksum: "KbBZb70xftwvupGJQCEZGg==",
 created_at: Sat, 20 Feb 2021 09:08:23.756118000 UTC +00:00>
[18] pry(main)> media.video?
=> true
seocahill commented 3 years ago

@dazpatreg féach ar no dhá blobanna os cionn ^.

An rud is tabhachtach ná an 'content_type'. Ar thaobh firefox de is é 'audio/ogg', i gchrome is é `"video/webm".

Mar gheall are sin tá an taistáil sin ag theipeadh i mo gcódsa (dictionary_entry.media.audio?)

<% if dictionary_entry.media.attached? && dictionary_entry.media.audio? %>
    <td><%= tag :audio, src: url_for(dictionary_entry.media), controls: true %></td>
  <% end %>

... mar is 'video' iad fileanna le content-type 'webmd', ní 'audio'

Muise, tá gach rud ag obair seachas (i.e. tá na taifeadaí sábháilte go léir) an html 'rendering'.

Ba chor don réitigh an-shimplí:

<% if dictionary_entry.media.attached? && (dictionary_entry.media.audio? ||  dictionary_entry.media.video?) %>
....etc

An brí ar an cód sin is ea "' 'spáin dom an file má tá video no audio type i gceist"