Click here to Skip to main content
15,887,822 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Developers,

I have been working on a music player for a while now, but i have been having problem with speed. The music player loads every mp3 file in the music folder and at that same instance also getting the metadata and cover art for the picture.

Is there anyway to make this faster, instead of loading all files and their details which takes so much time. Please Help If there is a faster method to do this

What I have tried:

i tried to load it once at the first instance then serialize, so when opening it again it wont be loading from the music directory but it would be deserializing instead, but this also takes time.

Please Help
Posted
Updated 21-Oct-16 8:08am
Comments
Dave Kreskowiak 21-Oct-16 14:07pm    
That depends entirely on the music play component you're using, it's capabilities and what it exposes for an API. It's entirely possible there is nothing you can do about this. You'd have to consult with the people that wrote the component you're using.
Suvendu Shekhar Giri 21-Oct-16 14:07pm    
How can we suggest anything without seeing what you have tried?
There is no need at all to load all the files at once.
ChrisHD22 21-Oct-16 17:47pm    
First of all, which audio library are you using? Which musicTagReader library are you using? And we cannot tell you how to optimize your code if we have not seen it yet.

1 solution

There is no "one size fits all" approach which we can tell you "do this, it'll be fine" - but you may want to look at background and / or "as required" loading.
start by identifying where the bottlenecks are: without n=knowing that you have nowhere to focus your attention. So use the Stopwatch class to monitor what is going on and give you numbers to work from. Spot where the major time is being taken, and you can start "drilling down" to find out what parts of that you will get best results from - there is no point in investing a week's effort into saving 90% of something that only uses 0.5 seconds in the real world, but a lot of reward in spending the same time saving 50% of something that takes 30 seconds.

So gather information, look at your code, and think about what you are doing and why: caching the MP3 file records in a text file instead of reading directly from the folders can be a very good saving, even if you then have to run a background task to update it while the rest of your app is running. Not loading images you don't need yet can save a lot of time as well. But you need info first, so get that together and start targeting your efforts.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900