Random Play with XML Playlist

I created a custom flv player and loaded a xml playlist. I
would like to the play the videos randomly. could anyone help me
with my script.
the following is my current action script:
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.setBufferTime(30);
ns.onStatus = function(info) {
if(info.code == "NetStream.Buffer.Full") {
bufferClip._visible = false;
if(info.code == "NetStream.Buffer.Empty") {
bufferClip._visible = true;
if(info.code == "NetStream.Buffer.Stop") {
ns.seek(0);
theVideo.attachVideo(ns);
rewindButton.onRelease = function() {
ns.seek(0);
playButton.onRelease = function() {
ns.pause();
var videoInterval = setInterval(videoStatus,100);
var amountLoaded:Number;
var duration:Number;
ns["onMetaData"] = function(obj) {
duration = obj.duration;
function videoStatus(){
amountLoaded = ns.bytesLoaded / ns.bytesTotal;
loader.loadbar._width = amountLoaded * 200;
loader.scrub._x = ns.time / duration * 200;
var scrubInterval;
loader.scrub.onPress = function() {
clearInterval(videoInterval);
scrubInterval = setInterval(scrubit,10);
this.startDrag(false,-5.3,this._y,193.3,this._y);
loader.scrub.onRelease = loader.scrub.onReleaseOutside =
function() {
clearInterval(scrubInterval);
videoInterval = setInterval(videoStatus,100);
this.stopDrag();
function scrubit() {
ns.seek(Match.floor((loader.scrub._x/200)*duration));
var theMenu:ContextMenu = new ContextMenu();
theMenu.hideBuiltInItems();
_root.menu = theMenu;
var i1:ContextMenuItem = new ContextMenuItem("::::
VideoControls ::::",trace);
theMenu.customItems[0] = i1;
var i2:ContextMenuItem = new ContextMenuItem("Play / Pause
Video",pauseIt,true);
theMenu.customItems[1] = i2;
var i3:ContextMenuItem = new ContextMenuItem("Replay
Video",replayIt);
theMenu.customItems[2] = i3;
var i4:ContextMenuItem = new ContextMenuItem("Copyright 2006
VideoLightTV.com",trace,true);
theMenu.customItems[3] = i4;
function pauseIt() {
ns.pause();
function replayIt() {
ns.seek(0);
var vlist:XML = new XML();
vlist.ignoreWhite = true;
vlist.onLoad = function() {
var videos:Array = this.firstChild.childNodes;
for(i=0;i<videos.length;i++) {
videoList.addItem(videos
.attributes.url,videos.attributes.url);
ns.play(videoList.getItemAt(0).data);
videoList.selectedIndex = 0;
var vidList:Object = new Object();
vidList.change = function() {
ns.play(videoList.getItemAt(videoList.selectedIndex).data);
videoList.addEventListener("change",vidList);
vlist.load("videos.xml");

Try something like this:
vidList.change = function() {
var nextVideo =Math.floor(Math.random()/videos.length);
ns.play(videoList.getItemAt(nextVideo).data);

Similar Messages

  • Random music with a playlist?

    Hi everyone,
    Just a simple question... I have been running with my Ipod and Nike+ thing for 2 weeks now, and Inwanted to know if it was possible to have random songs with a playlist I use for my jogging.
    I don't want random of all my songs, just from one playlist, and I don't know how to do.
    So far, it always begin with the first in alphabetical order.
    And is it possible to have statistics in an other way? instead of 5min/km, to know my km/hour average... Well, just to know, I don't care much, I can make the calcul myself, but still.
    Thx!

    Create a new Smart playlist.
    Match Rule;
    Playcount is 0 (or Last played is not in the last 2 months).
    My rating is not 1 star. (Rate songs 1 star that you don't want on the iPod)
    Limit it to 7200MB at random.
    Select teh iPod in iTunes. Click the Music tab.
    Select Sync music and Selected playliusts.
    Select this new playlist.
    When you want to change the music on the iPod, select this playlist, click a song, select all (ctrl A) then press delete.
    It will immediatley fill up again based on the criteria.
    Plug in the iPod to sync it.

  • Need help embedding a mp3 player swf with xml playlist

    Im a noob to Flash (started tuesday, haha) and so far everything is coming along just fine, but i need to put music in the swf. I have a button set up that slides a swf mp3 player in from the side but i dont know how to make the playlist work with it.
    The player is from this site:
    http://www.bezzmedia.com/swfspot/samples/flash8/Mp3_Player_with_XML_Playlist
    Using the xml playlist with html is simple enough, but im not sure how to use it with Flash Catalyst. Is there an easy way to do this?
    My original plan was to have a text list of the songs with a play button next to each one, then when you click on the play button it would set the state of any other songs to Stopped so you can just pick what song to play and if another song was playing it would stop. Im not sure how to do this either (like i said, i started learning this week), so i just tried embedding someone else's (ugly) mp3 player.
    Anyway, if anyone knows a relatively easy way to have a playlist in my swf please let me know. Thanks!

    If I understand you correctly, you've imported a SWF into Catalyst using Import Artwork on the File menu. When your app runs, you want to pass that swf a parameter that tells it what URL to read a data file from. The SWF is not one that you've created, rather, you got it from some web site.
    This is not something that you can do in Catalyst. However it should be possible to do in Flash Builder. I found an article discussing several ways to do it, at http://www.actionscript.org/forums/showthread.php3?t=175951. One idea is the following code snippet
    <fx:Script>
        <![CDATA[
        import flash.events.*;
        private function setVars(event):void
            event.target.content.yyyyyy = "zzzzzz";
        ]]>
    </fx:Script>
    <mx:Image source="xxxxx" complete="setVars(event)" />
    where "xxxxx" is the path of the SWF (you can put it somewhere in your Flash Builder project, or reference it via an URL), and yyyyy is the name of the parameter that the SWF expects, and zzzzzz is the path to the data file. The <Image> tag is what Catalyst created when you imported the SWF. (btw.the Image and SWFLoader tags are almost identical).
    I hope this gives you enough info to make progress.

  • FLV & SWF player with XML Playlist

    What I want is to create a player that can handle SWFs and
    FLVs or just FLVs, that load from a XML playlist.
    Now I have seen the tutorial (Creating a Dynamic Playlist for
    Progressive Flash Video) url:
    http://www.adobe.com/devnet/flash/articles/prog_download.html
    But this populates a list that you have to click to play the
    next movie, but I want it to play swf1 or flv1 then 2 then 3 and so
    on, then loop. But I can't find a tutorial for this anywhere?
    Any ideas, I need a detailed tutorial or a working example?

    I recently made something like that, but then my project
    consultor, made me change to use only flv files.
    The project is going to be an internal tv channel for a
    university, here in Portugal. First I thought of mixing SWF and
    FLV's together, but then it required that someone that used the
    system, knew how to program SWF's, because you need to change a
    flag (variable) at the end of the playback of the SWF. This change
    of flag status indicates that this SWF is over and pass to the next
    entry of the playlist. Without this, I think that you would never
    know when to go to next entry. so, the code resembled a little like
    this:
    if ((_root.percen_tx.text == "100%") || (_global.over == 1
    && _global.tipo[_global.num]=="1")) {
    _global.over = 0;
    _root.percen_tx.text = "";
    if (_global.num == (_global.filmes.length-1)) {
    _global.num = 0;
    switch (_global.tipo[_global.num]) {
    case "1" :
    loadMovie(_global.filmes[_global.num], _root.swf_cont);
    _root.descr_tx.text = "";
    _root.percen_tx.text = "";
    break;
    case "0" :
    _root.contentor.my_FLVPlybk.contentPath =
    _global.filmes[_global.num];
    _root.descr_tx.text = _global.descr[_global.num];
    break;
    } else {
    _global.num += 1;
    _root.percen_tx.text = "";
    switch (_global.tipo[_global.num]) {
    case "1" :
    _global.over=0;
    loadMovie(_global.filmes[_global.num], _root.swf_cont);
    _root.descr_tx.text = "";
    _root.percen_tx.text = "";
    break;
    case "0" :
    _root.contentor.my_FLVPlybk.contentPath =
    _global.filmes[_global.num];
    _root.descr_tx.text = _global.descr[_global.num];
    break;
    A brief explanantion:
    _global.over -> 0 (not over); 1 (is over)
    _global.tipo -> value that comes from an xml, and
    indicates if this playlist entry is a SWF or a FLV (they go to
    different MC's);
    _root.percen_tx -> Indicates the percentage of the FLV
    file that was already read. "100%" is over
    This is not the most efficient way to do it, because you can
    use listeners and so on, but at the time I abbandoned this, at this
    stage. Now it's only FLV, and only a few lines of code.
    You can see the project at www.ipvctv.com
    Hope it helped a bit.

  • Avoid random play in certain playlists or genres

    Does anyone have any ideas how to do this without having to go into settings and do it. I would like to have itunes leave certain genres and albums in order. Books for example which are broken into mp3 parts should not be randomized.

    what you need is to go to the section (playlist) and play, e.g. go to artist (The Beatles), you should able to play all The Beatles songs in shuffle

  • Creating random play with labels

    I have 5 labels inside 1 movieclip that I would like to
    activate with a play button that randomly choices one of the labels
    when pressed. Can someone please assist me with this. To be honest
    I'm not great with action script so a sample code or tutorial would
    be ideal.Thanks in advance.
    Regards

    Can anyone advise if the action script should be applied to
    the Button, Movieclip or the timeline.
    Thanks in advance.

  • Can shuffle songs or random play be used with a playlist?

    After a playlist is on the ipod, can you play the songs in the playlist randomly or in shuffle mode? Haven't been able to find any info on this.

    Well... yes, this works, but for me, it's a bit less than ideal.
    I don't want to have to turn Shuffle on or off then navigate to the desired playlist.
    What I want is a sort of "Smart Shuffle Playlist" that will contain X number of songs that I put into it and will always play those X songs in random order. Other playlists (non-Smart Shuffle Playlists) would not be touched.
    Why? Some playlists would be an exact, fixed sequence of songs that I really prefer to listen to in a particular order. Other playlists would be a bunch of songs that would play in a random order every time.
    The current options are *so close* to this... but just not there.

  • ITunes will only play one song. I have to hit play to start a new song. I have the shuffle on and I am in a playlist. I am running Windows 7. How do  I correct this to randomly play music, by itself?

    iTunes will only play one song. I have to hit play to start a new song. I have the shuffle on and I am in a playlist. I am running Windows 7. How do I correct this to randomly play music, by itself?

    That's consistent with all the tickboxes to the left of the tracks (in Song view) being unchecked.
    Go into Song view and Ctrl-click one of the empty boxes to do a "global recheck".
    If you can't see the tickboxes, head into your General preferences tab and select "Show list tickboxes" as per the following screenshot (it's for an earlier version of iTunes, but the boxes are in roughly the same place in the recent versions 11.x):

  • Is random play  less random with 11?

    Yep,
    due to the errors of iTunes 11, I stayed with 10 and finally updated last week. My mostly used playlist is intelligent one, being updated with songs not played the last couple of month and I usually use it with Random Play.
    Since that update from iTunes 10 to 11.0.4, I do have the impression, that the RandomPlay does not work that good anymore. Lots of Interpreter do occure with 2 songs in a row. Sometime even more. I noted up to 5 songs from one Interpret one after another. I am still not sure whether this is accidential, but as I observe this now since the update (I am a every day music listener) and never ever before (I use iTunes since Tiger), I doubt it. And beside that effect, the list looks pretty random.
    It may depends on the way how I do fill the PlayingNext, but I am not sure yet ...
    Does anybody has observed the same? Any idea?
    1000Thx for your help!

    Yep,
    meanwhile some days are gone and I almost was about to think that I was wrong with my assumption that random does not work that good anymore. But today I checked the list of songs being played next and found 11 Songs from one band in a row! Beside several other bands occuring 2, 3, 4 or 5 time in a row. I thought it might be sorted somehow, but I could not see anything. For sure it was no alphabetical order.
    When I highlighted the PlayList, I could sort the songs as expected by doublecklicking the headline, but as soon as I clicked on random, the same odd playorder occured (up to 11 from one band in a row).
    However, I noticed one thing ...
    The list which shows all the titles, with interpreters, song duration, last played and so on, has a very first column which is just an ongoing numbering. With iTunes 10 this was the order in which those songs are being played, but now with iTunes 11, it looks different. It seems like it remains to be just a numbering and not a playorder at all. When checking that, I saw that the little loudspeaker jumped cross the list to every song whichever song is played. In iTunes 10, I could say "Play this list randomly" and the numbering in the first column was played one after another, as the songs were already listed in a random order.
    May I stumble here over a different way of using iTunes between version 10 and 11.
    Any idea or help to get back on track is highly appreciated!
    Greetz from Germany!

  • HT1349 When listening to songs on my itunes acct (without ipod attached), I can only play one song at a time. It doesn't automatically play next song on list. It happens with all playlists. It only started happening when I downloaded the latest itunes upd

    When listening to songs on my itunes acct (without ipod attached), I can only play one song at a time. It doesn't automatically play next song on list. It happens with all playlists. It only started happening when I downloaded the latest itunes update.

    Are all songs checked in your playlist?

  • I have a tiny problem that is driving me mad. When I am playing an album in iTunes using cover flow view (with the playlist beneath the artwork picture) the  picture is exactly above the album title. All is symmetrical. When I switch to full screen displa

    I have a tiny problem that is driving me mad. When I am playing an album in iTunes using cover flow view (with the playlist beneath the artwork picture) the  picture is exactly above the album title. All is symmetrical. When I switch to full screen display, the artwork moves a couple of inches to the left and the display is therefore asymmetrical. Why and how do I correct it? It would drive you mad to.
    Thanks for any help,
    Graham

    I was having the same problem, but tried the "Top Button + Home Button" reset and that did work for me. My unofficial guess is that perhaps RAM caches get filled through daily use of various apps leaving no memory for cover flow. Resetting the phone on the phone itself seems to reset that RAM. I can't say it's a cure-all, but it solved my issue. Hope this helps.

  • Making xml playlist to play swf files inside one swf

    Hi,
    I have made an swf file and xml playlist.
    I want to include swf filepaths in xml playlist so i would be able to choose from my the list, which file i want to play.
    My list-component reads data from the xml, but i cannot get the swf files open there.
    I will attach my .fla file so you understand what i'm talking about.
    the .fla:
    http://www.mediafire.com/file/m24dz0gmzwz/Untitled-1.fla
    xml file:
    http://www.mediafire.com/file/gdyzzymy5mn/swfList.xml
    would you guys look at my files? i know i can play .flv files but i want to know how to play swf files inside another swf. The swf files should be loaded to  by the xml list.

    Hi
    we want to give some clarifications
    As per our requirement we need to play same swf file ( about
    5 in number) always.
    These swf files are kept in some folder and during run time
    we need to play these swf files inside our Mac / windows
    application using flash player.
    we don't need to play any swf file, but the same swf files
    we need a api / sdk to implement this
    Any help will be very well appreciated
    Sudesh

  • Problems with FMS2 streaming flv through xml playlist

    I've been testing for the first time FMS2 and has been quite
    a pain to make it work, I've been able to stream a single flv file
    but now that I've tried to stream multiple flv using a xml playlist
    (using the same example provided in
    http://www.adobe.com/devnet/flash/articles/video_player.html)
    and it wont work.
    I have IIS and FMS2 in the same computer.
    In the example provided by Adobe was an error in
    VideoSource.as in line originally was:
    my_FLVPlybk.contentPath = nav.attributes.url + "/_definst_/"
    + stream.attributes.name+".flv";
    And had to change "/_definst_/" to "_definst_/" to make it
    work, since path are:
    rtmp://localhost/videsource/_definst_/fish.flv for example
    and not:
    rtmp://localhost/videsource//_definst_/fish.flv
    Once that was solved and tested it works locally (in the same
    machine where the server is installed) but when testing from
    another computer it doesn't stream any videos.
    All the files are place the way it supposed to be in:
    \applications\videosource\streams\_definst_ (here are the
    videos)
    \applications\videosource (here is the main.asc)
    Then in IIS:
    \Inetpub\wwwroot\playlist (playlist-demo-1.xml,
    VideoThumb.as, VideoSource.as, VideoSource2.html, VideoSource2.swf,
    SteelExternalAll.swf).
    When tested local with
    http://localhost/playlist/VideoSource2.html
    or
    http://localhost/playlist/VideoSource2.swf
    works, but
    when trying from another computer in the same network or
    outside with
    http://my_server/playlist/VideoSource2.html
    wont stream like I said before.
    In the single flv stream (without xml playlist) I seem to be
    able to stream, just made a .fla with a FLVPlayback component
    pointing to: rtmp://localhost/test/_definst_/test.flv
    And trying
    http://my_server/test.html
    works fine.
    I've done the following:
    1. Added a MIME type to IIS for .flv and .swf
    2. Vhost.xml is open for all networks
    (<Allow>All</Allow>)
    3. Change the Global Security Settings for the Flash Player
    to access the .flv on the IIS server.
    4. No firewalls activated (for testing purposes).
    And it works with the single .flv stream but not with the
    xml playlist and I've run out of ideas or what to do, so I'm in
    need of anyone who can help me out and give me some insight.
    Thanks in advance.

    Sounds like a Flash Player security issue because you are
    running from a desktop. One of the items that can be different
    between Test Movie and a published test is security and any
    internet protocol. Flash Security errors fail silently.
    Look at
    NetConnection.connect
    method for the security warnings and references.
    If you plan to deploy from a web server, test there and it
    will likely work.

  • Why can i only select playlists from iTunes to play with my slideshows?

    I used to be able to select individual tracks from my itunes library to play with slideshows. For some reason i only seem to be able to select playlists now?
    Anybody know what is going on here? I did recently upgrade my iLife, has this got anything to do with it?
    Any feedback or hints and tips greatly received.
    G4 Powerbook, 1.25 Ghz   Mac OS X (10.3.9)   iPod 5gen 30G, Sony DSC-P7

    hi chris,
    You might just have to fiddle around with the window and the dimple.
    Take a look at the quicktime movies to see if it will help you.
    Music menu for Cinematic Slideshow
    Music menu for "on the fly" Slideshow
    Lori

  • IPod Video will Randomly turn on and play a certain playlist

    My iPod will randomly turn on and play a certain playlist I have. It will also do it in the middle of other playlist or when I'm just playing music. It is always the same playlist and there is no pattern as to when it will do this. Any ideas?

    Turn off the alarm.
    EXTRAS > CLOCK > ALARM CLOCK > ALARM > OFF
    Cheers!
    -Bryan

Maybe you are looking for