Aug 31, 2017 07:26 PM|mgebhard|LINK
When the user does a search I don't exactly know how many data will be pulled from the database and each one could have a byte array data. Once it get's the data it will display them on a webgrid, in one of my column I display an image if that employee has
a byte array data.
What is does the byte array data contain? Is it, by chance, a Base64 encoded string?
If the user clicks that img it will trigger an ajax call that would pass the corresponding byte array to the controller. It will then convert that byte array to a wav file then pass that wav file back to the view for the audio tag to play.
Why do you need to pass this array around?
You are not passing the wav file back. You are serializing the wav file to disk and returning a URL to the wav file. The client code invokes load which does yet another request to get the wav file (serialize) from disk. Basically, you're caching the file
on the hard drive. Keep in mind disk IO is an expensive operation and you are doing a lot of disk IO. That's why I suggested that you cache the wav file in memory.
The solution you posted works for the first wav file, but if the user clicks a different employee to play the wav file or do another search and play a wav file from one of the results it still plays the first wav file. Even if I delete "~/Content/Notify.wav"
first and then re-create it with the new byte array written in it, it would still play the first one it played and not the new one.
This is simply not true. I tested the solution and it works as expected. Did you try the solution as is without making changes? How about posting the code or code that reproduces the issue.
The thing is I don't want to reload the page each time the user plays a wav file, and I think that's the reason why it keeps playing the first wav file it create, since the first wav file was the one that's loaded to the page and since I'm not reloading the
page it's not reloading the new wav file it created. But I don't know how to resolve the issue.
You'll need to step through your code with the Visual Studio debugger. At this point there is not much else I can do to help you. IMHO, you need to rethink the approach.