加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flash AS3声音视频编程

发布时间:2020-12-15 18:15:43 所属栏目:百科 来源:网络整理
导读:入门极好视频:?http://www.enet.com.cn/eschool/video/flashas3/ 《Flash CS3 AS3声音视频高级编程》共分为两章:第一章深入讲解了FLASH对于声音的编程,最后通过一个功能强大的MP3播放器进行演示,通过这一章的学习可以让你对于声音的处理有一个深入的掌握



入门极好视频:?http://www.enet.com.cn/eschool/video/flashas3/

《Flash CS3 AS3声音视频高级编程》共分为两章:第一章深入讲解了FLASH对于声音的编程,最后通过一个功能强大的MP3播放器进行演示,通过这一章的学习可以让你对于声音的处理有一个深入的掌握;第二章深入讲解了对于视频的处理,包括如何使用现有视频组件来控制视频。同时还讲了如何创建自己的控制外观。


声音示例:

[AS3.0编程教学]最全的声音控制方法 ?http://jingyan.baidu.com/article/a948d651bc90a60a2ccd2e4c.html


视频示例:?http://www.cuplayer.com/player/PlayerCodeCourse/2012/0914409.html

[Flex]NetStream动态加载视频利用SoundTransform控制音量

  1. <?xml?version="1.0"?encoding="utf-8"?>?
  2. <!--?http://blog.flexexamples.com.sixxs.org/2008/03/01/displaying-a-video-in-flex-using-the-netconnection-netstream-and-video-classes/?-->?
  3. <mx:Application?xmlns:mx="http://www.adobe.com.sixxs.org/2006/mxml"?
  4. ????????????????layout="vertical"?
  5. ????????????????verticalAlign="middle"?
  6. ????????????????backgroundColor="white"?
  7. ????????????????viewSourceURL="srcview/index.html"?xmlns:local="*"?
  8. ????????????????initialize="init();">?
  9. ?
  10. ????mx:Script>?
  11. ????????<![CDATA[ ?
  12. ????????????import?mx.controls.Alert; ?
  13. ????????????private?var?urlArr:Array=["http://221.122.36.143.sixxs.org/oa/video/1.flv",?"http://221.122.36.143/oa/video/2.flv",?"http://221.122.36.143/oa/video/p2.mp4"]; ?
  14. ????????????public?function?init():void{ ?
  15. ????????????????myVideo.urlArr?=?urlArr; ?
  16. ????????????????myVideo.total?=?100000; ?
  17. //??????????????Alert.show("1==>>"+myVideo.urlArr.length); ?
  18. ????????????} ?
  19. ???????????? ?
  20. ????????]]>?
  21. ????</>?
  22. ?
  23. ????local:mVideo?id="myVideo"/>?
  24. ?
  25. mx:Application>?
  26. ?
  27. 第二个文件 ?
  28. xml?version="1.0"?encoding="utf-8"?>?
  29. mx:Panel?xmlns:mx="http://www.adobe.com.sixxs.org/2006/mxml"?
  30. ??????????creationComplete="setTransformVolume();">?
  31. ????>?
  32. ????????<![CDATA[ ?
  33. ????????????import?mx.controls.Alert; ?
  34. ????????????import?mx.events.SliderEvent; ?
  35. ?
  36. ????????????private?var?nc:NetConnection; ?
  37. ????????????private?var?ns:NetStream; ?
  38. ????????????private?var?nc2:NetConnection; ?
  39. ????????????private?var?ns2:NetStream; ?
  40. ????????????private?var?video:Video; ?
  41. ?
  42. ????????????[Bindable] ?
  43. ????????????public?var?urlArr:Array=null; ?
  44. ????????????public?var?total:Number=0; ?
  45. ?
  46. ????????????private?var?count:int=0; ?
  47. ????????????private?var?finished1:int=1;?//1:播放正在进行;0:播放结束 ?
  48. ????????????private?var?finished2:int=0;?//1:播放正在进行;0:播放结束 ?
  49. ?
  50. ????????????private?var?volumeTransform:SoundTransform; ?
  51. ?
  52. ????????????private?function?setTransformVolume():void{ ?
  53. ????????????????volumeTransform=new?SoundTransform(); ?
  54. ????????????????slider.value?=?volumeTransform.volume; ?
  55. ????????????????slider.tickInterval?=?slider.snapInterval; ?
  56. ????????????????slider.liveDragging?=?true; ?
  57. ????????????????slider.addEventListener(Event.CHANGE,?volumeChangeHandler); ?
  58. ????????????????init(); ?
  59. ????????????} ?
  60. ???????????? ?
  61. ????????????private?function?init():void ?
  62. ????????????{ ?
  63. ????????????????Alert.show(""?+?total); ?
  64. ???????????????? ?
  65. ????????????????var?nsClient:Object={}; ?
  66. ????????????????nc=new?NetConnection(); ?
  67. ????????????????nc.connect(null); ?
  68. ????????????????ns=new?NetStream(nc); ?
  69. ????????????????ns.play(urlArr[count]); ?
  70. ????????????????ns.client=nsClient; ?
  71. ????????????????ns.soundTransform=volumeTransform; ?
  72. ????????????????ns.addEventListener(NetStatusEvent.NET_STATUS,?myTest1); ?
  73. ???????????????? ?
  74. ????????????????video=new?Video(); ?
  75. ????????????????video.name="video1"; ?
  76. ????????????????video.width=uic.width; ?
  77. ????????????????video.height=uic.height; ?
  78. ????????????????video.attachNetStream(ns); ?
  79. ????????????????if?(uic.getChildByName("video1")?!=?null) ?
  80. ????????????????{ ?
  81. ????????????????????uic.removeChild(uic.getChildByName("video1")); ?
  82. ????????????????} ?
  83. ?
  84. ????????????????count++; ?
  85. ????????????private?function?volumeChangeHandler(event:SliderEvent):void?{ ?
  86. ????????????????volumeTransform.volume?=?slider.value; ?
  87. ????????????????ns.soundTransform?=?volumeTransform; ?
  88. ????????????????ns2.soundTransform?=?volumeTransform; ?
  89. ????????????private?function?init2():void ?
  90. ????????????{ ?
  91. ?
  92. ????????????????var?nsClient:Object={}; ?
  93. ?
  94. ????????????????nc2=new?NetConnection(); ?
  95. ????????????????nc2.connect(null); ?
  96. ????????????????ns2=new?NetStream(nc2); ?
  97. ????????????????ns2.play(urlArr[count]); ?
  98. ????????????????ns2.client=nsClient; ?
  99. ????????????????ns2.soundTransform=volumeTransform; ?
  100. ????????????????ns2.addEventListener(NetStatusEvent.NET_STATUS,?myTest2); ?
  101. ????????????????video.name="video2"; ?
  102. ????????????????video.attachNetStream(ns2); ?
  103. ????????????????if?(uic.getChildByName("video2")?!=?null) ?
  104. ????????????????????uic.removeChild(uic.getChildByName("video2")); ?
  105. ????????????????} ?
  106. ????????????????count++; ?
  107. ????????????} ?
  108. ?
  109. ????????????private?function?myTest1(event:NetStatusEvent):void ?
  110. ????????????{ ?
  111. ????????????????trace("count1==>>"?+?count); ?
  112. ????????????????trace("count1?onStatus:"?+?event.info.code); ?
  113. ????????????????if?(event.info.code?==?"NetStream.Buffer.Full") ?
  114. ????????????????{ ?
  115. ????????????????????if?(count?==?1) ?
  116. ????????????????????{ ?
  117. ????????????????????????uic.addChild(video); ?
  118. ????????????????????????init2(); ?
  119. ????????????????????} ?
  120. ????????????????????if?(finished2?==?1) ?
  121. ????????????????????{ ?
  122. ????????????????????????ns.seek(0); ?
  123. ????????????????????????ns.pause(); ?
  124. ????????????????????} ?
  125. ????????????????else?if?(event.info.code?==?"NetStream.Play.Stop") ?
  126. ????????????????????finished1=0; ?
  127. ????????????????????finished2=1; ?
  128. ????????????????????uic.addChild(video); ?
  129. ????????????????????ns2.togglePause(); ?
  130. ????????????????????if?(count?<=?urlArr.length) ?
  131. ????????????????????????init(); ?
  132. ????????????????????} ?
  133. ?
  134. ????????????private?function?myTest2(event:NetStatusEvent):void ?
  135. ????????????????trace("count2==>>"?+?count); ?
  136. ????????????????trace("count2?onStatus:"?+?event.info.code); ?
  137. ????????????????????if?(finished1?==?1) ?
  138. ????????????????????????ns2.seek(0); ?
  139. ????????????????????????ns2.pause(); ?
  140. ????????????????} ?
  141. ????????????????else?if?(event.info.code?==?"NetStream.Play.Stop") ?
  142. ????????????????????finished2=0; ?
  143. ????????????????????finished1=1; ?
  144. ????????????????????uic.addChild(video); ?
  145. ????????????????????ns.togglePause(); ?
  146. ????????????????????if?(count?<=?urlArr.length) ?
  147. ????????????????????????init2(); ?
  148. ????????????public?function?stopVideo():void ?
  149. ????????????????uic.stop(); ?
  150. >?
  151. ????mx:VideoDisplay?id="uic"?
  152. ?????????????????????width="550"?
  153. ?????????????????????height="450"?
  154. ?????????????????????volume="{slider.value}"/>?
  155. ?
  156. ????mx:ControlBar>?
  157. ????????mx:HSlider?id="slider"?
  158. ????????????????????minimum="0.0"?
  159. ????????????????????maximum="1.0"?
  160. ????????????????????snapInterval="0.1"?
  161. ????????????????????tickInterval="0.1"?
  162. ????????????????????liveDragging="true"/>?
  163. ????????mx:Button?label="Play/Pause"?
  164. ???????????????????click="uic.play();"mx:Button?label="Rewind"?
  165. ???????????????????click="stopVideo();"/>?
  166. ????>?
  167. mx:Panel>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读