尝试使用https://github.com/joshwcomeau/redux-sounds播放声音文件,但我无法使其正常工作。以下是我用来设置它的相关代码。我不知道webpack是不是正确加载它们还是其他东西。我怎么知道它们是否正确加载?有关如何使其工作的任何想法?没有控制台错误,除了Chrome说它无法解码音频,但这显然是错误,并且当我在Firefox中尝试它时不会出现。
configureStore.js
//...
import soundsMiddleware from 'redux-sounds';
const soundsData = {
barks: {
urls: ['data/barkSprite.wav', 'data/barkSprite.mp3'],
sprite: {
shortBark: [0, 500],
longBark: [600, 1250]
}
}
};
const loadedSoundsMiddleware = soundsMiddleware(soundsData);
//...
export default function configureStore(initialState) {
const store = createStore(
rootReducer,
initialState,
compose(
applyMiddleware(thunk, router, logger, loadedSoundsMiddleware),
DevTools.instrument(),
persistState(
window.location.href.match(
/[?&]debug_session=([^&]+)\b/
)
)
)
);
//...
actions.js
export const SHORT_BARK = 'SHORT_BARK';
export function shortBark() {
return {
type: SHORT_BARK,
meta: { sound: 'barks.shortBark' }
};
}
webpack.config.js
resolve: {
extensions: ['', '.js', '.jsx', '.scss', '.mp3'],
},
module: {
loaders: [
{
test: /\.mp3$/,
loader: 'file-loader'
},
]
}
答案 0 :(得分:0)
原来我忘了显示要表达的文件。
app.use('/data', express.static(path.join(__dirname, '/src/data')));