音頻自定義樣式

<div?class="audio-play-box">

??????<div?class="audio-play-box-main?clearfix">

????????<span?class="s-btn-close"?>關(guān)閉</span>

????????<div?class="s-area-handle?fl">

??????????<span?class="prevBtn"?></span>

??????????<span?class="playBtn"?@click="playAudio"?v-if="!isPlaying"></span>

??????????<span?class="stopBtn"?@click="stop"?v-if="isPlaying"></span>

??????????<span?class="nextBtn"?></span>

????????</div>

????????<div?class="audio_box?clearfix?fl">

??????????<audio

????????????ref="audio"

????????????:src="audioPathS.path"

????????????@timeupdate="updateTime"

????????????@canplay="getDuration"

????????????controls

????????????style="display:none;"

??????????></audio>

??????????<div?class="s-box-slider?fl">

????????????<el-slider

??????????????id="el-slider"

??????????????:show-tooltip="false"

??????????????v-model="playProgress"

??????????????@change="progressChange"

????????????>

????????????</el-slider>

??????????</div>

??????????<div?class="s-box-times?fl">

????????????<span?class="s-now"?id="audio-time-now">{{currentTime}}</span>

????????????<span>/</span>

????????????<span?class="s-all"?id="audio-time-end">{{totalTime}}</span>

??????????</div>

????????</div>

????????<div?class="playbackRate?fr"?>

??????????<span>3x</span>

????????</div>

??????</div>

????</div>

//?音頻參數(shù)

??????isPlaying:false,//播放狀態(tài)

??????totalLength:?"",//音頻總長度

??????currentLength:?"",//當(dāng)前播放時(shí)間

??????playProgress:?0,//滑塊位置


computed:{

????currentTime?()?{

??????let?time?=?'00:00'

??????if?(this.currentLength)?{

????????time?=?this.transTime(this.currentLength)

??????}

??????return?time

????},

????totalTime?()?{

??????let?time?=?'00:00'

??????if?(this.totalLength)?{

????????time?=?this.transTime(this.totalLength)

??????}

??????return?time

????},

??},

?//?點(diǎn)擊播放按鈕

????playAudio()?{

??????this.audioPathS?=?this.detail.GROUP_ITEMS[0];

??????let?s?=?this.$refs.audio.duration;?//獲取視頻的總時(shí)長

??????this.totalLength?=?s

??????this.$nextTick(()=>{

????????this.isPlaying?=?true;

????????this.$refs.audio.play();

??????})

????},

????//?暫停

????stop()?{

??????this.isPlaying?=?false;

??????this.$refs.audio.pause();

????},

????//?拖動進(jìn)度條事件

????progressChange(value)?{

??????let?current?=?(value?/?100)?*?this.totalLength;

??????this.$refs.audio.currentTime?=?current;

????},

????//?獲取音頻時(shí)長

????getDuration?()?{

??????this.totalLength?=?this.$refs.audio.duration

????},

????//?獲取當(dāng)前播放進(jìn)度

????updateTime(e)?{

???????this.currentLength?=?e.target.currentTime?//?獲取audio當(dāng)前播放時(shí)間

??????if?(this.totalLength)?{

????????this.playProgress?=?(this.currentLength?/?this.totalLength)?*?100

??????}

??????if?(this.currentLength?===?this.totalLength)?{

????????this.isPlaying?=?false

??????}

????},

????//?將時(shí)間轉(zhuǎn)化成?mm:ss?格式

????transTime?(time)?{

??????var?duration?=?parseInt(time)

??????var?minute?=?parseInt(duration?/?60)

??????var?sec?=?duration?%?60?+?''

??????var?isM0?=?':'

??????if?(minute?===?0)?{

????????minute?=?'00'

??????}?else?if?(minute?<?10)?{

????????minute?=?'0'?+?minute

??????}

??????if?(sec.length?===?1)?{

????????sec?=?'0'?+?sec

??????}

??????return?minute?+?isM0?+?sec

????}

<style?lang="scss"?scoped>

.audio-play-box?{

??position:?fixed;

??bottom:?0px;

??left:?0;

??width:?100%;

??min-width:?1200px;

??height:?56px;

??background:?rgba(0,?0,?0,?0.8);

??z-index:?9999;

??padding:?0?40px;

??/*?line-height:?56px;?*/

}

.audio-play-box?.audio-play-box-main?{

??width:?1200px;

??margin:?0?auto;

??position:?relative;

}

.audio-play-box?.audio-play-box-main?.s-btn-close?{

??position:?absolute;

??right:?0;

??top:?-26px;

??color:?#fff;

??width:?74px;

??text-align:?center;

??cursor:?pointer;

}

.audio-play-box?.audio-play-box-main?.s-btn-close:after?{

??content:?"";

??position:?absolute;

??top:?0;

??left:?0;

??border-bottom:?26px?solid?rgba(0,?0,?0,?0.8);

??border-left:?10px?solid?transparent;

??border-right:?10px?solid?transparent;

??width:?54px;

??z-index:?-1;

}

.audio-play-box?.s-area-handle?{

??width:?116px;

??float:?left;

??font-size:?0;

??line-height:?56px;

}

.audio-play-box?.s-area-handle?span?{

??display:?inline-block;

??/*?margin:?0?5px;?*/

??margin-right:?14px;

??vertical-align:?middle;

??cursor:?pointer;

}

.audio-play-box?.s-area-handle?span.prevBtn?{

??background:?url("../../../../static/images/player_button_previous_track@2x.png")

????no-repeat?left?center;

??background-size:?24px;

??padding-left:?24px;

??width:?24px;

??height:?24px;

}

.audio-play-box?.s-area-handle?span.playBtn?{

??background:?url("../../../../static/images/player_button_play@2x.png")

????no-repeat?left?center;

??background-size:?40px;

??padding-left:?40px;

??width:?40px;

??height:?40px;

}

.audio-play-box?.s-area-handle?span.stopBtn?{

??background:?url("../../../../static/images/playBtn.png")?no-repeat?left?center;

??background-size:?40px;

}

.audio-play-box?.s-area-handle?span.nextBtn?{

??background:?url("../../../../static/images/player_button_next_track@2x.png")

????no-repeat?left?center;

??background-size:?24px;

??padding-left:?24px;

??width:?24px;

??height:?24px;

??margin-right:?0;

}

.audio-play-box?.audio_box?{

??float:?left;

??/*?height:?56px;?*/

??/*?line-height:?56px;?*/

??/*?width:?calc(?100%?-?80px?-?130px?-?100px);?*/

??/*?width:?1050px;?*/

??/*?overflow:?hidden;?*/

??padding:?18px?0?0?40px;

}

.audio-play-box?.audio_box?.s-box-slider?{

??width:?800px;

}

.audio-play-box?.audio_box?.s-box-slider?.el-slider__runway?{

??background-color:?#474747;

??height:?10px;

??border-radius:?5px;

??margin:?13px?0;

}

.audio-play-box?.audio_box?.s-box-slider?.el-slider__bar?{

??height:?10px;

??background-color:?#4a69bd;

??border-top-left-radius:?5px;

??border-bottom-left-radius:?5px;

}

.audio-play-box?.audio_box?.s-box-slider?.el-slider__button-wrapper?{

??top:?-13px;

}

.audio-play-box?.audio_box?.s-box-slider?.el-slider__button?{

??border:?3px?solid?#fff;

??background-color:?#4a69bd;

}

.audio-play-box?.audio_box?.s-box-times?{

??margin:?6px?0?0?15px;

??color:?#fff;

}

.audio-play-box?.playbackRate?{

??line-height:?56px;

}

.playbackRate?span?{

??display:?inline-block;

??vertical-align:?middle;

??width:?34px;

??border-radius:?100%;

??border:?2px?solid?#fff;

??height:?34px;

??text-align:?center;

??line-height:?31px;

??color:?#fff;

??cursor:?pointer;

}

</style>

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末坚踩,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子澎埠,更是在濱河造成了極大的恐慌措近,老刑警劉巖溶弟,帶你破解...
    沈念sama閱讀 212,383評論 6 493
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異瞭郑,居然都是意外死亡辜御,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,522評論 3 385
  • 文/潘曉璐 我一進(jìn)店門屈张,熙熙樓的掌柜王于貴愁眉苦臉地迎上來擒权,“玉大人袱巨,你說我怎么就攤上這事√汲” “怎么了愉老?”我有些...
    開封第一講書人閱讀 157,852評論 0 348
  • 文/不壞的土叔 我叫張陵,是天一觀的道長纳鼎。 經(jīng)常有香客問我俺夕,道長,這世上最難降的妖魔是什么贱鄙? 我笑而不...
    開封第一講書人閱讀 56,621評論 1 284
  • 正文 為了忘掉前任劝贸,我火速辦了婚禮,結(jié)果婚禮上逗宁,老公的妹妹穿的比我還像新娘映九。我一直安慰自己,他們只是感情好瞎颗,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,741評論 6 386
  • 文/花漫 我一把揭開白布件甥。 她就那樣靜靜地躺著,像睡著了一般哼拔。 火紅的嫁衣襯著肌膚如雪引有。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 49,929評論 1 290
  • 那天倦逐,我揣著相機(jī)與錄音譬正,去河邊找鬼。 笑死檬姥,一個(gè)胖子當(dāng)著我的面吹牛曾我,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播健民,決...
    沈念sama閱讀 39,076評論 3 410
  • 文/蒼蘭香墨 我猛地睜開眼抒巢,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了秉犹?” 一聲冷哼從身側(cè)響起蛉谜,我...
    開封第一講書人閱讀 37,803評論 0 268
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎崇堵,沒想到半個(gè)月后型诚,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 44,265評論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡筑辨,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,582評論 2 327
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了幸逆。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片棍辕。...
    茶點(diǎn)故事閱讀 38,716評論 1 341
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡暮现,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出楚昭,到底是詐尸還是另有隱情栖袋,我是刑警寧澤,帶...
    沈念sama閱讀 34,395評論 4 333
  • 正文 年R本政府宣布抚太,位于F島的核電站塘幅,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏尿贫。R本人自食惡果不足惜电媳,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 40,039評論 3 316
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望庆亡。 院中可真熱鬧匾乓,春花似錦、人聲如沸又谋。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,798評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽彰亥。三九已至咧七,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間任斋,已是汗流浹背继阻。 一陣腳步聲響...
    開封第一講書人閱讀 32,027評論 1 266
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留仁卷,地道東北人穴翩。 一個(gè)月前我還...
    沈念sama閱讀 46,488評論 2 361
  • 正文 我出身青樓,卻偏偏與公主長得像锦积,于是被迫代替她去往敵國和親芒帕。 傳聞我的和親對象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,612評論 2 350

推薦閱讀更多精彩內(nèi)容