⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xspfparser.as

📁 本人做的Flash播放器源码,仅供大家参考并扩展
💻 AS
字号:
/**
* Parses ATOM feeds and returns an indexed array with all elements.
*
* @author	Jeroen Wijering
* @version	1.4
**/


import com.jeroenwijering.feeds.AbstractParser;
import com.jeroenwijering.utils.StringMagic;


class com.jeroenwijering.feeds.XSPFParser extends AbstractParser {


	/** Contructor **/
	function XSPFParser() { super(); };


	/** build an array with all regular elements **/
	private function setElements() {
		elements = new Object();
		elements["title"] = "title";
		elements["creator"] = "author";
		elements["info"] = "link";
		elements["image"] = "image";
		elements["identifier"] = "id";
		elements["album"] = "category";
	};


	/** Convert ATOM structure to array **/
	private function parse(xml:XML):Array {
		var arr = new Array();
		var tpl = xml.firstChild.firstChild;
		while(tpl != null) { 
			if (tpl.nodeName == 'trackList') {
				for(var i=0; i<tpl.childNodes.length; i++) {
					var obj = new Object();
					for(var j=0; j<tpl.childNodes[i].childNodes.length; j++) {
						var nod:XMLNode = tpl.childNodes[i].childNodes[j];
						var nnm = nod.nodeName.toLowerCase();
						if(elements[nnm]!=undefined) {
							obj[elements[nnm]] = nod.firstChild.nodeValue;
						} else if(nnm == "location"  && obj['type']!="flv") {
							obj["file"] = nod.firstChild.nodeValue;
							var typ = obj["file"].substr(-3).toLowerCase();
							if(obj["file"].substr(0,4) == "rtmp") {
								obj["type"] = "rtmp";
							} else if(mimetypes[typ] != undefined) {
								obj["type"] = mimetypes[typ];
							}
						} else if(nnm == "annotation") {
							obj["description"] = StringMagic.stripTagsBreaks(
								nod.firstChild.nodeValue);
						} else if(nnm == "link" && 
							nod.attributes.rel == "captions") {
							obj["captions"] = nod.firstChild.nodeValue;
						} else if(nnm == "link" && 
							nod.attributes.rel == "audio") {
							obj["audio"] = nod.firstChild.nodeValue;
						} else if(nnm == "meta" && 
							nod.attributes.rel == "start") {
							obj["start"] = nod.firstChild.nodeValue;
						} else if(nnm == "meta" &&
							nod.attributes.rel == "type") {
							obj["type"] = nod.firstChild.nodeValue;
						}
					}
					arr.push(obj);
				}
			}
			tpl = tpl.nextSibling;
		}
		return arr;
	};


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -