MediaElement can't play in Unity?
<MediaElement Source="G:\\test\\UnityApp1\\UnityApp1\\Assets\\Narrator107.mp3" LoadedBehavior="Manual" Name="media1">
</MediaElement>
var media = FindName("media1") as MediaElement;
media.Play();
I tested it. MP4 can play, but MP3 and wav can't play at present. Can this play?
</MediaElement>
var media = FindName("media1") as MediaElement;
media.Play();
I tested it. MP4 can play, but MP3 and wav can't play at present. Can this play?
Re: MediaElement can't play in Unity?
Had the same issue trying to play wav audio files.
Needed to use a MediaElement as I wanted to receive an event when the the audio stopped playing.
In the end I found the best solution was to convert all the wavs into mp4 files, using 'ffmpeg' (which is all round excellent & batch converts very easily)
If you use Unity though, you will need to convert them into actual video mp4s - when I converted I added add a parameter to insert a redundant single black frame.
Works fine after that and the mp4s are smaller than my Wavs!
(Its speech so it really doesn't affect anything for the purists out there) :)
Needed to use a MediaElement as I wanted to receive an event when the the audio stopped playing.
In the end I found the best solution was to convert all the wavs into mp4 files, using 'ffmpeg' (which is all round excellent & batch converts very easily)
If you use Unity though, you will need to convert them into actual video mp4s - when I converted I added add a parameter to insert a redundant single black frame.
Works fine after that and the mp4s are smaller than my Wavs!
(Its speech so it really doesn't affect anything for the purists out there) :)
Re: MediaElement can't play in Unity?
Absolute paths like this are not correct in Unity as you shouldn't use resources out of the project. As described in the URI documentation the correct ways to use an absolute or relative path are:<MediaElement Source="G:\\test\\UnityApp1\\UnityApp1\\Assets\\Narrator107.mp3" LoadedBehavior="Manual" Name="media1" />
Code: Select all
<MediaElement Source="Narrator107.mp3" LoadedBehavior="Manual" Name="media1" />
<MediaElement Source="/Assets/Narrator107.mp3" LoadedBehavior="Manual" Name="media1" />
Who is online
Users browsing this forum: No registered users and 2 guests