I’m trying to get the image of an audio file like mp3 to create something similar to this (The BassCandy picture)
I have no idea how they store the picture and song details in the mp3 file!
I have tried using the following but it simply returns a question mark image because im guessing im not supposed to be calling this method on an audio file but rather an actual texture lol… anyway! any ideas?
In future just ask a search engine, it would have given you the answer immediately, unlike this forum. You also could have gone straight to the file format specification and looked at that. If it’s in the file, then it’s in the format specification.
I’m sorry but i don’t really know how to GRAB that data in Unity, im still a beginner! Any built in available methods or do i have to look up how to grab such data in C#
Sup @WazupGames , since Mr @Hikiko66 is not of much help.
I did some research and came up with this:
You should use TagLibSharp (just google “TagLibSharp dll download”)
Then put .dll in Plugins folder
using TagLib;
using System.IO;
public RawImage rawImage;
private void ReadMetadata(string path)
{
var tfile = TagLib.File.Create(path);
//get metadata
string title = tfile.Tag.Title;
string album = tfile.Tag.Album;
System.TimeSpan duration = tfile.Properties.Duration;
// Load you image data in MemoryStream
TagLib.IPicture pic = tfile.Tag.Pictures[0];
MemoryStream ms = new MemoryStream(pic.Data.Data);
ms.Seek(0, SeekOrigin.Begin);
//Create texture2d with MemoryStream
Texture2D tex = new Texture2D(2, 2);
tex.LoadImage(ms.ToArray());
/// assign to a RawImage
rawImage.texture = tex;
}