UE4_UE5播放音频(播放、停止功能)(附工程)

24 篇文章 5 订阅

在UE4或UE5中播放音频的两种方式:

一、直接通过创建MediaPlayer播放:

1.创建MediaPlayer,命名为myMediaPlayer

选择生成的MediaTexture是用于播放视频,下篇文章来讲UE5如何播放视频。

2.创建一个Actor类用于播放音频,命名为BP_mySoundActor

3.编辑Actor类,添加MediaSound组件

4. 选中MediaSound组件,在其右侧将MediaPlayer设置为刚创建的myMediaPlayer

5.接着在BP_mySoundActor类中添加变量cMediaPlayer

 

 6.Complie一下当前蓝图类,然后将cMediaPlayer的值设置为自定义的myMediaPlayer

 7.最后在Actor类里直接打开音频文件

 8.将此蓝图类拖到场景中,运行即播放音频

或者通过动态加载的方式

此方法在删除Actor的时候,音频也会消失,就无需去做关闭音频的操作。

二、通过插件RuntimeAudioImporter播放:

在UE商城里下载免费的插件RuntimeAudioImporter

然后在工程里安装这个插件:

重启工程,并打开关卡蓝图:

 这样不需要去创建MediaPlayer就能直接播放音频,并且是可以播放各种音频。

但是这样直接播放音频,想停止音频的时候就不能直接销毁,于是要将播放音频的操作写到Actor类里,需要播放时就动态加载此Actor类到场景中,想关闭音频的时候,就直接删除当前Actor即可。

在新建的runtimeSound类里:

鼠标左键动态加载Actor到场景,右键删除:

最后工程地址分享:https://download.csdn.net/download/Highning0007/87337412

  • 5
    点赞
  • 31
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论
In the first edition, models initially developed to describe wave propagation in porous media saturated by heavy fluids are used to predict the acoustical performances of air saturated sound absorbing porous media. In this expanded and revised edition, we have retained, with slight modifications, most of the basic material of the first edition and expanded it by revisiting several original topics and adding new topics to integrate recent developments in the domain of wave propagation in porous media and practical numerical prediction methods that are widley used by researchers and engineers. Chapters 1 to 3 dealing with sound propagation in solids and fluid and Chapter 9 dealing with the modelling of perforated facings were slightly modified. Chapters 4 to 6 were greatly revisited. A more detailed description of sound propagation in cylindrical pores is presented (Chapter 4), related to the more general presentation of new parameters and new models for sound propagation in rigid-framed porous media (Chapter 5). Also in Chapter 5 a short presentation of homogenization, with some results concerning double porosity media, is added. In Chapter 6, different formulations of the Biot theory for poroelastic media are given, with a simplified version for the case of media with a limp frame. In Chapter 11 we have revisited the original representation of the modelling of layered media (Chapter 7 of the first edition) and extended it to cover the systematic modelling of layered media using the Transfer Matrix Method (TMM). In particular, a step by step presentation of the numerical implementation of the method is given with several application examples. Major additions include five new chapters. Chapter 7 discusses the acoustic field created by a point source above a rigid framed porous layer, with recent advances concerning the poles of the reflection coefficient and the reflected field at grazing incidence. Chapter 8 is concerned by the poroelastic layers excited by a point source in air or by a localized stress source on the free face of the layer, with a description of the Rayleigh waves and the resonances. Axisymmetrical poroelastic media are studied in Chapter 10. In Chapter 12, complements to the transfer matrix method are given. They concern mainly the effect of the finite lateral extend, and the excitation by point loads, of sound pack- ages. Several examples illustrating the practical importance of these extensions are given (e.g. size effects on the random incidence absorption and transmission loss of porous media; airborne vs. structure borne insertion loss of sound packages). In Chapter 13, an introduction to the finite element modelling of poroelastic media is presented. Emphasis is put on the use of the mixed displacement-pressure formulation of the Biot theory, xiv PREFACE TO THE SECOND EDITION which appears in the Appendix of Chap. 6. Detailed description of coupling conditions between various domains including a waveguide are presented together with sections on the breakdown of the power dissipation mechanisms within a porous media and radiation conditions. Several applications are chosen to illustrate the practical use of the presented methods including modelling of double porosity materials and smart foams. As in the first edition, the goal of the book remains to provide in a concrete manner a physical basis, as simple as possible, and the developments, analytical calculations and numerical methods, that will be useful in different fields where sound absorption and transmission and vibration damping by air saturated porous media are concerned.
UE4_API_Reference 是一个非常宝贵的资源,它提供了 Unreal Engine 4 引擎的全部 API 详细文档。这些离线文档对开发者来说非常重要,因为它们可以在没有网络连接的情况下提供对 UE4 引擎的完整了解和查询支持。 UE4_API_Reference 全部离线文档包括了对 UE4 的各个模块、类、函数和属性的详细描述和用法示例。开发者可以通过这些文档深入了解各个功能模块的实现原理以及如何正确使用它们。这对于开发者学习 UE4 引擎以及进行游戏开发非常有帮助。 离线文档的好处在于可以在没有网络的环境中使用。开发者不需要依赖互联网来查找关于 UE4 API 的信息,而是可以直接在本地进行搜索和查询。这不仅提高了开发效率,还可以避免由于网络问题导致的信息获取困难。 UE4_API_Reference 全部离线文档的编制工作需要花费大量的时间和精力。文档中的每一个类、函数和属性都需要进行详细描述和示例演示,以便开发者能够更好地理解和使用。这就要求文档编写人员具备广泛的知识和丰富的经验,以确保文档的完整性和准确性。 总之,UE4_API_Reference 全部离线文档对于 UE4 开发者来说是一个非常宝贵的资源。它提供了对 UE4 引擎的全面了解和查询支持,可以帮助开发者更好地学习和使用 UE4 引擎进行游戏开发。同时,它也方便了开发者在没有网络连接的环境中进行开发工作,提高了开发效率。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Bricke

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值