Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

PHP code enhancement

Posted on 2012-03-15
4
Medium Priority
?
341 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses
Course of the Month12 days, 2 hours left to enroll

916 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