当前位置:网站首页>【Unity】AVPro使用踩坑,编辑器模式使用视频播放正常,打包后视频无法播放的问题
【Unity】AVPro使用踩坑,编辑器模式使用视频播放正常,打包后视频无法播放的问题
2022-07-23 04:34:00 【Zhangxian_12】
编辑器模式使用视频播放正常,打包后视频无法播放的问题
这个主要是AVPro的坑
一般使用会直接Browse给取文件路径,然后面板上面就能看到视频文件的名字,这个方法在编辑器模式下播放是可以获取到文件的,所以没问题。
但是打包后路径变化,拉取到的地址就不对了。
首先把视频资源改存到StreamingAssets文件夹路径下,然后路径获取方式Application.streamingAssetsPath加上视频路径即可:
using RenderHeads.Media.AVProVideo;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class VideoURL : MonoBehaviour//这个脚本挂在组件所在物体上,然后把视频文件名(包含.mp4后缀名)填上去
{
MediaPlayer _mediaPlayer;
public string videoURL;
private void Awake()
{
_mediaPlayer = transform.GetComponent<MediaPlayer>();
_mediaPlayer.m_VideoPath = Application.streamingAssetsPath + "/Video/" + videoURL;//这里cideoURL直接给到文件名,如"动画一.mp4"
}
private void Start()
{
_mediaPlayer.Play();//运行即播放,这个按自己的需求来
}
}
(这里特别注意一下组件那张图箭头所指的资源路径获取方式,请选择第一项AbsolutePathOrURL,选择其他方式哪怕代码指定了,组件也会依照其他获取方式来等待)
重新打包运行,正常播放。
.p.s.我发现直接给组件拉取文件路径,然后勾选自动播放循环,即使是编辑器模式下播放也会有一点延迟,代码操控似乎没有延迟直接播放了?
边栏推荐
- Self operation and maintenance: a new sample of it operation and maintenance services in Colleges and Universities
- 32 < tag array and bit operation > supplement: Lt. sword finger offer 56 - I. number of occurrences of numbers in the array
- 32.< tag-数组和位运算>补充: lt.剑指 Offer 56 - I. 数组中数字出现的次数
- 写驱动程序的时候warning LNK4210报错
- Customer first | domestic Bi leader, smart software completes round C financing
- 0基础转行软件测试,月薪6000和11000的必备技能,截然不同...
- 理解ASP.NET Core - 基于Cookie的身份认证(Authentication)
- 《Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks》论文阅读
- 20.有效的括号
- How does VirtualBox set up port forwarding?
猜你喜欢

NFT数字藏品版权如何保护?

SQLZOO——SELECT Quiz

网线水晶头接法图解8根顺序

Sequence model (2) - natural language processing and word nesting

Information security is in danger, and it is urgent to control the leakage of enterprise data assets

China Economic Net: "Yuan universe" is hot

李宏毅机器学习2022-HW1

Antlr4 introductory learning (I): Download and test

When flutter runs flutter pub get, it reports an error: "the client does not have the required privileges“

PyQt5_ Pyqtgraph mouse draws line segments on the line graph
随机推荐
nacos限流查询的脚本
When flutter runs flutter pub get, it reports an error: "the client does not have the required privileges“
The safe distance between you and personal information leakage may be decided by a laptop!
配饰器模式
Chapter 3 Standard Input
New file / filter / folder in VS
Add trust list
FPGA——SPI总线控制flash(2)(含代码)
Cloudcompare & PCL point cloud point matching (based on point to face distance)
Flutter 运行flutter pub get 报错“客户端没有所需特权“
Basic process of dpdk cross compilation
Redis pseudo cluster one click deployment script - pro test available
20.有效的括号
Li Hongyi machine learning 2022-hw1
【Warning】YOLOV5训练时的ignoring corrupt image/label: [Errno 2].....,无法全部训练数据集,快速带你解决它
Chapter 4 Executing Commands
How to protect the copyright of NFT digital collections?
跳转语句与调试程序
PyQt5_ Pyqtgraph mouse draws line segments on the line graph
Sequence model (III) - sequence model and attention mechanism