我正在使用音效管理器的bar-ui js。
<div id="sm2-99943" class="sm2-bar-ui content compact flat full-width playlist full-width-player ">
<div class="bd sm2-main-controls">
<div class="sm2-inline-element sm2-button-element">
<div class="sm2-button-bd" style="background: transparent url(http://support.simplepodcaster.com/wp-content/uploads/2018/04/podcast_channel_artwork-150x150.png) repeat scroll 0% 0% / cover ;">
<div id="spp-player-background"> </div>
<a href="#play" class="sm2-inline-button play-pause">Play / pause</a>
<div class="eq">
<span class="bar bar-1"></span>
<span class="bar bar-2"></span>
<span class="bar bar-3"></span>
<span class="bar bar-4"></span>
</div>
</div>
</div>
<div class="sm2-inline-element sm2-inline-status progressbar" style="padding-right:0px !important;">
<div class="sm2-playlist">
<div class="sm2-playlist-target" style="max-width: 100% !important;"></div>
</div>
<div class="sm2-progress">
<div class="sm2-progress-bd">
<div class="sm2-progress-track">
<div class="sm2-progress-bar1" style="display:none;"></div>
<div class="sm2-progress-bar"></div>
<div class="sm2-progress-ball">
<div class="icon-overlay"></div>
</div>
</div>
</div>
<div class="sm2-row">
<div class="sm2-inline-time1" style="display:none;">0:00</div>
<div class="sm2-inline-time">0:00</div>
<div class="sm2-inline-duration">0:00</div>
</div>
</div>
</div>
<div class="sm2-inline-element sm2-button-element sm2-menu">
<div class="sm2-button-bd">
<a href="#menu" class="sm2-inline-button menu">menu</a>
</div>
</div>
</div>
<div class="bd sm2-playlist-drawer sm2-element">
<div class="sm2-playlist-wrapper">
<ul class="sm2-playlist-bd">
<li><a href="https://traffic.libsyn.com/secure/hmourra/HaniPodcast1_-_Introduction.mp3?dest-id=201638">Episode 1 - Introduction</a></li>
<li><a href="https://traffic.libsyn.com/secure/hmourra/HaniPodcast2_-_Tools_To_Grow.mp3?dest-id=201638">Episode 2 - How To Start Podcasting</a></li>
<li><a href="https://traffic.libsyn.com/secure/hmourra/SRP-thankyou.mp3?dest-id=201638">Episode 5 - Thank you!</a></li>
<li><a href="https://traffic.libsyn.com/secure/hmourra/input.mp3?dest-id=201638">Episode 6</a></li>
<li><a href="https://traffic.libsyn.com/secure/hmourra/episode6.mp3?dest-id=201638">2nd Episode 7</a></li>
<li><a href="https://traffic.libsyn.com/secure/hmourra/Episode8.mp3?dest-id=201638"> Episode 10 - Blogging vs Podcasting</a></li>
<li><a href="https://traffic.libsyn.com/secure/hmourra/Episode9.mp3?dest-id=201638">Episode 11 - Video vs Audio</a></li>
<li><a href="https://traffic.libsyn.com/secure/hmourra/output.mp3?dest-id=201638">Episode 12 - Social Sharing Your Content</a></li>
<li><a href="https://traffic.libsyn.com/secure/hmourra/hani2.mp3?dest-id=201638">Episode 13 - Growing Your Audience</a></li>
<li><a href="https://traffic.libsyn.com/secure/hmourra/ep15.mp3?dest-id=201638">Episode 15 - Blogging for Leads</a></li>
<li><a href="https://traffic.libsyn.com/secure/hmourra/ep16.mp3?dest-id=201638">Episode 16 - How To Get More iTunes Reviews</a></li>
<li><a href="https://traffic.libsyn.com/secure/hmourra/ep17.mp3?dest-id=201638">Episode 17 - "Growing Your Email List on Autopilot"</a></li>
<li><a href="https://traffic.libsyn.com/secure/hmourra/ep18.mp3?dest-id=201638">JUP 014 | Alexander Dahms: Mehrwert für andere statt Gewinndenken</a></li>
<li><a href="https://traffic.libsyn.com/secure/hmourra/Iron_Horse.mp3?dest-id=201638">Episode 18</a></li>
<li><a href="https://traffic.libsyn.com/secure/hmourra/Smoking_Gun.mp3?dest-id=201638">Episode 19 - New & Noteworthy</a></li>
<li><a href="https://traffic.libsyn.com/secure/hmourra/Iron_Horse_copy.mp3?dest-id=201638">Episode 21 - Beliefs -> Decisions -> Outcomes</a></li>
<li><a href="https://traffic.libsyn.com/secure/hmourra/WisdomTrek-Podcast-Day-597mixdown.mp3?dest-id=201638">Episode 22 - Publishing to Facebook</a></li>
<li><a href="https://traffic.libsyn.com/secure/hmourra/ep22.mp3?dest-id=201638">Episode 24 - Repurposing Your Content</a></li>
<li><a href="https://traffic.libsyn.com/secure/hmourra/test.mp3?dest-id=201638">Episode 26 - \Backslash /Frontslash To Facebook</a></li>
<li><a href="https://traffic.libsyn.com/secure/hmourra/combined_This-is-the-title-with-an-emoji1523041021218.mp3?dest-id=201638">This is the title with an emoji</a></li>
</ul>
</div>
</div>
</div>我有很多球员,所以我需要什么。
我想使用jQuery从html类中选择声音id ..。
我有这个可能??
就像我在上面的代码中使用内容类一样,所以我可以应用一些自定义更改。
更新
看这里有很多玩家
http://www.schillmania.com/projects/soundmanager2/demo/bar-ui/下面是soundmanager2代码的示例
var mySoundObject = soundManager.createSound({
// optional id, for getSoundById() look-ups etc. If omitted, an id will be generated.
id: 'mySound',
url: '/audio/mysoundfile.mp3',
// optional sound parameters here, see Sound Properties for full list
volume: 50,
autoPlay: true,
whileloading: function() {
console.log(this.id + ' is loading');
}
});发布于 2018-04-17 19:06:21
如果希望通过DOM提供ID,我建议在whileLoading函数中设置一个数据属性,如下所示:
var mySoundObject = soundManager.createSound({
id: 'mySound',
url: '/audio/mysoundfile.mp3',
// optional sound parameters here, see Sound Properties for full list
volume: 50,
autoPlay: true,
whileloading: function() {
jQuery(_Element_Selector_You_Want_To_Bind_To_).data('sound-id', this.id)
}
});然后,您可以使用jQuery(_Element_Selector_You_Want_To_Bind_To_).data('sound-id')从元素中检索ID
(由于我通常不使用jQuery,强制香草溶液是document.querySelector(selector).setAttribute('data-sound-id', this.id) document.querySelector(selector).getAttribute('data-sound-id') )
发布于 2018-04-17 10:55:51
有一个特殊的属性dom存储播放机的所有DOM对象,例如,您可以根据示例中演示的条形ui库的代码通过表达式window.sm2BarPlayers[0].dom (反过来,它利用声音管理器库)。
据我所知,您正在寻找SMSound (通过window.soundManager.getSoundById('sound0')获得)和我提到的player对象之间的连接。这个连接是存在的,它保存在播放器的一个私有变量中(它是一个JS的闭包):
exports = {
on: null,
actions: actions,
dom: dom,
playlistController: playlistController
};
soundObject = makeSound(playlistController.getURL());稍后将返回exports变量,这就是指尖上的内容,而soundObject则关闭在内部。不过,正如代码所揭示的那样,似乎有一个技巧可以完成您的任务:您的声音和它的播放器都有相同的url,这就是如何找到连接的方法。换句话说,这是一种方法:
var url = window.soundManager.getSoundById('sound0').url; //get the url of a sound
var player = window.sm2BarPlayers.find(function(p) { return p.playlistController.getURL() == url });
// Here you can use p.dom property where its DOM elements are kept and pass them to jQuery to build other search queries you need最后,拥有player DOM对象之后,您可以通过标准的JS选择器或jQuery选择器来确定它是在内容区域还是在其他地方。如果您需要详细说明如何处理最后一项任务,请在评论中告诉我。
https://stackoverflow.com/questions/49774644
复制相似问题