feat(媒体支持): 完善媒体播放与资源释放
build.yaml / build (push) Successful in 40s

This commit is contained in:
xiaoqidun committed 2026-09-30 21:15:14 +08:00
1 parent 91aa711dfc
commit c5867b0948
20 files changed
+541 -54

No files matched your search

+29 -6
View File
@@ -120,11 +120,25 @@ func (p *pdfImporter) annotations(ctx context.Context, page *pdfgo.Page, strict
if err != nil {
return err
}
data, err := pdfSoundWAV(sound)
var data []byte
format := "WAV"
if sound.File != nil {
var available bool
data, available, err = p.mediaData(ctx, *sound.File)
if err == nil && !available {
if err := p.appearanceAnnotation(ctx, page, annotation); err != nil {
return err
}
continue
}
format = pdfMediaFormat(*sound.File)
} else {
data, err = pdfSoundWAV(sound)
}
if err != nil {
return err
}
id, err := p.editor.AddMedia("Audio", "WAV", data)
id, err := p.editor.AddMedia("Audio", format, data)
if err != nil {
return err
}
@@ -139,18 +153,27 @@ func (p *pdfImporter) annotations(ctx context.Context, page *pdfgo.Page, strict
}
continue
}
if annotation.Subtype == "3D" || annotation.Subtype == "RichMedia" {
if err := p.interactiveAnnotation(ctx, page, annotation, strict); err != nil {
return err
}
continue
}
if annotation.Subtype == "FileAttachment" {
file, err := p.reader.ReadFileSpecification(dict["FS"])
if err != nil {
return err
}
if file.Embedded == nil {
return &pdfgo.UnsupportedError{Feature: "external file attachment"}
}
data, err := file.Embedded.Decode()
data, available, err := p.mediaData(ctx, file)
if err != nil {
return err
}
if !available {
if err := p.appearanceAnnotation(ctx, page, annotation); err != nil {
return err
}
continue
}
id, err := p.editor.AddAttachment(file.Name, data)
if err != nil {
return err