【发布时间】:2021-01-31 00:01:59
【问题描述】:
这款在 Windows 10 上运行的 Meteor 应用程序允许用户向下钻取 3 级目录树,以最终选择要播放或下载的音频文件。
最初我将目录放在meteor 'public' 文件夹下,但这使得应用程序在开发过程中的重启速度非常慢,因为公共文件夹大小变成了20GB(近400个音频文件),这个问题通过删除音频文件得到解决从公共文件夹到开发机器上的外部目录,并放置一个音频文件的绝对链接作为页面上source标签src属性的值(只是为了尝试)但它没有播放。
我尝试用“/”和“\”替换文件名,但无济于事。
知道如何在外部存储音频文件并命令客户端页面现在在 dev 上播放文件。机器和后来的生产机器,即使我将文件在线存储在不同的机器上?
谢谢
// and in the template event
let play = playButton(link)
let download = downloadLink(link)
let parent = document.createElement('div')
parent.setAttribute('id','parent')
parent.appendChild(play)
parent.appendChild(download)
$(event.target).append(parent)
//and in the playButton(link)
function playButton(link){
let play = document.createElement('div')
play.setAttribute('id', 'left')
let playButton = document.createElement('audio')
playButton.setAttribute('controls','')
playButton.setAttribute('preload', 'metadata')
playButton.setAttribute('class','audioButton')
let butSource = document.createElement('source')
butSource.setAttribute('src', link)
butSource.setAttribute('type','audio/mpeg')
let textnode = document.createTextNode('Your browser does not support the mp3 format.')
playButton.append(butSource)
playButton.appendChild(textnode)
play.append(playButton)
return play
}
<template name="tree">
<ol>
{{#each item in result}}
<li class="pointer" data-type={{item.type}} data-order={{item.order}}>{{item.title}}</li>
{{/each}}
</ol>
</template>
【问题讨论】:
-
这听起来像是Meteor Files 包的用例。那会是一个解决方案吗?您可以将其与 S3 或 Mongo GridFS 等自托管解决方案结合使用
-
为什么文件在meteor public 中可以播放,但在meteor 目录结构之外却没有?
-
因为 public 下的文件将成为 Meteor 生成的 HTML/js 包的一部分,而外部文件则不会。而且您不想要 GB 大小的捆绑包,因此您使用 Meteor 文件并在部署应用程序后将它们上传到数据库
标签: javascript audio meteor