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. 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.
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.
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.
I waas able to make this work when I was playing the wav file on the server side, the issue with that, is the quality of the wav file is so bad, there's so much background noise and I could barely understand anything.
Member
19 Points
95 Posts
Re: How can I play a wave file in mvc
Aug 31, 2017 06:26 PM|MikeT89|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. 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. 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.
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.
I waas able to make this work when I was playing the wav file on the server side, the issue with that, is the quality of the wav file is so bad, there's so much background noise and I could barely understand anything.