Tadpole1981
06-12-2008, 11:58 PM
I have created a video player to house 4 different categories of videos. The categories are each represented by a button. The player sits to the left of the four buttons and to the right of the four buttons is the list of videos for each category.
I want to have it so that each button loads a different XML playlist (in the area to their right) when clicked.
I have the buttons loading each new playlist, but they are not clearing out the previous playlists so the new lists are just being added to the bottom of the list.
In addition when the video is playing and you click on a new category the video stops and I would like it to keep playing until a new video is selected from the playlist.
I know that there is something that I am just not seeing here and I need a fresh set of eyes. Please help!
Thanks!
Here is my code:
package {
import flash.display.MovieClip;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
import fl.controls.listClasses.CellRenderer;
import fl.controls.ScrollBarDirection;
import flash.display.SimpleButton;
import flash.events.MouseEvent;
public class VideoPlaylist extends MovieClip {
private var xmlLoader:URLLoader;
public function VideoPlaylist():void {
// Load the playlist file, then initialize the media player.
xmlLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, initMediaPlayer);
xmlLoader.load(new URLRequest("playlist-streaming.xml"));
FeaturedVidButt_btn.addEventListener(MouseEvent.MO USE_UP, loadMe);
function loadMe (e:MouseEvent)
{
xmlLoader.load(new URLRequest("playlist-streaming.xml"));
}
v21Button_btn.addEventListener(MouseEvent.MOUSE_UP , loadMeTwo);
function loadMeTwo (e:MouseEvent)
{
xmlLoader.load(new URLRequest("playlist-streaming-2_1.xml"));
}
LowEnergyButton_btn.addEventListener(MouseEvent.MO USE_UP, loadMeThree);
function loadMeThree (e:MouseEvent)
{
xmlLoader.load(new URLRequest("playlist-streaming-LowEnergy.xml"));
}
IconsButton_btn.addEventListener(MouseEvent.MOUSE_ UP, loadMeFour);
function loadMeFour (e:MouseEvent)
{
xmlLoader.load(new URLRequest("playlist-streaming-Icons.xml"));
}
// Format the tileList, specify its cellRenderer class.
theList.setSize(170, 315);
theList.columnWidth = 155;
theList.rowHeight = 140;
theList.direction = ScrollBarDirection.VERTICAL;
theList.setStyle("cellRenderer", Thumb);
}
public function initMediaPlayer(event:Event):void {
var myXML:XML = new XML(xmlLoader.data);
var item:XML;
for each(item in myXML.vid) { // populate playlist.
// Get thumbnail value and assign to cellrenderer.
var thumb:String;
if(item.hasOwnProperty("@thumb")>0) thumb = item.@thumb;
// Send data to tileList.
theList.addItem({label:item.attribute("desc").toXMLString(),
data:item.attribute("src").toXMLString(),
source:thumb});;
}
// Listen for item selection.
theList.addEventListener(Event.CHANGE, listListener);
// Select the first video.
theList.selectedIndex = 0;
// And automatically load it into myVid.
myVid.source = theList.selectedItem.data;
// Pause video until selected or played.
myVid.pause();
// Listen for buttons selected
}
// Detect when new video is selected, and play it
function listListener(event:Event):void {
myVid.play(event.target.selectedItem.data);
}
}
}
I want to have it so that each button loads a different XML playlist (in the area to their right) when clicked.
I have the buttons loading each new playlist, but they are not clearing out the previous playlists so the new lists are just being added to the bottom of the list.
In addition when the video is playing and you click on a new category the video stops and I would like it to keep playing until a new video is selected from the playlist.
I know that there is something that I am just not seeing here and I need a fresh set of eyes. Please help!
Thanks!
Here is my code:
package {
import flash.display.MovieClip;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
import fl.controls.listClasses.CellRenderer;
import fl.controls.ScrollBarDirection;
import flash.display.SimpleButton;
import flash.events.MouseEvent;
public class VideoPlaylist extends MovieClip {
private var xmlLoader:URLLoader;
public function VideoPlaylist():void {
// Load the playlist file, then initialize the media player.
xmlLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, initMediaPlayer);
xmlLoader.load(new URLRequest("playlist-streaming.xml"));
FeaturedVidButt_btn.addEventListener(MouseEvent.MO USE_UP, loadMe);
function loadMe (e:MouseEvent)
{
xmlLoader.load(new URLRequest("playlist-streaming.xml"));
}
v21Button_btn.addEventListener(MouseEvent.MOUSE_UP , loadMeTwo);
function loadMeTwo (e:MouseEvent)
{
xmlLoader.load(new URLRequest("playlist-streaming-2_1.xml"));
}
LowEnergyButton_btn.addEventListener(MouseEvent.MO USE_UP, loadMeThree);
function loadMeThree (e:MouseEvent)
{
xmlLoader.load(new URLRequest("playlist-streaming-LowEnergy.xml"));
}
IconsButton_btn.addEventListener(MouseEvent.MOUSE_ UP, loadMeFour);
function loadMeFour (e:MouseEvent)
{
xmlLoader.load(new URLRequest("playlist-streaming-Icons.xml"));
}
// Format the tileList, specify its cellRenderer class.
theList.setSize(170, 315);
theList.columnWidth = 155;
theList.rowHeight = 140;
theList.direction = ScrollBarDirection.VERTICAL;
theList.setStyle("cellRenderer", Thumb);
}
public function initMediaPlayer(event:Event):void {
var myXML:XML = new XML(xmlLoader.data);
var item:XML;
for each(item in myXML.vid) { // populate playlist.
// Get thumbnail value and assign to cellrenderer.
var thumb:String;
if(item.hasOwnProperty("@thumb")>0) thumb = item.@thumb;
// Send data to tileList.
theList.addItem({label:item.attribute("desc").toXMLString(),
data:item.attribute("src").toXMLString(),
source:thumb});;
}
// Listen for item selection.
theList.addEventListener(Event.CHANGE, listListener);
// Select the first video.
theList.selectedIndex = 0;
// And automatically load it into myVid.
myVid.source = theList.selectedItem.data;
// Pause video until selected or played.
myVid.pause();
// Listen for buttons selected
}
// Detect when new video is selected, and play it
function listListener(event:Event):void {
myVid.play(event.target.selectedItem.data);
}
}
}