<template name="audioList">
	<view>
		<swiper class="swiper" autoplay="false" vertical="true" interval="990000" @change="changeAudio">
			<swiper-item v-for="(v, k) in item" :key="k">
				<dever-audio
				:src="v.audio" 
				:pic="v.pic" 
				:control="true"
				:loop="true"
				:load.sync="load"
				ref="audio"
				>
				</dever-audio>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
import deverAudio from '@/lib/dever/components/audio.nvue';
var play = true;
export default {
	name: "audioList",
	props: {
		control : {
			type : Object,
			value : null
		},
		item : {
			type    : Array,
			value	: null
		},
		index : {
			type    : Number,
			value	: null
		},
	},
	data() {
		return {
			load : false,
			current_index: 0,
		};
	},
	created() {
		
	},
	mounted() {
		this.control[this.index] = this;
	},
	methods:{
		start : function() {
			this.$refs.audio[this.current_index].start();
		},
		stop : function() {
			this.$refs.audio[this.current_index].stop(true);
		},
		changeAudio : function(e)  {
			var self = this;
			self.$nextTick(()=>{
				this.$refs.audio[this.current_index].stop(false);
				this.current_index = e.detail.current;
				self.start();
			});
					
		},
	},

	components:{
		deverAudio
	}
}
</script>

<style>
.swiper{
	width: 100vw;
	height: 100vh;	
	/*position: fixed;*/
	position: relative;
	top: 0;
	left: 0;
}
</style>
