zoukankan      html  css  js  c++  java
  • Flex 笔记之—音乐控制(SoundChannel, SoundTransform, volume)

    //首先将一个mp3导入了库中,给声音文件设置了music类
    //
    在场景中建立3个按钮buttonplay,Continuebotton,stopbotton
    var musicstar:SoundChannel=new SoundChannel();
    var StopPlayPosition:Number;//停止播放的位置
    var soundLoopPlay:Boolean=true;//是否循环播放
    var soundTF:SoundTransform = new SoundTransform();//控制声音的音量
    var music_play:music = new music();

    soundTF.volume = 0.5;//控制声音的音量现在是原来音量的一半
    musicstar.soundTransform = soundTF;
    stopbotton.visible=true;
    Continuebotton.visible=false;
    function playLoop():void {

    if (soundLoopPlay) {//循环播放
    musicstar = music_play.play();
    musicstar.addEventListener(Event.SOUND_COMPLETE, onSoundPlay);
    } else {
    musicstar = music_play.play();
    }

    }
    function onSoundPlay(evt:Event):void {
    musicstar.stop();//停止播放
    playLoop();
    }

    buttonplay.addEventListener(MouseEvent.CLICK,PLAY_1);

    function PLAY_1(e:MouseEvent):void {
    stopbotton.visible=true;
    Continuebotton.visible=false;
    musicstar.stop();
    playLoop();
    }

    stopbotton.addEventListener(MouseEvent.CLICK,STOP_1);

    function STOP_1(e:MouseEvent):void {
    stopbotton.visible=false;
    Continuebotton.visible=true;
    StopPlayPosition=musicstar.position;
    musicstar.stop();
    }

    Continuebotton.addEventListener(MouseEvent.CLICK,Continue_1);

    function Continue_1(e:MouseEvent):void {
    stopbotton.visible=true;
    Continuebotton.visible=false;
    musicstar=music_play.play(StopPlayPosition);
    musicstar.addEventListener(Event.SOUND_COMPLETE, onSoundPlay);
    }
  • 相关阅读:
    ArcGIS 重新创建几何服务(GeometryService)
    ArcGIS Server10.4安装教程
    ArcGIS Desktop10.4安装教程
    elk使用不足及弥补报警措施
    数据链路层
    限制mongoDB内存的方法
    计算机网络原理,TCP&UDP
    生产中一次内存使用过高排查过程
    (坑爹错误)记录prometheus中配置alertmanager.yml一次报错
    prometheus监控(小试牛刀)
  • 原文地址:https://www.cnblogs.com/rmbteam/p/2411732.html
Copyright © 2011-2022 走看看