I have a page that displays all movie of various cat. and i designed it to help people in my community click any old movie want to watch and it will send it through a URL parameter to the view video page. So any movie clicked is filtered on the playvideo.cfm page for viewing. It makes possible for only one movie to watched at a time.

One i use the single path link without database it works, but with database dynamic link, it wont play.

Here is the code to the request page (1)

1) movie displayed page (basic.cfm)

<td height="33" colspan="3" class="yellowish_green"><a href="/@unicast/movies/playmovie_db.cfm?MediaID=<cfoutput>#rsMovies.MediaID#</cfoutput>"><strong><cfoutput>#rsMovies.Title#</cfoutput></strong></a></td>

Here is the code to the embed Window Media Player from through the URL request from database(2)

2) video view page (playmovie.cfm)

DATABASE TABLE STRUCTURE

<cfparam name="URL.MediaID" default="0">
<cfquery name="rsMovies" datasource="#Request.DSN#">
SELECT MediaID, CatID, SubCat, Title, FileName, FileImg, DateReleased, "Cast", Director, Translator, AudioRating, AudioFM, VideoFM, "Language", Length, Awards, RatingID, AgeRating, Features, AddOnline
FROM media
WHERE MediaID = <cfqueryparam value="#URL.MediaID#" cfsqltype="cf_sql_bit">
</cfquery>

EMBEDDED WMPLAYER WITH URL REQUEST FROM DATABASE

<object
classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' data="<cfoutput>#rsMovies.FileName#</cfoutput>"' type='application/x-oleobject' name="mediaPlayer" width="676" height="500" id='mediaPlayer'
components...>
<param name='animationatStart' value='true' />
<param name='transparentatStart' value='true' />
<param name='autoStart' value="false" />
<param name='showControls' value="true" />
<param name='loop' value="true" />
<param name="fullscreen" value="true" />
<embed
src="<cfoutput>#rsMovies.FileName#</cfoutput>"

width="676" height="500"

autostart="false" loop="true" type='application/x-mplayer2'


pluginspage='

oad/'
id='mediaPlayer' name='mediaPlayer' displaysize='4'

autosize='-1'
bgcolor='darkblue' showcontrols="true" showtracker='-1'
showdisplay='0' showstatusbar='-1' videoborder3d='-1' designtimesp='5311' animationatstart="true" transparentatstart="true" fullscreen="true" mediaid="<cfoutput>#rsMovies.MediaID#</cfoutput>"> </embed>
</object>

Dani AI

Generated

Quick diagnosis and checklist for : when a hard-coded media URL plays but the DB-driven one does not, the problem is almost always that the browser/plugin is receiving a bad or inaccessible URL (or no URL at all). is right to say "view source" — but here are the concrete things to compare and fix, in order of likelihood.

  • Confirm the query actually returns a row. If the query returns zero rows you will have an empty FileName. Dump or check rsMovies.recordCount before building the player.
  • Make sure the MediaID parameter uses the correct SQL type. Use a numeric type for numeric IDs (not a bit/boolean). Wrong cfsqltype can make the WHERE fail and return no rows.
  • Print the final URL to the page and open it directly in a new tab. If that URL 404s, 403s, or downloads instead of streaming, the player won’t play. Ensure the stored FileName is either a full absolute URL (http://...) or a correct server-relative path that resolves from the page location.
  • Inspect the generated HTML for malformed attributes (extra quotes, stray apostrophes, stray line breaks injected by CFOUTPUT). A broken attribute will stop the plugin from receiving the URL. Compare the working hard-coded object/embed tags with the generated ones character-for-character.
  • URL-encode filenames that contain spaces or special characters before placing them into the embed/src/param. Use CF’s URLEncodedFormat or equivalent.
  • Verify server permissions and MIME mapping (.wmv/video types) so the web server will serve the file correctly. Also test the media URL in a native player (Windows Media Player) to isolate browser/plugin issues.

Small CF-specific checks (example, not repeating your existing code):

<!-- verify result -->
<cfif rsMovies.recordCount EQ 0>
  <cfoutput>No media found for ID #URL.MediaID#</cfoutput>
</cfif>

<!-- safe filename -->
<cfset safeUrl = URLEncodedFormat(rsMovies.FileName)>

If the URL works directly but the embed still fails, check that you supply the URL in the player param expected by the plugin (the object PARAM named "URL" and the embed src). For long-term compatibility consider an HTML5 player or a JS fallback; browser plugin support for native WMP embedding is inconsistent.

One i use the single path link without database it works, but with database dynamic link, it wont play.

You mean it works with a hard coded path but not when you use variables? Do a view source and look at the html generated. Compare it to the hard-coded-working version and see how it differs.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.