audio not playing in live server codeigniter - php

below code display the audio, audio tag works perfectly, it play the music in local server, but on live server audio not working, its not playing the music. it is appearing like disabled things in chrome and in mozilla it is not even showing the play button. i think problem is with source url.
<audio controls id = "myaudio">
<source src="<?php echo base_url(); ?>worship/assets/<?php echo $row->language_folder; ?>/<?php echo $row->album_folder; ?>/<?php echo $row->song_name; ?>" type="audio/mp3">
</audio>
Please advise me.

Hope this will help you :
Just change the Media Type OR MIME-type from audio/mp3 to audio/mpeg
<source type="audio/mpeg" src="<?php echo base_url(); ?>worship/assets/<?php echo $row->language_folder; ?>/<?php echo $row->album_folder; ?>/<?php echo $row->song_name; ?>" >
and use base_url like this (just suggestion) ;
<source type="audio/mpeg" src="<?php echo base_url('worship/assets/'.$row->language_folder.'/'.$row->album_folder.'/'.$row->song_name); ?>" >
For more :
https://www.w3schools.com/tags/tag_audio.asp

Related

Get filename from paths in codeigniter

HI guys i am trying to get the image/video filename from path
Here i have paths in my php variable like this from database
E:/xampp/htdocs/pes/new/movie.mp4
E:/xampp/htdocs/pes/new/flowers.jpg
And i am trying to get new/movie.mp4 or new/flowers.jpg from above paths and display it in img tag or video tag
<img src="new/flowers.jpg" alt="Trulli" width="500" height="333">
or
<video width="400" controls>
<source src="new/movie.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video>
Can anyone help me how to do that
Thanks in advance
Hope this will help you :
Set your base_url in your config.php
$config['base_url']='http://localhost/pes/'
and ur image src should be like this :
<img src="<?=site_url('new/'.$image); ?>" alt="Trulli" width="500" height="333">
Try with base_url(). Set your base_url in config.php for example www.xyz.com/ Update your code like this:
<img src="<?php echo base_url() ?>new/flowers.jpg" alt="Trulli" width="500" height="333">
And video frame:
<video width="400" controls>
<source src="<?php echo base_url() ?>new/movie.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video>
Hope this will help you!
If all paths are relative to FCPATH, FCPATH = 'E:/xampp/htdocs/pes', you can use:
<img src="<?php echo base_url(str_replace(FCPATH, '', 'E:/xampp/htdocs/pes/new/flowers.jpg')) ?>" alt="Trulli" width="500" height="333">
or
<video width="400" controls>
<source src="<?php echo base_url(str_replace(FCPATH, '', 'E:/xampp/htdocs/pes/new/movie.mp4')) ?>" type="video/mp4">
Your browser does not support HTML5 video.
</video>

How do i remove quotes from url string in php

I'm working on a wordpress plugin that streams videos using video js lib, but i can't figure out how my code automatically generates this (” and ″) in all my url supplied to the player.
this is what talking about, this is the url of the file :
"”https://s3-us-west-2.amazonaws.com/test-past3/data/Andrew+Cranston+-+Banners+of+Progress.mp4″"
this is my video player code:
<video class="video-js vjs-skin-flat-red vjs-16-9" id="<?php print $attr['video_id'];?>" style="max-width: 100%;"
controls
preload="<?php print $attr['preload']; ?>"
width="<?php print $width?>"
<?php print $muted ? "muted" : ""?>
height="<?php print $height?>"
poster="<?php print $attr['poster'];?>"
data-setup='{
"plugins": {
"vastClient": {
"adTagUrl": "<?php print $attr['adtagurl']; ?>",
"adCancelTimeout": 5000,
"adsEnabled": true
}
}
}'>
<source src="<?php print $attr['url']; ?>" type="<?php print $mime_type ?>"></source>
<p class="vjs-no-js">
To view this video please enable JavaScript, and consider upgrading to a
web browser that
<a href="http://videojs.com/html5-video-support/" target="_blank">
supports HTML5 video
</a>
</p>
</video>
Just use the substr() function :
<source src="<?php print substr($attr['url'], 1, -1); ?>"
But i recommand you to find why your $attr['url'] come with quotes :)
Another two solutions with str_replace() and preg_replace().
str_replace(['”', '″'], '', $url);
preg_replace('/[”″]+/', '', $url);
But substr() is simpler and faster in this specific case (remove first and last characters from string).
substr($url, 1, -1);

Not able to display video in PHP

On my site, users are able to upload videos.
And I am storing that videos in a folder and their path in the mysql database.
I want to retrieve that videos from the folder and get display on the page.
That folder also contains images.
I am showing that images also.
Images are getting displayed. And videos only play audio, and not the video. And also, I have only two videos in my database and one image. Then also 3 video files and 3 image are getting display, from which two images are displayed with alternate text.
Following is the code I tried in PHP:
if ($db_found)
{
$query ="SELECT * FROM `files`";
$result = mysql_query($query,$db_handle);
echo "<div class='product'>";
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$src=$row['File'];
echo "<img src='$src' height='200' width='200' alt='Image not Found'/>";
echo "<video width='200' height='200' autoplay controls>
<source src='$src' type='video/mp4'>
</video>";
}
echo "</div>";
}
You need to check which are videos and which are images using something like:
$src=$row['File'];
if (preg_match("/\.jpg$/i",$src)){
echo "<img src='$src' height='200' width='200' alt='Image not Found'/>";
}else{
echo "<video width='200' height='200' autoplay controls> <source src='$src' type='video/mp4'> </video>";
}
Edit
Oh and please stop using the deprecated mysql functions
Choose a more modern method of connecting to the db
You really should add (at the very least) some way to separate your videos and images. For example, a second column in your files table that tells you if the file in question is a video or image.
Then you can simply do something like this:
SELECT * FROM `files` WHERE `filetype` == 1
Where 1 = image, 2 = video, etc.
Then you can simply process that array as you please:
<?php
foreach($images as $image) { ?>
<img src='<?= $image["src" ?>' alt=''>
<?php } ?>
And
<?php
foreach($videos as $video) { ?>
<video id="video" preload="auto" autoplay="autoplay">
<source src="<?= $video["src"] ?>.mp4">
</video>
<?php } ?>
Note: The fact that only audio is playing on your videos has NOTHING to do with your code.

PHP + jQuery gallery

I have this code:
<img src="'. $random_pics[$i] .'" width="'.$thumb_width.'" alt="" name="?album='. urlencode($albums[$i]) .'" class="alb" />
<div id="pictures"></div>
<script>
$('.alb').click(function(){
var href = $(this).attr('name');
$("#pictures").load('display.php'+href)
});
</script>
Then I have a display.php file, where I use $_GET['album'] to get the album name and display the photos from that album.
How it should work: when I click the image, the pictures div should load the display.php?album=somealbum, but for some reason it does not... My files are bigger, but I think the problem is here.
It looks like you missed the php tags around each of those embedded php codes. Or perhaps there should be more to the snippet you provided?
<img src="<?php echo $random_pics[$i]; ?>"
width="<?php echo $thumb_width; ?>"
alt=""
name="?album=<?php echo urlencode($albums[$i]); ?>"
class="alb" />

Linking nightmare on my street

<img src="…/<?php echo "$ArtFilePath"; ?>">
gives me this. It’s actually the one I want only without the …
http://markdinwiddie.com/PHP2012/.../artwork/Drawings/Boy.jpg
<img src="../<?php echo "$ArtFilePath"; ?>">
give me this
http://markdinwiddie.com/artwork/Drawings/Boy.jpg
<img src="/../<?php echo "$ArtFilePath"; ?>">
gives me this
http://markdinwiddie.com/artwork/Drawings/Boy.jpg
and
<img src="/…/<?php echo "$ArtFilePath"; ?>">
gives me this
http://markdinwiddie.com/.../artwork/Drawings/Boy.jpg
What I need is
http://markdinwiddie.com/PHP2012/artwork/Drawings/Boy.jpg
Who knows the order of dots and slashes?
Since $artFilePath == "artwork/Drawings/Boy.jpg", you want either:
Relative urls
Provided your php file is within /PHP2012/ this will work. It will even work if you rename the directory
<img src="<?php echo $ArtFilePath ?>" />
Which outputs
<img src="artwork/Drawings/Boy.jpg" />
Absolute urls
<img src="/PHP2012/<?php echo $ArtFilePath ?>" />
Which outputs
<img src="/PHP2012/artwork/Drawings/Boy.jpg" />
if the webpage is within the PHP2012 folder: http://markdinwiddie.com/PHP2012/
and your image is in artwork/Drawings/Boy.jpg within the PHP2012 folder
can't you just do <img src="<?php echo "$ArtFilePath"; ?>">

Categories