Copy link to clipboard
Copied
Hi
I have a videoplayer that loads video from xml and players it. The code works well when loading the xml.
But because I need it to run the video on the server I user php code that echos xml to access videos:
$selectvideos=mysql_query("SELECT * FROM Videos");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
echo "<playlist id=\"output applications\">\n";
while($milo=mysql_fetch_assoc($selectvideos))
{
$title=$milo['title'];
$desc=$milo['desc'];
$src=$milo['video'];
$thumbphoto=$milo['thumb'];
echo '<vid Title="'.$title.'" Description="'.$desc.'" src="'.$src.'" thumb="'.$thumbphoto.'" />'."\n";
}
echo "</playlist>\n";
I then have actionscript:
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.text.TextFormat;
import fl.controls.TextArea;
public class VideoPlaylist extends MovieClip {
private var xmlLoader:URLLoader;
private var textStyle:TextFormat;
private var description:TextArea;
public var str:String;
var stream:Array = new Array();
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("testflow.php"));
///////////////
}
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.
stream.push({label:item.attribute("Title").toXMLString(),str:item.attribute("Description").toXMLString(),
data:item.attribute("src").toXMLString(),
source:thumb});
}
myVid.source=stream[0].data;
// Pause video until selected or played.
myVid.play();
}
}
}
The action script is suppose to play the file loaded by xml and plays it on videoplayer.
The xml works well but when using the php above this error pops up:
TypeError: Error #1085: The element type "param" must be terminated by the matching end-tag "</param>".
at VideoPlaylist/initMediaPlayer()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
1 Correct answer
ok, now use the code i suggested.
Copy link to clipboard
Copied
use the trace function (or a textfield if you can't see traces) to see the xml you're trying to load.
Copy link to clipboard
Copied
Hi thank you for reply. When you mean trace function i.e trace(xml.Loader);
or you mean some thing else, not very clear.
The error is now: [object URLLoader]
TypeError: Error #1085: The element type "param" must be terminated by the matching end-tag "</param>".
at VideoPlaylist/initMediaPlayer()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
Thanks.
Copy link to clipboard
Copied
no:
public function initMediaPlayer(event:Event):void {
trace(xmlLoader.data);
var myXML:XML=XML(xmlLoader.data);
var item:XML;
for each (item in myXML.vid) {// populate playlist.
Copy link to clipboard
Copied
Hi this is the xml traces and they is also some text from the php file.
<?xml version="1.0" encoding="UTF-8" ?>
<playlist id="output applications">
<vid Title="First video" Description="This is the first expishare video to run on the system. Okay." src="Videos/robot.flv" thumb="Thumb/robot.png" />
</playlist>
The error is:
TypeError: Error #1085: The element type "param" must be terminated by the matching end-tag "</param>".
at VideoPlaylist/initMediaPlayer()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
The weird thing is that the code works with just xml.
Thanks.
Copy link to clipboard
Copied
what do you mean there is some text from the php file?
copy and paste the entire result of that trace().
Copy link to clipboard
Copied
Hi thanks for the reply. Greatly appreciant.
This is what the trace outputs.
<?xml version="1.0" encoding="UTF-8" ?>
<playlist id="output applications">
<vid Title="First video" Description="This is the first expishare video to run on the system. Okay." src="Videos/robot.flv" thumb="Thumb/robot.png" />
</playlist>
<html>
<head>
<title>Video Upload Form</title>
<body>
<form method="POST" name="frmVideoUpload" enctype="multipart/form-data" action="">
<p>Video: </p>
<p>
<input type="file" name="filename" />
<br/>
<input type="submit" name="cmdSubmit" value="Upload" />
</p>
</form>
<br/>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="500" height="400" title="Player">
<param name="movie" value="UP-MODE.swf">
<param name="quality" value="high">
<embed src="UP-MODE.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="500" height="400"></embed>
</object>
</body>
</html>
TypeError: Error #1085: The element type "param" must be terminated by the matching end-tag "</param>".
at VideoPlaylist/initMediaPlayer()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
Copy link to clipboard
Copied
that's the problem. all that html flash thinks is xml.
use:
kglad wrote:
no:
public function initMediaPlayer(event:Event):void {
var s:String=xmlLoader.data.substring(0,xmlLoader.data.indexOf("<html>"));
var myXML:XML=XML(s);
var item:XML;
for each (item in myXML.vid) {// populate playlist.
Copy link to clipboard
Copied
Hi
I really appreciate the help. I have modified the code to:
public function initMediaPlayer(event:Event):void {
var s:String=xmlLoader.data.substring(0,xmlLoader.data.indexOf("<html>")) ;
trace(xmlLoader.data);
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.
stream.push({label:item.attribute("Title").toXMLString(),str:item.attribute("Description").toXMLString(),
data:item.attribute("src").toXMLString(),
source:thumb});
}
On the function the current error is now:
<?xml version="1.0" encoding="UTF-8" ?>
<playlist id="output applications">
<vid Title="First video" Description="This is the first expishare video to run on the system. Okay." src="http://www.expishare.com/Videos/robot.flv" thumb="Thumb/robot.png" />
</playlist>
TypeError: Error #1088: The markup in the document following the root element must be well-formed.
at VideoPlaylist/initMediaPlayer()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
What could I do. Please assist.
thank you.
Copy link to clipboard
Copied
that can't be the trace() output unless you changed your php. did you?
Copy link to clipboard
Copied
Hi This is the actual trace:
<?xml version="1.0" encoding="UTF-8" ?>
<playlist id="output applications">
<vid Title="First video" Description="This is the first expishare video to run on the system. Okay." src="http://www.example.com/Videos/robot.flv" thumb="Thumb/robot.png" />
</playlist>
<html>
<head>
<title>Video Upload Form</title>
<body>
<form method="POST" name="frmVideoUpload" enctype="multipart/form-data" action="">
<p>
Video: </p>
<p>
<input type="file" name="filename" />
<br/>
<input type="submit" name="cmdSubmit" value="Upload" />
</p>
</form>
</body>
</html>
TypeError: Error #1085: The element type "head" must be terminated by the matching end-tag "</head>".
at VideoPlaylist/initMediaPlayer()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
All I need the player to do is get the xml output playing in the player.
As it would do with a .xml
Thank
Copy link to clipboard
Copied
ok, now use the code i suggested.
Copy link to clipboard
Copied
Hi
In four words: YOU ARE A LEGEND.
Thank you so much::::
Copy link to clipboard
Copied
you're welcome.
Copy link to clipboard
Copied
Hello Kglad
Thanks again for all the help. One thing I need help with is that I have tried to incorparate a tile into my project and have run into
some problems getting the code running.
This is the .as code:
public function initMediaPlayer(event:Event):void {
var s:String=xmlLoader.data.substring(0,xmlLoader.data.indexOf("<html>")) ;
var myXML:XML=new XML(s);
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.
tileList.addItem({label:item.attribute("Title").toXMLString(),str:item.attribute("Description").toXMLString(),
data:item.attribute("src").toXMLString(),
source:thumb});
}
// Select the first video.
tileList.selectedIndex=0;
// Listen for item selection.
tileList.addEventListener(Event.CHANGE, listListener);
// And automatically load it into myVid.
myVid.source=tileList.selectedItem.data;
// Pause video until selected or played.
myVid.play();
}
The only difference from the last time you helped. Is the the tileList included in the code. For some reason I get this output error:
RangeError: DataProvider index (0) is not in acceptable range (0 - -1)
at fl.data::DataProvider/checkIndex()
at fl.data::DataProvider/getItemAt()
at fl.controls::SelectableList/get selectedItem()
at VideoPlaylist/initMediaPlayer()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
Do you think you can help. Thanks
Copy link to clipboard
Copied
use the trace function to see that index.
Copy link to clipboard
Copied
Hello
I just tried
trace(s);
After: var s:String=xmlLoader.data.substring(0,xmlLoader.data.indexOf("<html>")) ;
And recieved the same result.
Thanks.
Copy link to clipboard
Copied
not, there.
click file/publish settings/flash and tick "permit debugging". retest. the problematic line of code will be in the error message. indicate that line in this thread.
Copy link to clipboard
Copied
Hey kglad
I have changed the debug settings and this is now the output:
RangeError: DataProvider index (0) is not in acceptable range (0 - -1)
at fl.data::DataProvider/checkIndex()
at fl.data::DataProvider/getItemAt()
at fl.controls::SelectableList/get selectedItem()
at VideoPlaylist/initMediaPlayer()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
The code area in VideoPlaylist.as
// Select the first video.
60. tileList.selectedIndex=0;
// Listen for item selection.
62. tileList.addEventListener(Event.CHANGE, listListener);
// And automatically load it into myVid.
64. myVid.source=tileList.selectedItem.data;
// Pause video until selected or played.
myVid.play();
Thank you.
Copy link to clipboard
Copied
mabe you're not adding anythig to your tilelist. test that by using:
public function initMediaPlayer(event:Event):void {
var s:String=xmlLoader.data.substring(0,xmlLoader.data.indexOf("<html>")) ;
var myXML:XML=new XML(s);
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.
trace("added data",item.attribute("src").toXMLString());
tileList.addItem({label:item.attribute("Title").toXMLString(),str:ite m.attribute("Description").toXMLString(),
data:item.attribute("src").toXMLString(),
source:thumb});
}
// Select the first video.
tileList.selectedIndex=0;
// Listen for item selection.
tileList.addEventListener(Event.CHANGE, listListener);
// And automatically load it into myVid.
myVid.source=tileList.selectedItem.data;
// Pause video until selected or played.
myVid.play();
}
Copy link to clipboard
Copied
Hi
I am not sure if the data is getting lost some where in the code. But trace is outputing the same error:
RangeError: DataProvider index (0) is not in acceptable range (0 - -1)
at fl.data::DataProvider/checkIndex()
at fl.data::DataProvider/getItemAt()
at fl.controls::SelectableList/get selectedItem()
at VideoPlaylist/initMediaPlayer()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
This is the modified .as
public function initMediaPlayer(event:Event):void {
var s:String=xmlLoader.data.substring(0,xmlLoader.data.indexOf("<html>"));
var myXML:XML=new XML(s);
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.
trace("added data",item.attribute("src").toXMLString());
tileList.addItem({label:item.attribute("Title").toXMLString(),str:item.attribute("Description").toXMLString(),
data:item.attribute("src").toXMLString(),
source:thumb});
}
// Select the first video.
tileList.selectedIndex=0;
// Listen for item selection.
tileList.addEventListener(Event.CHANGE, listListener);
// And automatically load it into myVid.
myVid.source=tileList.selectedItem.data;
// Pause video until selected or played.
myVid.play();
}
Thanks again.
Copy link to clipboard
Copied
and that confirms what i stated: you're not adding anything to your tilelist.
use the trace() function. see if you're loading that xml. and if you are, see if you're parsing it correctly.
Copy link to clipboard
Copied
Hi
You where write the xml had not been loaded the php file had a bugs. I fixed the bug and re tried. The same error came out. Because
the php that loads the xml was on a remote server I tried to add the exact directory of the videos. The same error happened.
I then kept trying to use trace("added data",item.attribute("src").toXMLString());
to see if any data came out without any luck.
tileList.addItem({label:item.attribute("Title").toXMLString(),str:item.attribute("Description").toXMLString(),
data:item.attribute("src").toXMLString(),
source:thumb});
Above code is surpose to add the data to the tileList and below is the
echoed xml:
<?xml version="1.0" encoding="UTF-8" ?>
<playlist id="output applications">
<vid Title="Test video" Description="This is the first expishare video to run on the system. Okay." src="http://www.example.com/Videoscroll/Videos/robot.flv" thumb="http://www.example.com/Videoscroll/Thumb/robot.png" />
</playlist>
I dont get why the trace is not displaying the loaded data. Weird. Still trying and working at solving the problem. Still hope
you can assist.
Copy link to clipboard
Copied
if you're not loading anything from your php, you need to debug your php. have it echo a simple string.
Copy link to clipboard
Copied
Hi There
I have made massive debug progress I think. The only reason I say this is because the error output has changed to:
TypeError: Error #1088: The markup in the document following the root element must be well-formed.
at VideoPlaylist/initMediaPlayer()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
The php/html:
<?Php
include("connect.php");
$moid=$_GET['expid'];
$selectvideos=mysql_query("SELECT * FROM Videos ");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
echo "<playlist id=\"output applications\">\n";
while($milo=mysql_fetch_assoc($selectvideos))
{
$title=$milo['title'];
$desc=$milo['desc'];
$src=$milo['video'];
$thumbphoto=$milo['thumb'];
echo '<vid Title="'.$title.'" Description="'.$desc.'" src="'.$src.'" thumb="'.$thumbphoto.'" />'."\n";
}
echo "</playlist>\n";
?>
<html>
<head>
<title>Video Upload Form</title>
<body>
<form method="POST" name="frmVideoUpload" enctype="multipart/form-data" action="">
<p>
Video: </p>
<p>
<input type="file" name="filename" />
<br/>
<input type="submit" name="cmdSubmit" value="Upload" />
</p>
</form>
<br/>
<br/>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="500" height="400">
<param name="movie" value="UP-MODE.swf">
<param name="quality" value="high">
<embed src="UP-MODE.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="500" height="400"></embed>
</object>
</body>
</html>
-
- 1
- 2