Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-20-2012, 01:12 AM   PM User | #1
ansipants
New to the CF scene

 
Join Date: Nov 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
ansipants is an unknown quantity at this point
XML/Java Help

I'm working on a video player that pulls from an xml playlist. So far I have it success fully pulling from the following xml structure:

course
chapter - looping object
title (video title)
screen (video location and type)
description (description of video)
/chapter
/course

Here is what I would like to do, but am having difficulty understanding how to set it up properly:

course
courseinfo label=" "
chapter label =" "
screen label = " " (instead of title) path= " " (url to file) type="video/mp4" /screen
/chapter
/courseinfo
/course

here is the code that I am using:

Code:
// properties
var XML_PATH = "xml/screens.xml";
var videos_array=new Array();

// init the application
function init()
{
// call loadXML function
loadXML();
}

// XML loading
function loadXML()
{
$.ajax({
type: "GET",
url: XML_PATH,
dataType: "xml",
success: function onXMLloaded(xml)
{


// loop for each item
$(xml).find('chapter').each(function loopingItems(value)
{
// create an object
var obj={title:$(this).find("title").text(), screen:$(this).find("screen").text(), description:$(this).find("description").text()};
videos_array.push(obj);

// append <ul> and video title
$("#playlist2").append('<ul>');
$("#playlist2").append('<a><li id="chapter"><strong>'+obj.title+'</strong></li></a>');
});

// close </ul>
$("#playlist2").append('</ul>');
// append video tag player
$("#player").append('<video width="600" height="300" controls="controls"><source src="'+videos_array[0].screen+'" type="video/mp4" />Your browser does not support the video tag.</video>');
// append description
$("#description").append(videos_array[0].description);

// call addListeners function
addListeners();
}
});
}

// add <li> listener
function addListeners()
{
// loop for each list item
$('#playlist2 li').each(function looping(index)
{
// onclick...
$(this).click(function onItemClick()
{
// empty left column and description
$("#player").empty();
$("#description").empty();
// append video tag
$("#player").append('<video width="600" height="300" controls="controls"><source src="'+videos_array[index].screen+'" type="video/mp4" />Your browser does not support the video tag.</video>');
// append description
$("#description").append(videos_array[index].description);
});
});
}
Also, I want to display the course info lable in a box called #courseinfo.
The player is set up with the video element on top, then I've been trying to put in the courseinfo under that, then the description, then the actual playlist.

any help would be much appreciated

Last edited by VIPStephan; 11-20-2012 at 10:50 AM.. Reason: fixed code BB tags
ansipants is offline   Reply With Quote
Old 11-20-2012, 08:11 AM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,038
Thanks: 197
Thanked 2,411 Times in 2,389 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Java and Javascript are entirely different programming languages, in spite of the confusingly similar names. Rather like Austria and Australia!
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Old 11-20-2012, 12:50 PM   PM User | #3
ansipants
New to the CF scene

 
Join Date: Nov 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
ansipants is an unknown quantity at this point
man this is so frustrating lol. Is there anyway to move this into the right place.
ansipants is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:58 PM.


Advertisement
Log in to turn off these ads.