Go Back   Pligg CMS Forum > Pligg Development > Modification Tutorials

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-01-2006, 04:42 PM
Casual Pligger
 
Join Date: Oct 2006
Posts: 33
Thanks: 1
Thanked 3 Times in 2 Posts
A better way of embedding flash/video

If you want to give users the ability to post youtube videos or other flash links, rather than allowing the embed tag you can use some .js to pull it in. This is a much nicer and more compliant way of doing it, and allows you to also have a no-flash and no-js fallback.

Grab the SWFObject code from here: http://blog.deconcept.com/swfobject/ and then put it in your template's /js folder.

Make sure you call the js from the header of your template.

Here is the code I am using to pull in the flash, using an extra field:

Code:
{if $Enable_Extra_Field_1 eq 1}{if $link_field1 neq ""}
<!-- this is the youtube embedded file -->
	<div id="flashcontent-{$link_shakebox_index}">
  		This text is replaced by the Flash movie.
	</div>

	<script type="text/javascript">
		var so = new SWFObject("{$link_field1}", "mymovie", "425", "350", "7", "#FFFFFF");
		so.write("flashcontent-{$link_shakebox_index}");
	</script>
{/if}{/if}
As you can see it just takes the extra field, and wraps some js around it. Look in your link_summary.tpl file for the first line to find where to insert the code.

This will only work if the correct part of the provided embed code is used, eg
Code:
http://www.youtube.com/v/FmSIsKckAzE
Ideally I'd like to write a php function that takes the full embed code and strips out the required stuff, just to make it easier on users.

Last edited by cruci; 11-01-2006 at 04:48 PM..
Reply With Quote
The Following 2 Users Say Thank You to cruci For This Useful Post:
  #2 (permalink)  
Old 11-01-2006, 08:39 PM
Constant Pligger
 
Join Date: Oct 2006
Posts: 227
Thanks: 56
Thanked 22 Times in 18 Posts
Nice Cruci.

Maybe the php function should strip out everything except for the actual video ID (ie: FmSIsKckAzE). No need to store the youtube.com part in the db and that way you could use the video ID in different ways - (ie just display a still pic like Digg does)

Where would this php function go? ... in submit.php ?
Reply With Quote
  #3 (permalink)  
Old 11-01-2006, 08:50 PM
Constant Pligger
 
Join Date: Oct 2006
Posts: 227
Thanks: 56
Thanked 22 Times in 18 Posts
I was just looking through submit.php and i'm wondering ...

Would it be possible to just parse the main title link when the user is submitting the story, see if it is a link to a youtube video if it is grab the video ID from there and insert it into the extra field?

This would make it easier for the user because it wouldn't involve an extra field or copying over the embed code form youtube. But i have no idea if this would mess up the submission code ... i'm very new to pligg.
Reply With Quote
  #4 (permalink)  
Old 11-02-2006, 02:14 AM
Casual Pligger
 
Join Date: May 2006
Posts: 30
Thanks: 8
Thanked 10 Times in 6 Posts
cruci what is your website? id like to see this mod in action.
__________________
I Love PLIGG!
http://www.thatvideoblog.com
Reply With Quote
  #5 (permalink)  
Old 11-02-2006, 03:18 AM
Casual Pligger
 
Join Date: Oct 2006
Posts: 33
Thanks: 1
Thanked 3 Times in 2 Posts
Chad: sorry, the website is localhost only. To see it in action, it looks the same as videosift or youtube...

Revolver: good idea about just stripping the video code from the initial URL. I'd like to support google video and others too, but I'm sure that could written into the function too.

Yeah, the function would go in submit.php I think, so it manipulates the data before it is put into the db, and then link_summary.php can deal with it in a clean state.
Reply With Quote
  #6 (permalink)  
Old 11-02-2006, 12:53 PM
Div Div is offline
Casual Pligger
 
Join Date: May 2006
Posts: 60
Thanks: 0
Thanked 7 Times in 4 Posts
I'm no coder but a thought about your idea crossed my mind. If on the submit page you had a drop down or check boxes with the allowed sources for the video, you could pass that to the submit.php to have it strip what you want from the particular source. If "a" strip this, If "b" strip that, etc. Could even be used when calling the video back, If "a", from this source, If "b", from that source etc.

Hope this makes sence and is helpful.
__________________
DivGamer.com
Reply With Quote
  #7 (permalink)  
Old 11-02-2006, 04:25 PM
Casual Pligger
 
Join Date: Oct 2006
Posts: 33
Thanks: 1
Thanked 3 Times in 2 Posts
Div: yeah, it could be done that way, but I'm sure the function could also just detect which domain it is from and treat it accordingly. It might have to store the domain so it knows where to get it from later though...

Times like this I wish I knew more PHP...
Reply With Quote
  #8 (permalink)  
Old 11-02-2006, 05:12 PM
Div Div is offline
Casual Pligger
 
Join Date: May 2006
Posts: 60
Thanks: 0
Thanked 7 Times in 4 Posts
I wish I knew more PHP also. I'm just geussing here, but to do it as you suggest, you would have to have conditions to meet to determine which domain. With a drop down or check box it would already know, and thus what to do with it. Maybe it would be more work that way, having to code a drop down or check box and pass that on.

Like I said, it was just a thought I had, probably not easier that what has been talked about, but an idea non the less.
__________________
DivGamer.com
Reply With Quote
  #9 (permalink)  
Old 02-05-2008, 01:00 PM
New Pligger
Pligg Version: 9.8.2 Beta
Pligg Template: not sure yet
 
Join Date: Dec 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Has there been any progress? lI would like a similar solution to the embed youtube videos.

Thanks
Reply With Quote
Reply

Thread Tools
Display Modes
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Similar Threads
Thread Thread Starter Forum Replies Last Post
documents embedding enzofsilva Suggestions 1 08-08-2007 01:38 PM
Version 9.5: Problem with embedding videos (movie not loaded) nothingman Modification Tutorials 3 05-11-2007 01:39 PM
Embedding pligg ozzie135 General Help 4 04-17-2007 10:11 AM
Embedding Videos Protection Code Renegade Modification Tutorials 16 09-27-2006 05:39 AM
Help embedding a .swf bkatzel "Mollio-Beat" 2 09-17-2006 08:39 AM


Search Engine Friendly URLs by vBSEO 3.2.0