Solved

PHP code enhancement

Posted on 2012-03-15
4
325 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 33

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
mysql Encryption with PHP 8 49
Modify PHP Code on the Fly? 8 40
Editing login page in zencart. 2 14
Strip leading 0 from a var 3 14
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now