Order Now AdSolution Sign Up | Login » Bits on the Run Sign Up | Login »

Forums

/

publish XML files from playlists

5 replies [Last post]

Hey I've managed to create php file which publishes the XML what I need. The problem is, however, I'd need this file to be downloadable .xml file..

How can I make one?

Please please! I've read a million zillion tutorials and through the whole forum.. How you guys cannot make a simple tutorials on this since everyone is asking? and even though we're paying customers you only have these arrogant **** here..

PLEASE how to create .XML file from a playlist?

*scratches his head*

First of all, you called us "arrogant **** here" and I don't think that you have enough characters in that part of the sentence for a good swear word. <grin>

Second of all, it is usually not a good idea to be mean to anybody who can help you, especially technical support people. We tend to take simple things very seriously.

But, I have been in your shoes before. I can understand how frustrated you must feel, and I am not going to take your name calling personally.

I fact, I am going to answer your question because I think other readers on this Forum will want to know the answer as well. But, keep in mind that as soon as I give you the answer to this question, you will have additional questions.

Here is how to "create an xml file from a playlist," as you put it.

Copy and paste the following link into your Internet Explorer address bar. (Not in the Google Search Field.) <grin>

http://developer.longtailvideo.com/trac/wiki/FlashFormats#Playlists

As long as you work with the JW Player, you will need to know how to return to this page, so make sure you save this page as a Favorite in your Internet Explorer.

Then go to the Internet Explorer Menu and select Edit > Find On This Page

Type in

XML Playlists

Under XML Playlists, you will see the four playlist feeds that are supported by the JW Player. The JW Player uses each playlist for different purposes, but they each have similarities which are discussed in the Overview found under XML Playlists.

There is also an example of each playlist format in this area. Until you gain more experience with the JW Player, you will probably want to start with the XSPF format. The word

example

is displayed in parenthesis after it says

XSPF feeds.

You can capture the xml file and download it to your computer by right clicking on the word example and clicking "Save Target As."

After you save this xml file to a convenient place on your computer, you will have what you called a "downloadable xml file."

In order to view and make changes to the xspf.xml file, you must use a basic text editor like Notepad. DO NOT use Word, WordPad, WordPerfect or similar word processing software because they will add extra (invisible!) characters to your xml file and make it impossible to troubleshoot any errors that will arise.

If you are feeling adventurous, you might download and install a free xml editor that is compatible with your operating system. There are probably lots of free xml editors, but since I use Windows XP, the one that I use is called

XML Copy Editor

found at

http://xml-copy-editor.sourceforge.net

It takes a little learning curve to learn how to use the XML Copy Editor but it is worth it because that program will allow you to check the "well-formedness" of your xml file. This program will also allow you to "validate" your xml file.

Basically these two options allow XML Copy Editor to help you find and repair little errors that creep in whenever you work on your xml files. But if you are very very very careful when making changes to your xml files, you could get by with Notepad.

The first thing you must do when you download any examples of code, (such as this xspf.xml file) is to make a copy of the original and store the original in a safe place on your computer. Then you should make all your changes only to the copy. That way, when you make mistakes, (and you will!) you can

1. delete the old copy
2. make another copy from the original
3. make your changes to the copy again
4. repeat as necessary until you are successful

The easiest way to open an xml file is by double-clicking on the file with your XML Editor.

If you insist on using good ol' Notepad to edit your xml file, you will need to perform a few more steps.

Open Notepad and then minimize it. Then, instead of right-clicking and saving the xspf.xml file by pointing to the example link shown above, you will need to simply left-click on the example link. This will open the xml file in Internet Explorer. Then you basically highlight and copy the text you see on the page, and then paste this text into your empty Notepad file.

Now the first thing you must do is click File > Save As and save this file to your hard drive as xspf.xml (You should use all small letters when naming this file since certain operating systems consider xspf.xml completely different from XSPF.XML) As we discussed above, save a copy of of this xspf.xml file and make your changes to that file. Then store the original in a safe place.

The next thing you must do if you are using Notepad is to remove the leading dashes in the Page Source manually. Don't search and replace; just remove the leading dashes manually. There is a leading dash in front of the following tags

- <playlist
- <tracklist>
- <track>
- <track>
- <track>
- <track>

these must all be removed. Your new file should look like this when you are finished removing the leading dashes from in front of these tags

<playlist
<tracklist>
<track>
<track>
<track>
<track>

Can you see what a pain it is when you don't use an XML Editor to make changes to your xml files?

In any case, once you open the xspf.xml file, you will see four examples of how the JW Player wants you to format your playlist for different media and graphic files

flv
mp3
png
YouTube

When you view the xspf.xml file in Internet Explorer, it should become obvious what you will need to change to make a new personal xml file that you can use for your JW Player.

In my Internet Explorer, the tags are colored red and blue and the text you can change is bold black.

In my XML Editor, the tags are blue and red and the text you can change is bold black.

If you insist on using Notepad to change your xml files, you are on your own because all the text is black. (When I first started editing xml files, I didn't want to be bothered with downloading and installing yet another program onto my computer, so I compared the Notepad xml file with the Internet Explorer Page Source. Now I use my XML Editor almost all the time.)

Hopefully, you know a little about tags and relative vs absolute file paths and you can make your own changes to the text, because it would take another tutorial to show you how to manage those two things.

Note: one detail that will not be obvious is that you can also add image tags, a path, and a graphic of your choice to the flv track, using the mp3 track as your guide.

There are a lot of resources on the Internet that can show you the basics. For example, after I searched Google under relative paths and absolute paths I found this

http://www.communitymx.com/content/article.cfm?cid=230ad

Obviously, you might want to add many more video or audio tracks to your playlist, but the idea is to use this xspf.xml file as a guide as you make additions and changes to the file.

When you are finished with your xspf.xml file, rename it to something that makes sense to you (perhaps yourplaylist.xml) and then upload it to your domain folders.

After that, all you need to do is to reference your new xml file under the flashvars in your player code

Here is a common example of how to do that

so.addVariable('file','yourplaylist.xml');

In this example, your file called

yourplaylist.xml

is in the root folder of

http://www.yourdomain.com

right next to the index.html, contact-us.html, about-us.html files and so on.

One you get your playlist working, you can move your file called

yourplaylist.xml

into any other folder on the same domain as your player, as long as you know the path to that folder, and can type the path into the file flashvar shown above. (See Troubleshooting Below.)

For example, if you move your file called

yourplaylist.xml

from the root folder of your domain into a folder called

playlists

under your domain

http://www.yourdomain.com

you would change the file flashvar to read

so.addVariable('file','/playlists/yourplaylist.xml');

Does this make sense to you?

Troubleshooting:

Keep these two things in mind, while trouble-shooting your xml file

You must be doing your trouble-shooting on your live website, not locally, on your own computer. The type of Flash we are using for the JW Player is restricted from running on your local computer.

The videoplayer on one domain cannot load a playlist from another domain. For example, in order for your new playlist to work, all your player files must be stored in folders at only one of your domains.

If you have the player files (player.swf and swfobject.js) stored in folders at

http://www.yourdomain.com

and you have the video, music, graphic and xml files (flv, mp3, png, xml) stored in folders at

http://www.yourdomain.net

your playlist will not work, unless you use a special file called crossdomain.xml both of which are discussed here

http://developer.longtailvideo.com/trac/wiki/FlashSecurity

Even if you know what you are doing, the crossdomain.xml file can be difficult to set up correctly.

If anyone has anything to add, please feel free to add to this post.

That's brilliant. Really helpful and also made me laugh a very lot :-)

This is one of the best tutorials i have ever read, and I have read a lot of training materials over the past 25 years. Thank you very much for the clear explanation and the thorough coverage. Your willingness to explain why one approach is better than another is what makes this such a good tutorial.

Thank you Are We There Yet for a wonderful post!!