Multimedia&Network

1、Unity3D共支持4种格式音乐文件:

2、AudioSource用于指明音频源,被绑定在一个GameObject身上。光有AudioSource组件声音是无法听到的,因为在3D世界中,距离远的音频我们听不到或者声音小,而距离近的音频我们就能清楚地听到。这样的效果需要通过AudioListener来实现,AudioListener被绑定在Camera身上,因为在3D世界上,我们的位置与Camera的位置一致。

只有AudioSource可以加载音乐文件,当代码中有AudioSource时,只能指向AudioSource,而非音乐源文件,如下:

 

3、视频使用MovieTexture来播放。

     //电影纹理
public MovieTexture movTexture; void Start()
{
//设置当前对象的主纹理为电影纹理
renderer.material.mainTexture = movTexture;
//设置电影纹理播放模式为循环
movTexture.loop = true;
} void OnGUI()
{
if(GUILayout.Button("播放/继续"))
{
//播放/继续播放视频
if(!movTexture.isPlaying)
{
movTexture.Play();
} } if(GUILayout.Button("暂停播放"))
{
//暂停播放
movTexture.Pause();
} if(GUILayout.Button("停止播放"))
{
//停止播放
movTexture.Stop();
}
}

4、也可以通过GUI.DrawTexture来播放视频。

     //电影纹理
public MovieTexture movTexture; void Start()
{
//设置电影纹理播放模式为循环
movTexture.loop = true;
} void OnGUI()
{
//绘制电影纹理
GUI.DrawTexture (new Rect (,, Screen.width, Screen.height),movTexture,ScaleMode.StretchToFill); if(GUILayout.Button("播放/继续"))
{
//播放/继续播放视频
if(!movTexture.isPlaying)
{
movTexture.Play();
} } if(GUILayout.Button("暂停播放"))
{
//暂停播放
movTexture.Pause();
} if(GUILayout.Button("停止播放"))
{
//停止播放
movTexture.Stop();
}
}

5、使用WWW类获取网络数据。

     //本机下载的贴图
private Texture tex0 ; //服务器下载贴图
private Texture tex1; IEnumerator loadLocal ()
{
//本机下载
if(tex0 == null)
{
//资源在本机的路径
WWW date = new WWW("file://" + Application.dataPath + "/0.png");
//等待下载完成
yield return date;
//得到下载的贴图
tex0 = date.texture;
}
//更换为下载的贴图
renderer.material.mainTexture = tex0; } IEnumerator loadNetWork ()
{
//服务器网页下载
if(tex1 == null)
{
//资源的url服务器路径
WWW date = new WWW("http://www.google.com.hk/intl/zh-CN/images/logo_cn.png");
//等待下载完成
yield return date;
//得到下载的贴图
tex1 = date.texture;
}
//更换为下载的贴图
renderer.material.mainTexture = tex1;
} void OnGUI()
{
if(GUILayout.Button("本机下载贴图"))
{
StartCoroutine(loadLocal());
} if(GUILayout.Button("服务器下载贴图"))
{
StartCoroutine(loadNetWork());
}
}

6、使用Network类可以实现连接。Network.peerType的值为以下几种,可以用来判断网络状态。

  

  InitializeServer可创建服务器:

  

  通过connection属性可以获取连接的peer。

  

  通过connect方法可以连接至服务器:

  

  

Multimedia&Network的更多相关文章

  1. 使用YUM管理软件包

     一.概念 YUM,全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及SUSE中的Shell前端软件包管理器.基於RPM包管理,能够从指定的服务器 ...

  2. menuconfig选项

    打开一个典型的openwrt中package目录下都能发现两个相同点: ? package/<name> /Makefile ? package/<name> /patches ...

  3. qt Multimedia 模块类如何使用?

    qt 多媒体模块介绍 类名 英文描述 中文描述 QAudioBuffer Represents a collection of audio samples with a specific format ...

  4. Qt Multimedia 模块类如何使用?(表格)

    qt 多媒体模块介绍 类名 英文描述 中文描述 QAudioBuffer Represents a collection of audio samples with a specific format ...

  5. DeepCoder: A Deep Neural Network Based Video Compression

    郑重声明:原文参见标题,如有侵权,请联系作者,将会撤销发布! Abstract: 在深度学习的最新进展的启发下,我们提出了一种基于卷积神经网络(CNN)的视频压缩框架DeepCoder.我们分别对预测 ...

  6. 论文翻译:2020_Acoustic Echo Cancellation by Combining Adaptive Digital Filter and Recurrent Neural Network

    论文地址:https://arxiv.53yu.com/abs/2005.09237 自适应数字滤波与循环神经网络相结合的回声消除技术 摘要 回声消除(AEC)在语音交互中起关键作用.由于明确的数学原 ...

  7. 论文翻译:2020_RESIDUAL ACOUSTIC ECHO SUPPRESSION BASED ON EFFICIENT MULTI-TASK CONVOLUTIONAL NEURAL NETWORK

    论文翻译:https://arxiv.53yu.com/abs/2009.13931 基于高效多任务卷积神经网络的残余回声抑制 摘要 在语音通信系统中,回声会降低用户体验,需要对其进行彻底抑制.提出了 ...

  8. 论文翻译:2020_Nonlinear Residual Echo Suppression using a Recurrent Neural Network

    论文地址:https://indico2.conference4me.psnc.pl/event/35/contributions/3367/attachments/779/817/Thu-1-10- ...

  9. 论文解读(AGCN)《 Attention-driven Graph Clustering Network》

    Paper Information Title:<Attention-driven Graph Clustering Network>Authors:Zhihao Peng, Hui Li ...

随机推荐

  1. h-index

    https://leetcode.com/problems/h-index/ https://leetcode.com/mockinterview/session/result/xjcpjlh/ 看了 ...

  2. openfire源码分析

    启动流程 Socket接口 Socket通信使用Mina框架实现,是XMPP协议的处理入口,具体为: 消息接收后由不同的节处理器处理: StanzaHandler基础消息类型,之后进行消息路由: 最后 ...

  3. jQuery1.9+中删除了live以后的替代方法

    .live() removed The .live() method has been deprecated since jQuery 1.7 and has been removed in 1.9. ...

  4. UVa 11107 (后缀数组 二分) Life Forms

    利用height值对后缀进行分组的方法很常用,好吧,那就先记下了. 题意: 给出n个字符串,求一个长度最大的字符串使得它在超过一半的字符串中出现. 多解的话,按字典序输出全部解. 分析: 在所有输入的 ...

  5. 打印机C++

    m_prnDC.SetMapMode(MM_LOMETRIC);  m_iPrnX = m_prnDC.GetDeviceCaps(HORZRES);m_iPrnY = m_prnDC.GetDevi ...

  6. 移植linux(1)

    硬件环境:TQ2440   软件环境:linux-2.6.30.4 下载源码:ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.30.4.tar ...

  7. acdream 1683 村民的怪癖(KMP,经典变形)

    Problem Description 娜娜费劲九牛二虎之力终于把糖果吃完了(说好的吃不完呢?骗人,口亨~),于是,缘溪行,忘路之远近.忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷,娜娜甚异之 ...

  8. DOM对象常用对象的方法和属性

      HTML文档中的常用节点类型: 接口 nodeType 备注 Element 1 元素节点 Text 3 文本节点 Document 9 Document Comment 8 注释文本 Docum ...

  9. hibernate中使用fetch来决策性能方案

    什么时候用子查询,或者连接查询 一般多个数据的对应用子查询,单一行的数据用连接 (若要查询每个学生分别学了什么课程 ,若要fetch=join.fetch=select) 则是这种情况 Hiberna ...

  10. AIX 第2章 指令记录

    root@db:/#mount  node       mounted        mounted over    vfs       date        options     ------- ...