Registriraj se
Artservis1

Izmenjava
 












  • Logo(1)
  • razlika v ceni ....(3)
  • Dreamweaver vrašanje(7)
  • Delo dobi...(1)
  • Iščemo arhitekturne projektante!(0)
  • Okus 51. beneškega bienala umetnosti (0)
  • Splet 2.0? (0)
  • Reason - Šola z razlogom 5. del (1)
  • Animiran metulj (0)
  • Reason - Šola z razlogom 4. del (0)
  • Taktike & praksa: Seminar novomedijske umetnosti (0)
  • Povabilo k sodelovanju na festivalu HAIP10 (0)
  • Apple iPad: odiseja v vesolju? (0)
  • Game Developers Conference San Francisco 2010 (0)
  • Google Chrome Beta za Mac in Linux ter razširitve (0)

  • Forum> programje & tehnika> Flash predvajalnik glasbe
    mloncaric

    Član

    .:Flash predvajalnik glasbe:. 11/02/2006, ob 12:42

    Prosil bi za eno veliko pomoč!
    Delam predvajalnik za glasbo za eno stran. Uporabil sem componente kot so DataGrid in MediaController. Za nalaganje pesmi sem uporabil XML datoteko, ki naloži playlist v datagrid, in tukaj so se zacele tezave. Rad bi, da ko kliknes na naslov pesmi, da bi le to zacelo predvajati v MediaControllerju, a ne deluje. Za pomoč bi vam bil zelo hvalezen.

    LP

    [BISI]

    Administrator

    .::. 13/02/2006, ob 01:46

    Huh, ne vem, ce je datagrid prava izbira za predvajalnik glasbe. Mislim, da bi bila tukaj pravsnja ListBox komponenta. Do nje lahko potem zelo enostavno dostopas z getSelectedItem(). Slednje pa pripopas na onselect event listener.
    Life is a workaround...a bad one.
    mloncaric

    Član

    .::. 13/02/2006, ob 13:43

    Aha. No tukaj je en primer ze delujocega predvajalnika, ki uporabla komponente accordion, tree, datagrid, mediacomponent, label. Ker v strani ze uporabljam accordion, imam za predvajalnik ze narejen mc, kateri se v acc loada.
    Kodo sem poskusal spremeniti na vse mozne nacine, a zmeraj se je nekje zalomilo. Rad bi odstranil tree in accordion komponenti, tako da bi izbrano pesem lahko izbral direktno iz datagrid.

    Tukaj je koda ze delujocega primera predvajalnika:














    Koda:


    // import component classes.
    import mx.controls.*;
    import mx.containers.*;
    import mx.controls.gridclasses.DataGridColumn;

    // add components to the Stage
    this.createClassObject(Label, "nowplaying_lbl", 1, {_x:35, _y:0});
    nowplaying_lbl.setSize(530, 20);
    nowplaying_lbl.setStyle("color", 0xFFFFFF);
    this.createClassObject(MediaController, "nowplaying_mediacon", 2, {_x:30, _y:45});
    nowplaying_mediacon.setSize(380, 24);
    this.createClassObject(Accordion, "jukebox_acc", 3, {_x:25, _y:75});
    jukebox_acc.setSize(550, 300);

    // configure components on main timeline
    nowplaying_lbl.autoSize = "center";
    nowplaying_lbl.text = "";
    nowplaying_mediacon.backgroundStyle = "none";
    nowplaying_mediacon.controllerPolicy = "off";

    // add the children to the Accordion component
    var library = jukebox_acc.createChild(mx.core.View, "library_mc", {label:" 1. Library"});
    var playlist = jukebox_acc.createChild(mx.core.View, "playlist_mc", {label:" 2. Playlist"});
    var nowplaying = jukebox_acc.createChild(mx.core.View, "nowplaying_mc", {label:" 3. Now Playing"});

    // add component instances to the Accordion component"s children.
    library.createClassObject(Tree, "library_tree", 100, {_x:10, _y:10});
    library.library_tree.setSize(530, 280);

    playlist.createClassObject(DataGrid, "playlist_dg", 200, {_x:10, _y:10});
    playlist.playlist_dg.setSize(530, 260);
    playlist.createClassObject(Label, "playlist_lbl", 201, {_x:10, _y:270});
    playlist.playlist_lbl.setSize(530, 20);

    var title_dgc:DataGridColumn = new DataGridColumn("title");
    title_dgc.headerText = "Title:";
    title_dgc.width = 300;
    playlist.playlist_dg.addColumn(title_dgc);

    var artist_dgc:DataGridColumn = new DataGridColumn("artist");
    artist_dgc.headerText = "Artist:";
    artist_dgc.width = 150;
    playlist.playlist_dg.addColumn(artist_dgc);

    var length_dgc:DataGridColumn = new DataGridColumn("length");
    length_dgc.headerText = "Length:";
    length_dgc.width = 60;
    playlist.playlist_dg.addColumn(length_dgc);

    playlist.playlist_lbl.autoSize = "center";
    playlist.playlist_lbl.text = "{PLAYLIST STATS}";

    nowplaying.createClassObject(Loader, "cover_ldr", 300, {_x:10, _y:10});
    nowplaying.cover_ldr.setSize(200, 200);
    nowplaying.createClassObject(MediaController, "mp3_mediacon", 301, {_x:220, _y:10});
    nowplaying.mp3_mediacon.setSize(300, 70);
    nowplaying.createClassObject(TextArea, "id3_ta", 302, {_x:220, _y:90});
    nowplaying.id3_ta.setSize(300, 160);
    nowplaying.createClassObject(MediaDisplay, "mp3_mediadisp", 303, {_x:220, _y:260});
    nowplaying.mp3_mediadisp.setSize(70, 70);

    nowplaying.mp3_mediacon.associateDisplay(nowplaying.mp3_mediadisp);
    nowplaying_mediacon.associateDisplay(nowplaying.mp3_mediadisp);

    nowplaying.mp3_mediacon.controllerPolicy = "on";
    nowplaying.id3_ta.editable = false;
    nowplaying.id3_ta.html = true;
    var borders_array:Array = new Array("borderColor", "buttonColor", "shadowColor", "highlightColor", "shadowCapColor", "borderCapColor");
    for (var side in borders_array) {
    nowplaying.id3_ta.setStyle(borders_array[side], 0xFFFFFF);
    }



    updatePlaylistStats();

    var dgListener:Object = new Object();
    dgListener.change = function(evt:Object) {
    playSong();
    };
    playlist.playlist_dg.addEventListener("change", dgListener);

    var songs_xml:XML = new XML();
    songs_xml.ignoreWhite = true;
    songs_xml.onLoad = function(success:Boolean) {
    if (success) {
    library.library_tree.dataProvider = this.firstChild;
    } else {
    trace("unable to load/parse library.xml");
    }
    };
    songs_xml.load("library.xml");

    var treeListener:Object = new Object();
    treeListener.change = function(evt:Object) {
    var selectedMP3:XMLNode = evt.target.selectedNode;
    if (evt.target.getIsBranch(selectedMP3)) {
    evt.target.setIsOpen(selectedMP3, !evt.target.getIsOpen(selectedMP3), true);
    } else {
    playlist.playlist_dg.addItem({title:selectedMP3.attributes["label"], artist:selectedMP3.attributes["artist"], length:selectedMP3.attributes["length"], track:selectedMP3.attributes["track"], album:selectedMP3.attributes["album"], cover:selectedMP3.attributes["cover"], src:selectedMP3.attributes["src"]});
    updatePlaylistStats();
    }
    };
    library.library_tree.addEventListener("change", treeListener);

    function playSong() {
    var thisSong:Object = playlist.playlist_dg.selectedItem;
    stopAllSounds();
    nowplaying.mp3_mediadisp.setMedia(thisSong.src, "MP3");
    nowplaying.mp3_mediadisp._playerImpl._sound.onID3 = function() {
    nowplaying_lbl.text = this.id3.artist+" -- "+this.id3.songname+" ("+thisSong.length+")";
    var id3_str:String = new String();
    id3_str = "<textformat tabstops="[70]">";
    id3_str += "<b>Artist:</b>    "+this.id3.artist+newline;
    id3_str += "<b>Album:</b>    "+this.id3.album+newline;
    id3_str += "<b>Song:</b>    "+this.id3.songname+newline;
    id3_str += "<b>Track:</b>    "+this.id3.track+newline;
    id3_str += "<b>Year:</b>    "+this.id3.year+newline;
    //id3_str += "<b>Genre:</b>    "+this.id3.genre+newline;
    id3_str += "</textformat>";
    //id3_str += "<p><font size="9">"+this.id3.TSSE+"</font></p>";
    nowplaying.id3_ta.text = id3_str;
    };
    nowplaying.mp3_mediadisp.play(0);
    nowplaying.cover_ldr.load(thisSong.cover);
    }

    function updatePlaylistStats():Void {
    var totalSeconds_number:Number = 0;
    var numSongs_number:Number = playlist.playlist_dg.dataProvider.length;
    for (var i = 0; i<numSongs_number; i++) {
    var time_array:Array = playlist.playlist_dg.dataProvider.getItemAt(i).length.split(":");
    totalSeconds_number += (Number(time_array[0]*60)+Number(time_array[1]));
    }
    var numMinutes = Math.floor(totalSeconds_number/60);
    var numSeconds = totalSeconds_number%60;
    var playlistLabel_string:String = numSongs_number+" "+((numSongs_number == 1) ? "song" : "songs");
    playlistLabel_string += ", "+numMinutes+":"+((numSeconds<10) ? "0" : "")+numSeconds;
    if (numMinutes<60) {
    // playlist length is under an hour.
    } else if (numMinutes<1440) {
    playlistLabel_string += " ("+(Math.round(numMinutes/60*10)/10)+" hours)";
    } else {
    playlistLabel_string += " ("+(numMinutes/1440)+" days)";
    }
    playlist.playlist_lbl.text = playlistLabel_string;
    }



    pesmi nalaga iz XML datoteke z imenom library.xml
    koda XML:













    Koda:


    <node>
    <node label="Macromedia">
    <node label="Tragic Sounds">
    <node label="Disk 1">

    <node label="Song One" src="song1.mp3" artist="Macromedia" album="Tragic Sounds" track="1" length="0:14" cover="images/cover.jpg" />
    <node label="Song Two" src="song2.mp3" artist="Macromedia" album="Tragic Sounds" track="2" length="0:08" cover="images/cover.jpg" />
    <node label="Song Three" src="song3.mp3" artist="Macromedia" album="Tragic Sounds" track="3" length="0:08" cover="images/cover.jpg" />


    </node>
    </node>
    </node>
    </node>



    Zal je ta koda primerna le za tree komponento.
    Ce bi imeli kaksno idejo, kak bi resil ta problem, bi vam bil zelo hvalezem.

    LP

    [BISI]

    Administrator

    .::. 14/02/2006, ob 00:50

    Zakaj pa potem v tree listenerju ne klices funkcije playSong?
    Life is a workaround...a bad one.
    mloncaric

    Član

    .::. 14/02/2006, ob 11:53

    Jap. Saj bi lahko, samo zelel sem narediti v datagrid zato, ker bi potem lahko kolicino pesmi dosti lazje razvrscal po kriterijih, naprier, velikosti pesmi, dolzini pesmi, imenu, albumu, ...

    Drugace pa bom vseeno probal z tree komponento, mogoce bo tudi dobro izgledalo.

    [BISI]

    Administrator

    .::. 14/02/2006, ob 12:08

    Hm, saj imas onchange listener tudi za Datagrid (id: playlist_dg), ki bi naj sprozil playSong? A sporoci debugger kaksno napako? :)
    Life is a workaround...a bad one.
    mloncaric

    Član

    .::. 14/02/2006, ob 12:34

    To sn zdaj za trenutek opustil. Zdaj sem ta predvajalnik spravil izven accordiona, pa ga bom probal celega za zacetek imet z tree, datagrid, in mediacontrollerjem. Ko bo to delovalo, bom pa zacel prilagajat al v tree al pa v datagrid komponente.

    mloncaric

    Član

    .::. 19/02/2006, ob 23:05

    Najlepsa hvala za vso pomoc!

    Stran si lahko ogledate na tem naslovu:

    http://nothingoverbeer.slohosting.com/

    Sicer je se nedokoncana, ampak za ogled bo...

    LP

    Miran


    mloncaric

    Član

    .::. 20/02/2006, ob 12:47

    Pozdravljeni! Spet jaz...

    Imam en problem, ko z flashom iz diska dostopam do neke mp3 datoteke, posnete na enem serverju, mi to izbramo pesem predvaja, ko pa flash uploadam na server, da bi stran delovala, pa mi nikakor noce predvajati iste datoteke...
    MediaController in MediaDisplay imata ze oba vgrajen netstream in netconnection, toraj tega ne rabim posamicno pisat...
    Mogoce je problem v zvezi z System.security.*;//tu sn dal vec opcij, kot so allowDomain itd na link:
    http://nothingoverbeer.slohosting.com/
    ...po mojem je to edino, kar bi lahko bilo, ker mi na disku zmeraj opozorijo tiste nastavitve, in ga delno onemogocijo...

    Ce imate kaksno idejo, bi bila zelo dobrodoslja.

    LP

    [BISI]

    Administrator

    .::. 20/02/2006, ob 16:14

    Vprasanje, ce prebavi celoten url... Kaj se zgodi, ce vpises le domeno?

    System.security.allowDomain("slohosting.com");
    Life is a workaround...a bad one.
    mloncaric

    Član

    .::. 21/02/2006, ob 12:57

    Hm...to se nisn probal. Samo, ce spletno stran zazenem na svojem pcji, pa stran deluje. Pa sn v xml datotki dal link do pesmi na domeno in malo pa ime datoteke, in deluje. Na netu pa ne.

    Forum> programje & tehnika> Flash predvajalnik glasbe
     

    Skok na: