Welcome Guest, Not a member yet? Register   Sign In
Play Audio file in writable folder
#1
Sad 

Is it possible to play audio files that are inside the writable folder?

Code:
<audio controls="">
    <source src="C:\wamp64\www\cdr\writable\audios\2021\04\06\1617722381.169-221-20523678-12%3A19%3A41.wav">
</audio>

I have this code on the front end, but the audio doesn't play.

Thank you all!
Reply
#2

premise : the public is the webroot
two ways
1, add new folder example 'uploads' in public/ . then upload files in it (public/uploads)
2, make the (your writable/uploads full path) softlink to public/uploads . then upload filed in (writable/uploads full path)
Reply
#3

(This post was last modified: 08-10-2021, 04:58 AM by InsiteFX.)

Try this, not tested.
Code:
<audio controls="">
    <source src="<?= base_url(WRITEPATH.'audios\2021\04\06\1617722381.169-221-20523678-12%3A19%3A41.wav');?>">
</audio>

See if that will work for you.

UPDATE:

I found out that chrome and any web browsers using the chrome engine will give the error.

What I did to get it to work was to play the audio files from my live server then it worked.

Could be public_html or public depends on the server mine is public_html

Code:
<audio controls autoplay>
    <source src="https://www.your_server_name.com/assets/audio/bubble.mp3" type="audio/mpeg">
    Your browser does not support the audio element.
</audio>

Set audio folder permissions to 755
All have only read access owner has read/write/execute permissions.

Worked like a charm.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#4

I tried as follows, but to no avail.

moved files from writable to public/assets/audios

PHP Code:
<audio controls>
      <source src="<?= base_url('assets/audios/'.$line["audiofile"]) ?>" type="audio/mpeg">
      Your browser does not support the audio element.
</
audio

base_url('assets/audios/'.$line["audiofile"]) print:
http://cdr.local/assets/audios/2021/08/1...07m29s.WAV

directly accessing the url in browser
[Image: Screenshot_1.png?1628606412]
Reply
#5

Upload your file to public /upload


You cannot read file from writable folder
Enlightenment  Is  Freedom
Reply
#6

(This post was last modified: 08-10-2021, 09:03 AM by rafinhaa.)

(08-10-2021, 08:13 AM)paliz Wrote: Upload your file to public /upload


You cannot read file from writable folder

Yes! i moved files from folder writable to public/assets/audios

I found the problem was the file's codec
Code:
Input File    : 'public/assets/audios/2021/08/10/1628601745.4-FX0-atendimento-10:22:32.WAV'
Channels      : 1
Sample Rate    : 8000
Precision      : 16-bit
Duration      : 00:00:07.08 = 56640 samples ~ 531 CDDA sectors
File Size      : 11.6k
Bit Rate      : 13.1k
Sample Encoding: GSM

I did the test with another file and everything worked
Code:
Input File    : 'public/assets/audios/2021/04/06/1617722381.169-221-20523678-12:19:41.wav'
Channels      : 1
Sample Rate    : 8000
Precision      : 16-bit
Duration      : 00:00:25.38 = 203040 samples ~ 1903.5 CDDA sectors
File Size      : 406k
Bit Rate      : 128k
Sample Encoding: 16-bit Signed Integer PCM

Thanks to everyone who helped!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB