I currently found a script that dynamically loads an ASX playlist, allowing the user to choose the item that he wants to watch in Windows media player embedded.
The trouble is that once the user click on the link in the playlist it wont work.
Take a look here http://tv.mghospedagem.com/wmp-pl3.html
Works only on IE. - <head>
-
<script language="javascript1.2">
-
-
playListLoaded=false;
-
-
-
function loadPlayItems() {
-
df=document.getElementById("playItem");
-
dp=document.getElementById("playlist");
-
WMP9=document.getElementById("MediaPlayer1");
-
-
WMP9.url="http://tv.mghospedagem.com/play.asx";
-
WMP9.controls.play();
-
-
}
-
-
function showPlayItems() {
-
WMP9=document.getElementById("MediaPlayer1");
-
playlistItems=WMP9.currentPlaylist.count;
-
for (i=0; i<playlistItems; i++) {
-
playitem=document.createElement("a");
-
playnext=document.createElement("br");
-
playitem.setAttribute("href","#");
-
playitem.setAttribute("onclick","playItem("+i+")");
-
playitem.innerText=WMP9.currentPlaylist.item(i).name;
-
dp.appendChild(playitem);
-
dp.appendChild(playnext);
-
}
-
playListLoaded=true;
-
WMP9.controls.play();
-
-
}
-
-
-
-
function setPlayItem(index) {
-
WMP9=document.getElementById("MediaPlayer1");
-
playlistItems=WMP9.currentPlaylist.count;
-
if (playlistItems > 0) {
-
-
WMP9.controls.currentItem=WMP9.currentPlaylist.item(index);
-
WMP9.controls.play();
-
}
-
}
-
-
</script></head>
-
-
<body onLoad="loadPlayItems()">
-
<object id="MediaPlayer1"
-
classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6"
-
type="application/x-oleobject" width="600" height="400">
-
<param name="autostart" value="1">
-
<param name="showcontrols" value="1">
-
<param name="uimode" value="full">
-
<param name="stretchtofit" value="1">
-
<param name="enablecontextmenu" value="0">
-
</object>
-
-
<div id="playlist" style="position: absolute; top: 10px; left:
-
640px; visibility: visible; z-index: 999999999999999;">
-
<h2>Playlist</h2></div>
-
-
<script language="javascript1.2" for="MediaPlayer1"
-
event="playStateChange">
-
WMP9=document.getElementById("MediaPlayer1");
-
if (WMP9.playState==3 && ! playListLoaded) {
-
showPlayItems();
-
}
-
-
-
-
-
-
-
</script>
-
-
22 2751
That's the first time that anyone help me here. That script problem must be a really hard issue to solve.
So, how can I use this information to help on my issue?
The following text is from another source:
Hi Chopz,
That's an interesting hack, but it relies on browser sniffing, which is best avoided if possible. There are a couple of other solutions to this problem, the simplest is to add event.returnValue = false to make it work in IE: -
<a href="#" onclick="doSomething(); event.returnValue = false; return false;">click me</a>
-
And then there is the much more convoluted but more OOP method of attaching events at onLoad (which of course requires harvesting the element/s to change and using different methods for IE and everyone else): -
-
function preventDefaultAction(evt) {
-
if (evt) {
-
if (typeof evt.preventDefault!= 'undefined') {
-
evt.preventDefault(); // W3C
-
} else {
-
evt.returnValue = false; // IE
-
}
-
}
-
// safey for handling DOM Level 0
-
return false;
-
}
-
-
function doSomething(evt) {
-
alert('do something cool');
-
return preventDefaultAction(evt);
-
}
-
function init() {
-
var target = document.getElementById('target');
-
if (target.addEventListener) { // use addEventListener for DOM
-
target.addEventListener('click', doSomething, false);
-
} else if (target.attachEvent) { // use attachEvent for IE
-
target.attachEvent('onclick', doSomething);
-
}
-
}
-
and the HTML -
-
<body onLoad="init()">
-
<div id="scrollbox"></div>
-
<p>If you have JS enabled, the page should not scroll to the top when you <a id="target" href="#">click this link</a>.</p>
-
</body>
-
HTH, Scott
I've been on this for weeks (In the beginning the issue was the player itself), someone lead me some light, please =/
acoder 16,027
Recognized Expert Moderator MVP
playItem() needs to be a function and I don't see it anywhere. Also, I would avoid naming elements and functions with the same name.
PS. merged threads.
Hi sir, what do you mean with "playItem() needs to be a function and I don't see it anywhere"?
U mean that the funcition is not being used by Internet Explorer anymore?
----- EDITING ----
I'm sorry, I've read "anymore", instead of "anywhere".
acoder 16,027
Recognized Expert Moderator MVP
The line which is causing problems: - playitem.setAttribute("onclick","playItem("+i+")");
translates as onclick="playItem(0)" , onclick="playItem(1)" and so on depending on the number of items in the play list.
I cant use numbers, cause it's asx playlist with more than 800 itens, it is loaded and showed dynamicaly, just the links wont wokr once u click them.
So it will be like this? - function showPlayItems() {
-
WMP9=document.getElementById("MediaPlayer1");
-
playlistItems=WMP9.currentPlaylist.count;
-
for (i=0; i<playlistItems; i++) {
-
playitem=document.createElement("a");
-
playnext=document.createElement("br");
-
playitem.setAttribute("href","javascript:void(0)");
-
onclick="playItem("+i+")";
-
playitem.innerText=WMP9.currentPlaylist.item(i).name;
-
dp.appendChild(playitem);
-
dp.appendChild(playnext);
-
}
-
playListLoaded=true;
-
WMP9.controls.play();
-
-
}
acoder 16,027
Recognized Expert Moderator MVP
No, it can't be like that. If anything, it'd be something like: - playitem.onclick = function() { playItem(i) };
This will still not work because you haven't defined the function playItem().
You mention about not being able to use numbers. Well, then you need to tell us exactly what you can use.
I mentioned number because there is an +i+, I didnt see any zero, or one, 2, 3. So I thought the developer used that to show that the script will play only what is loaded dynamicaly from the P LIst.
acoder 16,027
Recognized Expert Moderator MVP
If you follow the code, you'll see that i is in fact a variable counter holding a number - see this line: - for (i=0; i<playlistItems; i++) {
It starts at 0 until the number of play list items.
Anyway, until you don't define playItems as a function, it's simply not going to work and you should see errors in your error console.
I'd like to thank you again for ur great help. thx for the support. Here is what I tried now: -
-
function showPlayItems() {
-
WMP9=document.getElementById("MediaPlayer1");
-
playlistItems=WMP9.currentPlaylist.count;
-
for (i=0; i<playlistItems; i++) {
-
playitem=document.createElement("a");
-
playnext=document.createElement("br");
-
playitem.setAttribute("href","#");
-
// onclick="playItem("+i+")";
-
playitem.innerText=WMP9.currentPlaylist.item(i).name;
-
dp.appendChild(playitem);
-
dp.appendChild(playnext);
-
}
-
playListLoaded=true;
-
WMP9.controls.play();
-
-
}
-
-
}
-
playitem.onclick = function() {
-
-
-
-
-
WMP9=document.getElementById("MediaPlayer1");
-
playlistItems=WMP9.currentPlaylist.count;
-
for (i=0; i<playlistItems; i++) {
-
playitem=document.createElement("a");
-
playnext=document.createElement("br");
-
playitem.setAttribute("href","#");
-
playItem(+i+) }; // onclick="playItem("+i+")";
-
playitem.innerText=WMP9.currentPlaylist.item(i).name;
-
dp.appendChild(playitem);
-
dp.appendChild(playnext);
-
}
-
playListLoaded=true;
-
WMP9.controls.play();
-
-
-
-
-
-
-
{
-
The error is on <body onLoad="loadPlayItems()">
error name: Object Expected.
acoder 16,027
Recognized Expert Moderator MVP
OK, that's not correct. Before we proceed any further, where did you get the original code from or did you write it yourself?
acoder 16,027
Recognized Expert Moderator MVP
Having had a better look at your code, I see that you misnamed the function (or the person you copied from).
On line 24 in your original code, the code needs to refer to setPlayItem(i) - the function defined on line 36, not playItem(i).
I did this -
-
function showPlayItems() {
-
WMP9=document.getElementById("MediaPlayer1");
-
playlistItems=WMP9.currentPlaylist.count;
-
for (i=0; i<playlistItems; i++) {
-
setPlayItem=document.createElement("a");
-
playnext=document.createElement("br");
-
setPlayItem.setAttribute("href","#");
-
setPlayItem.setAttribute("onclick","playItem("+i+")");
-
setPlayItem.innerText=WMP9.currentPlaylist.item(i).name;
-
dp.appendChild(playitem);
-
dp.appendChild(playnext);
-
}
-
playListLoaded=true;
-
WMP9.controls.play();
-
-
}
Nothing worked, and the playlist wont load the itens dinamicaly.
acoder 16,027
Recognized Expert Moderator MVP
I didn't meant the variable playitem (note the lower-case), I meant the function called onclick on line 24 (post #1) playItem() (upper-case I).
Badly named variables/functions anyway.
Ahhh... lol
I'll take a look on that
=D
What am I doing wrong? I tried this - function showPlayItems() {
-
WMP9=document.getElementById("MediaPlayer1");
-
playlistItems=WMP9.currentPlaylist.count;
-
for (i=0; i<playlistItems; i++) {
-
playitem=document.createElement("a");
-
playnext=document.createElement("br");
-
playitem.setAttribute("href","#");
-
-
-
playitem.setAttribute("onclick","setPlayItem("+i+")");
-
-
-
playitem.innerText=WMP9.currentPlaylist.item(i).name;
-
dp.appendChild(playitem);
-
dp.appendChild(playnext);
-
}
-
playListLoaded=true;
-
WMP9.controls.play();
-
-
}
-
I still cant make the click work.
acoder 16,027
Recognized Expert Moderator MVP
So what happens now? Do you get any errors?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Jim |
last post by:
Hey guys
I DESPERATLY need some help with this small javascript i have on this
website. All that it's supposed to do is change the button image once
it's pressed but alas... I copy-pasted the code as it was given to me
from Imageready but it won't work. The event that i wanted (and
"created" with Imageready) was ondown. The code is this:...
|
by: Mark |
last post by:
the Following bit of code doesn't work.
It seems to respond to the second, starting with 'add iif statement
for Good Practice', but not to the first, starting 'add iif statement
for archived'
Help me to sort this out, it has taken me almost a week to wade
through and it still won't work.
Select Case Forms("frmForce").OpenArgs
|
by: Chad |
last post by:
I have a link (.ascx) and that generates an Add form on that page. The
autopostback dropdown is within a "If Not IsPostBack Then" statement.
The form that is created is all via static html in the user control.
The problem is, no matter what even when no data is filled out in the
form, the submit button just postsback the page and nothing...
|
by: simon |
last post by:
I have simple html(aspx) page, but vertical height won't work.
Even if i had set the height of a table=100%, the table is not 100% height.
I spend a lot of time(my real page is more complicated) to figured it out that this won't work because of attribute of a page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"...
|
by: musosdev |
last post by:
Hi guys
Okay, I've setup my projects to open and compile fine in VS2005 using FPSE
and remote web, but it's *really* slow. So I thought I'd have a go at doing
it the normal way, by loading from the network share.
It loads in VS2005 fine, and I can edit and save code changes etc, but when
I try and Build the solution, I get the following...
| |
by: b. hotting |
last post by:
Hi,
I don't see why this won't work,
it are 3 links, the last one (a get) does work, but the first 2 won't.
i would like to use a post, through hidden input types
any idea?
thanks for your help!
bjorn
|
by: Eran.Yasso |
last post by:
Hi,
I have project that automate excel(using Excel COM) which works fine
in my home.
I took the project from my home to work and tried to build the project
but it won't built.
I get error "The type or namespace name 'Excel' could not be found".
the error points to line in my code: "public Excel.Application
ExcelObj = null".
|
by: pplers |
last post by:
it's an example. I want a script to print the real url behind a lix.in one
so i tried these:
use LWP::UserAgent;
use LWP::UserAgent;
my $ua = new LWP::UserAgent;
my $response = $ua->post('http://lix.in/53fe67',{ tiny => '53fe67', submit => 'continue',});
my $con = $response->content;
|
by: justabeginner |
last post by:
First of all, let me say I've had very little training in html and probably know just enough to be dangerous. I designed a website for my alumni association last summer using XHTML Transitional and CSS. I finally got around to posting it, but in the meantime IE7 came out. Everything looks fine in IE6 and FF, but when the page is opened in IE7 the...
|
by: z55177 |
last post by:
My domain: http://www.esthevision.cz/
This is the cause of my problem.
The template is supposed to look somewhat like this: PINK STRIPE
http://themebot.com/website-templates/ht...
I created an extra copy of it called Natvrdo, since I modified the logo.
Okay, I have this in my HTML (Natvrdo being the CSS style sheet)
This is what I have...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |