<audio> element cannot play mp3 from email attachment using objectURL(attachmentFile)
Categories
(Thunderbird :: Add-Ons: Extensions API, defect)
Tracking
(Not tracked)
People
(Reporter: buecher, Unassigned)
References
Details
Attachments
(2 files)
This is either a bug or a documentation deficiency.
- Playing audio from attachment file fails when using objectURL from file
- Playing audio from uploaded file (input type = "file") succeeds when using objectURL from file
- Using a third party mime parser parses to arrayBuffer, which succeeds playing when converted to blob/objectURL
- Final solution derived from 3): after trying multiple ways to convert the attachment or create new blobs from it, mp3 playing via objectURL
succeeds if a new blob is created from file.arrayBuffer
It is undesirable that files are treated differently in 1) and 2).
STR(1):
a) get an mp3 attachment:
let file = await browser.messages.getAttachmentFile(
this.msgid,
this.partName );
b) create objectURL from this file
let objectURL = URL.createObjectURL(file);
c) assign audio.src = objectURL
d) Result: fails: media conversion
STR(2)
a) upload file from <input type = "file">
b) perform b), c) from STR(1)
c) succeeds: audio can be played when creating objectURL from file
STR(3)
postal-mime can convert raw email and play via objectURL out of the box, it converts attachments to an arrayBuffer
so I tried
STR(4)
a) get attachment file
b) create new blob from file.arrayBuffer, set correct type
c) create objectURL from this blob
d) success. audio element plays
Final comment: it is undesirable that some files (input type = file) can be played from objectURL, but other files (from attachment) can not.
Comment 1•2 years ago
•
|
||
I created a simple reproducer add-on (conceptually based on work from Klaus). I directly create the ObjectUrl from the file and it seems to work as expected.
Below you will find the xpi and the mp3 I used for the test. Klaus, can you check if this works for you?
Comment 2•2 years ago
|
||
The MP3 which I attached to an email for this test.
Comment 3•2 years ago
|
||
A simple reproducer add-on. Open a message with an audio file (for example the one attached to this bug) and click on the message display action. A new tab opens , which has an audio playback element. The element should start to play the sound.
Comment 4•2 years ago
|
||
What I have found out so far:
- it is not a size issue, I have a file here which is 5MB (larger than Track1 provided by Klaus) and plays
- the Track1 example file provided by Klaus fails to open in audacity, but I have found another file which does open in audacity and still does not play, so that is not it
- if I repack the file on the API side, it does not work
- if I create a Blob instead of a File on the API side, it does not work
What does work:
- if I send the buffer and create the File on the WebExt side, it works
So there is a difference between the File being created on the WebExt side and on the API side, both being created from the same buffer.
Will now try to look into the actual error thrown by the decoder.
Comment 5•2 years ago
|
||
I was not able to see, what goes wrong in the decoder. But decoding is not working if the file has a cover and was transferred from an API implementation file.
I created a Firefox bug, including a reproducer add-on for Firefox Nightly:
https://bugzilla.mozilla.org/show_bug.cgi?id=1875621
Comment 6•1 year ago
|
||
The Firefox fix has been uplifted to ERS115 and will reach Thunderbird ESR soon. It is already confirmed fixed in Thunderbird Beta.
Description
•