Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6140835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:10:16+00:00 2026-05-23T18:10:16+00:00

i am actually working on this mentioned title. player show the list, its generating

  • 0

i am actually working on this mentioned title. player show the list, its generating perfectly. but i am no where to make it actually play that file. i must be wrong some where.
i need advise fox. (ahh if i can attach the files.)

my class

    class DecodDir 
        {
            function getFiles($directory)
            {
                $all_files  = array();
                $handler    = opendir($directory);
                while($files=readdir($handler))
                {
                    if($files!="." && $files!="..")
                    {
                        $all_files[]= $files;
                    }
                }
                closedir($handler);
                return $all_files;
            }
        }

################# file where i am using this class *###############



 <?php

 include("decoddir.php");

 $obj       = new DecodDir();
 $results   = $obj->getFiles("mp3");
 $total     = count($results);
 $string        = "";
 for($i=0; $i<$total; $i++){

    $string .="
        {
        name:'$results[$i]',
        mp3:'mp3/$results[$i]',
        ogg:'$results[$i]'
        },
        ";
 }

    ?>
// its at the top of that html file (ofcorse with the php ext)

and below, this is where it is generating the playlist

var audioPlaylist = new Playlist("2", [
<?php echo $string; ?>
],

http://www.jplayer.org/latest/demo-02/ (the link from where i get jplayer) you can see the audio player with playlist.
(actually i don’t know hot format the code in here stackoverflow)
thanks
Rafay

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:10:17+00:00Added an answer on May 23, 2026 at 6:10 pm

    I have taken the liberty of re-factoring the code a bit for you. I don’t know exactly what you are trying to do, but it will help to have the beginnings of a better class on your side.

    <?php
    
    class DecodDir
    {
    
        private
            $directory,
            $files;
    
        public function __construct( $directory = null )
        {
            if ( ! is_null($directory) )
            {
                $this->setDirectory( $directory );
            }
        }
    
        public function setDirectory( $directory )
        {
            $this->directory = $directory;
            $this->files = null;
    
            // TODO put some validation in here;
    
            return $this;
        }
    
        public function getDirectory()
        {
            if ( is_null($this->directory) )
            {
                $this->directory = './';
            }
            return $this->directory;
        }
    
        private function getFiles()
        {
            if ( is_null($this->files) )
            {
                $this->files = array();
                $handler    = opendir( $this->getDirectory() );
                while($files=readdir($handler))
                {
                    if($files!="." && $files!="..")
                    {
                        $this->files[]= $files;
                    }
                }
                closedir($handler);
            }
    
            return $this->files;
        }
    
        public function getJson()
        {
            $list = array();
    
            foreach ( $this->getFiles() as $filename )
            {
                $item = new stdClass();
    
                $item->name = $filename;
                $item->mp3 = "mp3/{$filename}";
                $item->ogg = $filename;
    
                $list[] = $item;
            }
    
            $json = json_encode( $list );
    
            return $json;
    
        }
    
        public function countFiles()
        {
            return sizeof( $this->getFiles() );
        }
    
    }
    
    
    $obj = new DecodDir( 'mp3' );
    echo $obj->getJson();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Actually, This is working fine.. but i want the parent value. not a child
Actually I'm working with BufferedImages, that provide me pixel values in int type. Do
I've got an ASP document that 5 years old. Actually I'm working with PHP
I understand that this is a very broad question, but I was very curious
I'm actually working at MOSS 2007 project where I have to import data from
I am actually working on SP in SQL 2005. Using SP i am creating
Actually I have a file . I am working in linux environment. I need
I'm working on designing the kernel (which I'm going to actually call the core
I am working with a set of what is essentially Attribute/Value pairs (there's actually
I'm working on a WTL project, actually WTL 8.1 with VS2008. In many tutorials

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.