带HTML5音频标签的自定义单键播放器 [英] Custom 1-button player with HTML5 audio tag

查看:150
本文介绍了带HTML5音频标签的自定义单键播放器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我最近一直在做的某些网页开发中使用< audio> 标记,我要做的一件事就是用它来构建一个单词列表并在列表中的每个单词旁边提供发音样本。设置它并不难,但是这种应用几乎不需要全套控件;只需一个播放按钮。

Working with the <audio> tag in some web development I've been doing lately, and one thing I'm trying to do is use it to build a word list and provide a pronunciation sample next to each word on the list. Setting this up isn't hard at all, however this sort of application hardly requires the full set of controls; just a play button.

< audio>的控件元素标签似乎没有完全记录;我能找到的就是总是把'放在'这里,除非你想建立自己的玩家。我不想构建我自己的播放器,但是,我只想要一个简单的单按钮播放界面,最好不要使用JavaScript或Flash。

The controls element of the <audio> tag doesn't seem to be that well documented at all, however; all I can find on it is "always put 'on' here, unless you want to build your own player". I don't want to build my own player, however, I just want a simple, 1-button play interface with nothing else, ideally without requiring JavaScript or Flash.

推荐答案

这很简单。您只需在单击某些内容时调用 audio DOM对象上的play方法。这些东西可能是图像,文字,链接或任何适合的东西。

It's fairly simple. You just need to call the play method on the audio DOM object when something is clicked. The something could be an image, text, link, or whatever suits.

这是一种可能的方式:

<a onclick="this.firstChild.play()"><audio src=".."></audio></a>

查看示例

这篇关于带HTML5音频标签的自定义单键播放器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆