`
天梯梦
  • 浏览: 13764540 次
  • 性别: Icon_minigender_2
  • 来自: 洛杉矶
社区版块
存档分类
最新评论

Wordpress 音频播放器 Wordpress audio player with jQuery

阅读更多

Wordpress audio player with jQuery

How to use Wordpress audio player (standalone version) with jQuery and jQuery SWFObject (progressive enhancement).

<!-- SECTION "Wordpress audio player with jQuery" [1-272] -->

Example 1: basic

View demo

HTML

<a class="audio" href="audio/reason.mp3">
	Audio: An Electronic Reason
</a>
 

Javascript

<!-- SECTION "Example 1: basic" [273-705] -->

$('.audio').each(function(){
	audio_file = $(this).attr('href'); 
 
	$(this).flash(
		{
			swf: 'flash/audioplayer.swf',
			flashvars:
			{
				soundFile: audio_file
			}
		}
	);
});
 

Example 2: several synchronized players

View demo

Javascript

<!-- SECTION "Example 2: several synchronized players" [706-1488] -->

// close other audio players
// called by audio player when click on play button 
function ap_stopAll(player_id)
{
	$('.audio').each(function(){
		if($(this).attr('href') != player_id)
		{
			$(this).find('object')[0].SetVariable("closePlayer", 1);
		}
		else 
		{
			$(this).find('object')[0].SetVariable("closePlayer", 0);
		}
	});
} 
 
$(document).ready(function() {
	$('.audio').each(function(){
 
		audio_file = $(this).attr('href'); 
 
		$(this).flash(
			{
				swf: 'flash/audioplayer.swf',
				flashvars:
				{
				    playerID: "'" + audio_file + "'",
				    soundFile: audio_file
				}
			}
		);
	});
});
 

Notes

How it works:

  • players are given an id upon initialization
  • when click on play button, player calls ap_stopAll() with its id as parameter
  • ap_stopAll(): stops all players but the one with this id
  • the id here is the audio file path, but anything else is possible.

<!-- SECTION "Notes" [1489-1786] -->

Example 3: real world

View demo

HTML  

<p>
	<a class="audio" href="audio/reason.mp3" id="reason">
		Audio: An Electronic Reason
	</a>                                                     
</p>
 
<p>
	<a class="audio" href="audio/sunday.mp3" id="sunday">
		Audio: By Sunday Afternoon
	</a>
</p>
 

Javascript

 

// close other audio players
// called by audio player when click on play button 
function ap_stopAll(player_id)
{
	$('.audio_flash').each(function(){
		if($(this).attr('id') != player_id)
		{
			$(this).find('object')[0].SetVariable("closePlayer", 1);
		}
		else 
		{
			$(this).find('object')[0].SetVariable("closePlayer", 0);
		}
	});
}
 
$(document).ready(function() {
 
	$('.audio').each(function() {
		audio_file = $(this).attr('href'); 
		audio_title = $(this).text();
		audio_id = $(this).attr('id');
 
		div = $('<div class="audio_flash" id="' + audio_id + '"></div>');		
		$(this).after(div);
		$(this).after(audio_title);
		$(this).remove();
		div.flash(
			{
				swf: 'flash/audioplayer.swf',
				flashvars:
				{
					soundFile: audio_file,
					playerID: "'" + audio_id + "'",
					quality: 'high',
					lefticon: '0xFFFFFF',
					righticon: '0xFFFFFF',
					leftbg: '0x357CCE',
					rightbg: '0x32BD63',
					rightbghover: '0x2C9D54',
					wmode: 'transparent'
				},
				height: 50
			}
		);
	});
 
});

<!-- SECTION "Example 3: real world" [1787-3238] -->

Notes

  • meaningful HTML: visitors without Javascript get a download link, otherwise it's replaced by plain text and the player

  • the appearance can be customized with many options (bottom of the page).
  • the default white space before and after the player is reduced by the “height” Flash parameter.
  • use of a custom id (set on the HTML link)

<!-- SECTION "Notes" [3239-3682] -->

Download

<!-- SECTION "Download" [3683-] -->

分享到:
评论

相关推荐

    WordPress漂亮的音乐播放器插件Aplayer

    在WordPress的众多插件中,Aplayer是一款设计精美的音乐播放器插件,深受许多网站管理员的喜爱。它为用户提供了丰富的自定义选项和流畅的听觉体验,使得音乐与网站内容完美融合。本文将深入探讨Aplayer插件的特性、...

    WordPress播放器插件Flash-Mp3-Player

    在上图中,点击Add New添加新的歌曲,title输入标题,URL中输入地址,这里建议在WordPress根目录中建一个audio的目录,把你希望播放的歌曲放在里面,然后,在URL地址中输入这些歌曲的URL地址(这些歌曲用英文来命名,...

    HTML5音频播放器(AmazingAudioPlayerEnterprise)V3.2汉化特别安装版

    Amazing Audio Player Enterprise是一款能够帮助用户快速的制作出一个HTML5音乐播放器的小工具,做好的播放器可以作为插件整合到Wordpress博客系统中去! 软件介绍:用户只需将需要播放的音乐添加到软件中然后选择...

    WordPress Audio Player最新汉化插件 for Wordpress.rar

    WordPress Audio Player 汉化版使用方法:解压文件,把解压出来的audio-player文件夹上传到WordPress博客的wp-content/plugins 目录下,登陆博客后台 到插件中启用audio-player插件即可。然后在设置中根据需要对插件...

    【WordPress插件】2022年最新版完整功能demo+插件v2.9.zip

    Disk Audio Player For WordPress WordPress的磁盘音频播放器" ---------- 泰森云每天更新发布最新WordPress主题、HTML主题、WordPress插件、shopify主题、opencart主题、PHP项目源码、安卓项目源码、ios项目源码,...

    WordPress ++++html5音频播放器

    **WordPress ++++html5音频播放器** 在WordPress中集成HTML5音频播放器是现代网站增强用户体验的一个重要方式,尤其对于音乐分享或者在线电台站点来说,一个功能强大的HTML5音频播放器能够提供无缝的音乐播放体验。...

    html5-WP-audio-player:令人敬畏的WordPress音频播放器的版本,用于支持HTML5的浏览器标签,并针对不支持该功能的浏览器退回到原始Flash播放器

    标签的浏览器,而对不支持HTML5的浏览器的原始WP Audio Player有所保留。 最初,这将是,但最终我破坏了该项目的默认CSS,以至于我决定从头开始从事该项目。 结果是一个精简,平均的样式表,具有大量的定制潜力。去...

    【WordPress插件】2022年最新版完整功能demo+插件v34.2.zip

    S3MediaVault - Amazon S3 Video & Audio Player and File Security for WordPress S3MediaVault - 亚马逊S3视频和音频播放器和WordPress的文件安全性" ---------- 泰森云每天更新发布最新WordPress主题、HTML主题...

    最小的音频播放器(1bit)

    1比特音频播放器(1 BIT AUDIO PLAYER v1.4)的设计理念可能是为了满足对轻量级音频播放需求的用户,尤其在资源有限或者对播放器性能有特定要求的环境下,比如嵌入式系统或者老旧计算机。 1比特音频,也称为1位音频...

    audio-player.2.0.4.6

    《WordPress音频播放器插件audio-player 2.0.4.6详解》 在WordPress的广阔世界里,各种插件丰富了网站的功能,其中audio-player 2.0.4.6是一个专注于音频播放的插件,它为用户提供了便捷、高效的音频播放解决方案。...

    WordPress插件HTML5悬浮播放器 v1.0

    WordPress插件HTML5悬浮播放器是将emlog的播放器移植到了WordPress,完美本地化,完全免费,自带歌词,歌曲解析系统。安装方法:后台上传插件即可安装,安装完成后设置启用在菜单左侧边栏目点击HTML5播放器即可设置

    【WordPress插件】2022年最新版完整功能demo+插件v1.2.zip

    Lono - Responsive HTML5 Audio Player With Playlist WordPress Plugin LONO - 响应HTML5带播放列表WordPress插件的音频播放器" ---------- 泰森云每天更新发布最新WordPress主题、HTML主题、WordPress插件、...

    Using jQuery Tools in WordPress

    ### 使用jQuery Tools在WordPress中的应用 #### 知识点一:jQuery Tools与WordPress结合的意义 在本书中,我们已经探讨了使用jQuery Tools所能实现的各种可能性。然而,这些探索大多是在独立环境中进行的。本章节...

    jw-player-plugin-for-wordpress.2.1.1

    在WordPress的多媒体内容呈现中,JW Player是一款备受青睐的视频播放器插件。标题"jw-player-plugin-for-wordpress.2.1.1"揭示了我们关注的是这款插件的一个特定版本——2.1.1。该版本针对WordPress平台进行了优化,...

    Vanilla-JS-Audio-Player:带有ACF中继器的Vanilla JS音频播放器

    【标题】"Vanilla-JS-Audio-Player:带有ACF中继器的Vanilla JS音频播放器"是一个使用纯JavaScript编写的音频播放器项目,它利用了Advanced Custom Fields(ACF)插件的中继器功能。这个项目旨在提供一个轻量级且...

    【WordPress插件】2022年最新版完整功能demo+插件v3.1.7.zip

    WavePlayer - WordPress Audio Player with Waveform and Playlist Waveplayer - wordpress音频播放器waveform和播放列表" ---------- 泰森云每天更新发布最新WordPress主题、HTML主题、WordPress插件、shopify主题...

    【WordPress插件】2022年最新版完整功能demo+插件v6.65.zip

    ZoomSounds - WordPress Wave Audio Player with Playlist zoomsounds - wordpress波浪音频播放器与播放列表" ---------- 泰森云每天更新发布最新WordPress主题、HTML主题、WordPress插件、shopify主题、opencart...

    网页上播放flv, mp3的播放器,可插入博客wordpress

    "网页上播放flv, mp3的播放器,可插入博客wordpress"这个主题涉及到的是一个专为网页设计的媒体播放器,它支持FLV和MP3两种常见的音频和视频格式,能够方便地集成到WordPress博客平台中,提升用户体验,同时也提供了...

    wordpress 3.0 jquery

    ### WordPress 3.0与jQuery结合的技术要点 #### 核心知识点概述 在《WordPress 3.0 jQuery》这本书中,作者Tessa Blakeley Silver详细介绍了如何利用jQuery增强WordPress网站的功能性和吸引力。这本书不仅适合...

Global site tag (gtag.js) - Google Analytics