I a given playlist 'Animals' I have 5 items (entry titles): Dog, Cat,
Elephant, Zebra and Lion.
The WMP9 object is embedded in a webpage with id="MediaPlayer1".
AutoStart is set to 'False'.
URL is set to 'animals.asx'.
A text menu is present with:
<a href="#">View Dog</a>
<a href="#">View Cat</a>
etc.
I've been all over the SDK and among others found the
'currentPlaylist.item(index)':
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmplay/mmp_sdk/playlistitem.asp
But unfortunately I haven't been able to get the bits and peaces together in
a proper way.
Any suggestions to how a Jscript code could look like?
/Tony
Just step through the indexes and read content attributes until you
get a match for the text you've specified inside the link tags.
Don't forget, the user will be prompted if you ask to examine a
playlist other than one which you've built on the fly. You'll need to
check if you were given mediaAccessRights (so check for
player.settings.mediaAccessRights=='full' ) before attempting to
enumerate the playlist items.
Cheers - Neil
I'm trying and trying and trying .. But it just won't work.
Can I talk you into showing me, and others who follows this thread, a
working example based on the 'animals.asx' concept?
BTW:
Neil are you a freelancer. It would be nice to have you in a 'back up team'.
If so, I'll fill you in on what we are doing .
/Tony
"Neil Smith [MVP Digital Media]" <ne...@nospam.com> skrev i en meddelelse
news:g7nqg0ded479v3cna...@4ax.com...
With a 'little' help from other friends I've thrown this answer in on a
similar question on the WMTalk list:
***
In the SDK I've seen that "access to Media Library is required", but for
what reason I don't really know . at this point in my 'trail and error
prototyping' everything is working OK in WMP9 .
If the real code-sharks on this list have any comments / suggestions, they
are more than welcome .
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>Pick entry in playlist</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript">
function establishPlayer()
{
document.write('<object id="MediePlayer1" \n');
document.write('width="320" \n');
document.write('height="304" \n');
document.write('classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"
\n');
document.write('codebase="http://activex.microsoft.com/activex/controls/mpla
yer/en/nsmp2inf.cab#Version=6,4,5,715" \n');
document.write('standby="Loading Microsoft Windows Media Player
components..." \n');
document.write('type="application/x-oleobject"> \n');
document.write('<param name="URL"
value="mms://server/path/animals.asx">\n');
document.write('<param name="uiMode" value="Full"> \n');
document.write('<param name="AutoStart" value="true"></object> \n');
}
function playEntry(index) {
MediePlayer1.URL = "mms://server/path/animals.asx";
var media = MediePlayer1.currentPlaylist.item(index);
MediePlayer1.controls.playItem(media);
}
function stop(){
MediePlayer1.URL = "";
MediePlayer1.controls.stop();
}
</script>
<script language = "JavaScript" for = "MediePlayer1" event =
"PlayStateChange()">
if(MediePlayer1.playState == 8) stop();
</script>
</head>
<body>
<script language="JScript">establishPlayer();</script>
<br>
<input type="button" value="Cat" onclick="playEntry(1);">
<input type="button" value="Dog" onclick="playEntry(2);">
<input type="button" value="Elephant" onclick="playEntry(3);">
<input type="button" value="Lion" onclick="playEntry(4);">
<input type="button" value="Zebra" onclick="playEntry(5);">
</body>
</html>
Refs.:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmplay/mmp_sdk/playlistitem.asp
/Tony
N.B. Neil: I'm still interested in a dialog with you. Perhaps we together
can set up an international 'back up group' we all can benefit from.
"Tony" <tony.b...@streamteam.dk> skrev i en meddelelse
news:410de282$0$13844$ba62...@nntp05.dk.telia.net...
The security implications are different - if you load your 'own'
playlist, you have access to it while it's loaded.
If you try to access the clients playlists or media library, then you
will have to first request media access rights, and the user agree to
the prompt which is raised by media player.
Sorry it took a while to get back to you, I wanted to more fully
develop this idea so you can see the possibilities.
So with that in mind.... lets say you have a playlist like this :
<ASX VERSION="3.0" PREVIEWMODE="NO" BANNERBAR="auto" >
<ENTRY>
<TITLE>Cat</TITLE>
<REF HREF="file://F:\Audio\Zero7\Home.wma" />
</ENTRY>
<ENTRY>
<TITLE>Dog</TITLE>
<REF HREF="file://F:\Audio\Zero7\Look Up.wma" />
</ENTRY>
<ENTRY>
<TITLE>Llama</TITLE>
<REF HREF="file://F:\Audio\Zero7\Morning Song.wma" />
</ENTRY>
</ASX>
And you want to dynamically load the items in the playlist into a list
of links - I'll assume you don't know in advance what the content of
the entry tags will be, only that you know they have a title element
to key off.
Starting with the HTML :
<body onload="loadPlayItems()">
<object id="MediaPlayer1"
classid="clsid:6bf52a52-394a-11d3-b153-00c04f79faa6"
type="application/x-oleobject" width="400" height="300">
<param name="autostart" value="0">
<param name="showcontrols" value="0">
<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:
420px"><h2>Playlist</h2></div>
<script language="javascript1.2" for="MediaPlayer1"
event="playStateChange">
WMP9=document.getElementById("MediaPlayer1");
if (WMP9.playState==3 && ! playListLoaded) {
showPlayItems();
}
</script>
You'll need the deferred playStateChange event for reasons I'll
discuss in a moment : There's a DIV in there which is a DOM
placeholder for the link's we'll generate from the playlist.
The following script should now be applied to the head or external
script of your page :
<script language="javascript1.2">
function loadPlayItems() {
df=document.getElementById("playItem");
dp=document.getElementById("playlist");
WMP9=document.getElementById("MediaPlayer1");
WMP9.url="http://localhost/windowsmediatv/medialibrary/playlist.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.stop();
}
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>
It should be obvious when you run this what's happening, but it's
important to note certain things : The WM7 player will return only one
element in the playlist until you actually trigger a play() event. We
have 3 elements, but they only seem to become available for scripting
when you've started to play the playlist (however briefly).
So we need to defer execution till the page loads. Then we load the
url, and start to play the playlist. The script-for kludge is to
ensure that when the playlist is loaded, we examine the full playlist.
Now we walk the items in the playlist, extracting the item's title,
and appending these as links to the DIV.
You'll now have links which are dynamically created from whatever
playlist you pass in - although this could as easily be done server
side by creating the ASX and links from a data source, rather than
creating the links from the ASX.
To tidy this up a bit, you could give the links a style of block
rather than the default CSS for a link (inline), and dispose of
appending <br /> to each link. You could and probably should use
attachEvent rather than the kludgy and marginally supported script-for
block.
Although this could be made to work on other browsers, you'd need to
carefully look at the embedding code, however most of these problems
go away if you're using standard w3c DOM and a modern browser. I've
tried to avoid any IE specific stuff in the code above so you get a
head start.
HTH
CHeers - Neil
The issue with the media library is about security for the users media
content lists from snooping by 3rd parties. It doesn't apply in the
case of playlists which are created on the fly, or loaded from your
domain, but does apply if you wish to save a playlist to the users
computer.
Why don't you contact me about your ideas, I'd be interested to hear
your larger plans : neil{removethis}smith@{removethis}fresh-toast.net
Cheers - Neil
========================================================
CaptionKit http://www.captionkit.com : Produce subtitled
internet media, transcripts and searchable video. Supports
Real Player, Quicktime and Windows Media Player.
VideoChat with friends online, get Freshly Toasted every
day at http://www.fresh-toast.net : NetMeeting solutions
for a connected world.
So now you've done it again - given an answer way beyond what one may expect
in a NG. Impressive! Let's hope many other users can benefit from it now -
and in the future as well.
Sorry for misleading you by not clarifying the actual playlist type :(
It doesn't matter if I / we have to wait a bit. It is worth waiting fore.
And you most certainly got the development and possibilities fully covered
in this idea :)
Thx. mate!
From here on we will take the dialog further off list. I will therefore
contact you ASAP.
/Tony
"Neil Smith [MVP Digital Media]" <ne...@nospam.com> skrev i en meddelelse
news:nn81h05nnvdsdc405...@4ax.com...
Mailed U at: firstnam...@domane.net ... Got it ???
(Perhaps i should have been:
firstname sir...@domane.net ?)
/Tony
"Neil Smith [MVP Digital Media]" <ne...@nospam.com> skrev i en meddelelse
news:0jl1h09439q2jflkb...@4ax.com...