Jump to content

Can I Use Php To Do This...?


dzhax

Recommended Posts

Hi im making a media section on my website and instead of making a page for each piece of media i am sure there must be a way to run a script of some sort to change the windows media player on the web page to play the requested media.ex. Main page:Playlist 1Playlist 2Playlist 3then when you click on the play list it takes you to the page with the windows media player on it and plays the correct playlist-----------------------Is this possible with php and if so does anyone know how?Thanks

Link to comment
Share on other sites

Yes, you can just use PHP or you can include AJAX (not refreshing the whole page when a link for the playlist is clicked). You will want to use $_GET array. It will get information through the URL.For example:If your link is http://www.example.com/index.php?playlist=14$_GET['playlist'] will return the value of 14.You can assign a number to a playlist with a database and return the URL of it into an embed/object html tag for the source. If you don't want to do that, you can instead replace the number with the filename itself, with or without the file extension (a little bit more coding and secure).

Link to comment
Share on other sites

WMP is very stubborn piece of software. It only plays files with extensions it knows, often regardless of their MIME type.So, if you want to make WMP play a dynamically created playlist, what you must do is:1. Adjust your server to parse ".wpl" files as PHP files.2. Create parameters in the <object> that point to ".wpl" files with certain known parameters upon which you'll construct the actual playlist, like for example:

<object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">	<param name="url" value="playlist.wpl?v=1" />	<param name="showcontrols" value="true" />	<param name="autostart" value="true" /></object>

3. In the ".wpl" file, generate the actual playlist, which BTW is clear SMIL. For example (and this is a really sketchy one... you should REALLY tweak it):

<?xml version="1.0" encoding="UTF-8"?><smil>	<head>		<title>Playlist <?php echo (int) $_GET['id']; ?></title>	</head>	<body>		<seq>			<?php switch ((int) $_GET['id']) {				case 1:					echo '<media src="video1.avi"  /><media src="video2.avi" />';					break;				case 2:					echo '<media src="video3.avi"  /><media src="video4.avi" />';					break;				}			?>		</seq>	</body></smil>

Link to comment
Share on other sites

I already have the playlists compiled. they are .m3u files and all i need to do is set the src= to the correct m3u file when it navigates to the page with the wmp on it.any ideas maybe an example to go with. im not really familiar with php or ajax i know basic html and what ever expression web will do for me automatically.mma_fighter yours look a little like what i would need but i dont really understand how to use the get thingagain thanks for any help you guys rock.if you are curious what i have so far... http://www.dzhax.com/movies/webplayer.php

Link to comment
Share on other sites

I don't think WMP plays .m3u files at all... or if it does, it doesn't fully support it. Your best bet is to use ".wpl" instead.Your m3u file contains

http://dzhax.com/movies/webPlay/21/21_1.wmvhttp://dzhax.com/movies/webPlay/21/21_2.wmvhttp://dzhax.com/movies/webPlay/21/21_3.wmvhttp://dzhax.com/movies/webPlay/21/21_4.wmv

A ".wpl" file would instead be something like:

<?xml version="1.0" encoding="UTF-8"?><smil>	<head>		<title>dzhax.com movies</title>	</head>	<body>		<seq>			<media src="http://dzhax.com/movies/webPlay/21/21_1.wmv"  />			<media src="http://dzhax.com/movies/webPlay/21/21_2.wmv"  />			<media src="http://dzhax.com/movies/webPlay/21/21_3.wmv"  />			<media src="http://dzhax.com/movies/webPlay/21/21_4.wmv"  />		</seq>	</body></smil>

I believe replacing the file should be enough, but just in case, make sure you also use a classid like in the above example:

<object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">

Link to comment
Share on other sites

i tried the class id thing before and nothing showed up. Is there something needed to install for it to work correctly?----As you could see, I am making it so you can watch full dvds so, if i were to have the all movies page opened it would show something like this:<img src="Album Art"> <br /><a href = "">Movie Name </a>for each movie. Then When you click on either the link or picture, it navigates to the player.php and plays the correct list----even if it is something simple likesample for all movies pageand how to do the player.php----Maybe something like this:Like a form with action= ... and it calls the player.php which does a function to determine playlist then also contains the player on it(I used something like this to do auto navigation to certain sub sites according to the url typed, but i lost it when my pc crashed and had to rebuild my website...)----Am i clear enough or do i need to explain more.Sorry for being a pain I just still cant figure out what your trying to tell me.Thanks.

Link to comment
Share on other sites

What I'm telling you is "give up .m3u. Use .wpl files intead".Try to get ".wpl" files running, and then we'll talk more about making it more convinient to organize multiple playlists.

Link to comment
Share on other sites

Well, I'm not completely sure honestly. I've only done this in a local network. In there, I just shared the files (for reading), and linked them with the "file://" scheme. It works nicely, but for the "http://" scheme, it won't work as easily.Let's try to reverse engineer a working example from Microsoft themselves:

<object width="320" height="240" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject">	<param name="URL" value="http://wm.microsoft.com/ms/whdc/WinHEC/M_Angiulo.wmv">	<param name="SendPlayStateChangeEvents" value="True">	<param name="AutoStart" value="False">	<param name="uiMode" value="mini">	<param name="PlayCount" value="1"></object>

(example slightly altered from http://www.microsoft.com/whdc/winhec/2008/Videos.mspx)Try to copy&paste that and see if it works in IE at least. If it does, try to replace the URL with the playlist URL and see if that works as well. If it does, try it without the classid and see if Firefox now displays it as well. If IE doesn't display it with the playlist, I'm afraid you'll need a more specialized hosting for your videos - a streaming server to be more precise. MS have it as a free plug-in for IIS7, but you still need to find a host with IIS7 that is willing to install this for you, and it sure won't be free. That, or you need to host the site yourself on your own IIS server, in which case you'll need a Windows 2008 license.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...