import { _decorator, Component, Label, Node } from 'cc';
import { bag_item_data, event_item_stop_play_loop_sound } from '../../../data/data';
import { tools } from '../../tools';
const { ccclass, property } = _decorator;

@ccclass('event_stop_play_loop_sound')
export class event_stop_play_loop_sound extends Component {
    @property(Node) btn_select_sound:Node = null;
    @property(Node) lab_name:Node = null;
    private m_data:event_item_stop_play_loop_sound = null;
    public initView(data:event_item_stop_play_loop_sound){
        this.m_data = data;
        this.btn_select_sound.on(Node.EventType.TOUCH_END,()=>{
            tools.select_sound_list((data:bag_item_data)=>{
                this.m_data.res = data.url;
                this.updateStatus()
            })
        })
        this.updateStatus()
    }

    updateStatus(){
        if(this.m_data.res.length>0){
            this.lab_name.getComponent(Label).string = this.m_data.res
        }else{
            this.lab_name.getComponent(Label).string   = "选择停止播放语音文件"
        }
    }
}


