Solved

PHP code enhancement

Posted on 2012-03-15
4
333 Views
Last Modified: 2012-05-04
Good afternoon.

What I am trying to do on the playlist tab. Currently I have a PHP code that randomly generates a playlist each time the user clicks on the category. What I want to do is now have the ability to load 5 seconds (mp3) that will load every 5 songs. for example one of the add is a voice clips "You’re  listening to HIPHOP and R&B provided by theonlinebeatz.com I want that mp3 clip to load every 5 other mp3's.
 
 (I still want to keep the way that is being generated randomly)
autoplaylist.php
0
Comment
Question by:Zirwo02
4 Comments
 
LVL 13

Expert Comment

by:joomla_php
ID: 37729394
What is the mechanism that plays the mp3 now? I think this would be an ffmpeg type of operation in which the full mp3 is edited on the fly to snip out the 5 second clip.
0
 
LVL 14

Expert Comment

by:Scott Madeira
ID: 37730752
Sounds like you have a list of songs in an array that is your playlist.  Or you are randomly getting songs and playing them in a loop.  Before playing a song you want to check to see if you played 5 songs.  If so, play an ad....  The logic would be something like this:

$counter = 0;

While ($play_songs == true){

    // play the song
 
    // use the modulus to track every multiple of 5 to play an ad
    if ( ! $counter % 5) {
          // play an ad
    }

    $counter++;
}

Sorry, can't be more specific without the code you are using...
0
 

Author Comment

by:Zirwo02
ID: 37731858
the php code is attahced and that's what I use to generate the playlist. Let me know what else you need.
0
 
LVL 34

Accepted Solution

by:
Slick812 earned 500 total points
ID: 37744060
greetings Zirwo02, , I looked at your code file of  autoplaylist.php  , there's too much code in it for me to spend time on trying to figure out how to help you, I can see that the method-function that makes the play-List is   makePlaylist(  )  , , however this is NOT a short function and does several many things to make a play list, to make it even more complex, it adds sub-items like artist, title and image.
I do not really know how the XML is suppose to read to be workable for this, and I do not have time to install and use the  autoplaylist.php  stuff and see what the XML will be, ? ?
I will guess that you want to insert a line in the XML for your ads that would be =
<item><filename>/home/domain/pickle/theonlinebeatz.mp3</filename></item>

you may could do this in the  makePlaylist(  )   method-function,   do you have code you can show where you altered the  makePlaylist(  )  function to try and get this?
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP Mail error 3 26
How to delete values from an array using php 4 22
Echo Multiple values from multiple records 19 39
issue with DB import 1 17
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question