 |
VideoEmbedding, a Movable Type plugin to include external video
This product is a plugin for the Movable Type blog platform to help content creator to simply add external videos to their posts.
From the internal Movable Type editor, with a BBCode-like tag, you can include embedding videos currently from this platform
- www.youtube.com using [yt] tag
- video.google.com using [gv] tag
- www.vimeo.com using [vm] tag
- www.myspace.com using [ms] tag
- www.blip.tv using [bl] tag
- local video using JW FLV Media Player using [mp] tag
If you write this

you get this

To use this plugin:
- Download the zip or tar.gz file and upload the contents of the 'plugins' folder to the 'plugins' directory of your MT installation.
As an alternative, you can install a development version of this plugin directly from its SVN location. Change to the 'plugins' directory and install the plug from SVN
svn co https://svn.micso.net:666/bruni/MTOS/MTVideoEmbedding/trunk/MTVideoEmbedding/plugins/MTVideoEmbedding/ MTVideoEmbedding
- Write a new blog entry.
- In "Format" combo, switch format to "Video"
- Append your favorite video as [yt]fn3rbKd47IY[/yt]
- Optional you can continue to edit your page in "Rich Text" mode. The "yt" tag will be substituted with embedded code.
- Save and view page.
Download
Download in .zip format
Download in .tar.gz format
For more information, read the README file.
Credits
This module is a completly rewrite of Crys Clouse and David Wees videoembedding.pl plugin. I rewrote
most of the code to optimize regular expression and incapsulate some logics. I implement standard interface for movable type plugin and extend original module with other video source like vimeo and myspace.
Source code
For learning porpouse, this is the source code of the main module in version 02.02
1 #!/usr/bin/perl
2
3 package MT::Plugin::VideoEmbedding;
4
5 use strict;
6 use warnings;
7 use MT 4.0;
8 use base qw( MT::Plugin );
9
10 our $DISPLAY_NAME = 'Video Embedding via BBCode';
11 our $VERSION = '2.02';
12
13 our ($plugin, $PLUGIN_MODULE, $PLUGIN_KEY);
14 MT->add_plugin($plugin = __PACKAGE__->new({
15 id => plugin_module(),
16 key => plugin_key(),
17 name => plugin_name(),
18 description => "A text filter to use BBCode-like tag to include external video resource. You can embed an youtube video with this BBCode<p><pre>[yt]eR8swuWfKMI[/yt]</pre>",
19 version => $VERSION,
20 author_name => "Emiliano Bruni",
21 author_link => "http://www.ebruni.it",
22 plugin_link => "http://www.ebruni.it/software/os/mtos/videoembedding/",
23 doc_link => "http://www.ebruni.it/software/os/mtos/videoembedding/readme.htm"
24 }));
25
26 MT->add_text_filter(video => { label => 'Video', on_format => sub { &vcode }, });
27
28 sub init_registry {
29 my $plugin = shift;
30 $plugin->registry({
31 });
32 }
33
34 sub vcode {
35 my $s = shift;
36 vfullcodes($s);
37 }
38
39 sub vfullcodes {
40 my $s = $_[0];
41
42 $s = &youtube($s);
43 $s = &google($s);
44 $s = &vimeo($s);
45 $s = &myspace($s);
46
47 $s = vmaincodes($s);
48 return $s;
49 }
50
51 sub vcommentcodes {
52 my $s = $_[0];
53
54 $s =~ s!<!\*amp;lt;!g;
55 $s =~ s!>!\*amp;gt;!g;
56 $s = vmaincodes($s);
57 $s =~ s!\*amp;!&!g;
58
59 return $s;
60 }
61 sub vmaincodes {
62 my $s = $_[0];
63
64 $s =~ s!…!…!g;
65 $s =~ s!‘!‘!g;
66 $s =~ s!’!’!g;
67 $s =~ s!“!“!g;
68 $s =~ s!”!”!g;
69 $s =~ s!–!–!g;
70 $s =~ s!—!—!g;
71
72 $s = MT::Util::html_text_transform($_[0]);
73 $s =~ s!(<p>.*?</p>)!vsmarty_pnts($1)!geis;
74 $s =~ s!<linebreak>!\n!g;
75
76 return $s;
77 }
78
79 sub vsmarty_pnts {
80 my $s = $_[0];
81 my $smarty = $MT::Template::Context::Global_filters{'smarty_pants'};
82 return $smarty ? $smarty->($s, '1') : $s;
83 }
84
85 sub youtube {
86 my $er = sub() {
87 my ($v,$height,$width,$hq) = (shift,shift,shift,shift);
88 return <<""
89 <object width="$width" height="$height">
90 <param name="movie" value="http://www.youtube.com/v/$v" />
91 <param name="wmode" value="transparent" />
92 <embed src="http://www.youtube.com/v/$v" type="application/x-shockwave-flash" wmode="transparent" height="$height" width="$width">
93 </object>
94
95 };
96 return &_def_filter(shift,'yt',$er,350,425);
97 }
98
99 sub google {
100 my $er = sub() {
101 my ($v,$height,$width) = (shift,shift,shift,shift);
102 return <<""
103 <embed style="width:${width}px;height:${height}px" flashvars="" src="http://video.google.com/googleplayer.swf?docid=$v" type="application/x-shockwave-flash"> </embed>
104
105 };
106 return &_def_filter(shift,'gv',$er,326,400);
107 }
108
109 sub vimeo {
110 my $er = sub() {
111 my ($v,$height,$width) = (shift,shift,shift,shift);
112 return <<""
113 <object width="$width" height="$height">
114 <param name="allowfullscreen" value="true" />
115 <param name="allowscriptaccess" value="always" />
116 <param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id=$v;show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" />
117 <embed src="http://www.vimeo.com/moogaloop.swf?clip_id=$v&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="$width" height="$height"></embed>
118 </object>
119
120 };
121 return &_def_filter(shift,'vm',$er,225,400);
122 }
123
124 sub myspace {
125 my $er = sub() {
126 my ($v,$height,$width) = (shift,shift,shift);
127 return <<""
128 <object width="${width}px" height="${height}px">
129 <param name="wmode" value="transparent"/>
130 <param name="allowscriptaccess" value="always"/>
131 <param name="movie" value="http://lads.myspace.com/videos/vplayer.swf"/>
132 <param name="flashvars" value="a=0&ap=0&y=0&m=$v&userid=-1&showmenus=0&remove=0&t=&type=video"/>
133 <embed src="http://lads.myspace.com/videos/vplayer.swf" width="$width" height="$height" flashvars="a=0&ap=0&y=0&m=$v&userid=-1&showmenus=0&remove=0&t=&type=video" type="application/x-shockwave-flash" allowscriptaccess="always" />
134 </object>
135
136 };
137 return &_def_filter(shift,'ms',$er,386,430);
138 }
139
140 sub _def_filter {
141 my ($s,$tag,$er,$defH,$defW) = @_;
142
143 my $re = '\[' . $tag. '\s*(.*?)](.*?)\[\/' . $tag. ']';
144
145 $s =~ s{$re}{
146 my $params = $1;
147 my $v = $2;
148 my $height = ($params =~ /height\s*=\s*"?(\d+)"?/) ? $1 : $defH;
149 my $width = ($params =~ /width\s*=\s*"?(\d+)"?/) ? $1 : $defW;
150 $er->($v,$height,$width);
151 }gse;
152
153 return $s;
154 }
155
156
157 sub plugin_name { return ($DISPLAY_NAME || plugin_module()) }
158 sub plugin_module {
159 $PLUGIN_MODULE or ($PLUGIN_MODULE = __PACKAGE__) =~ s/^MT::Plugin:://;
160 return $PLUGIN_MODULE;
161 }
162 sub plugin_key {
163 $PLUGIN_KEY or ($PLUGIN_KEY = lc(plugin_module())) =~ s/\s+//g;
164 return $PLUGIN_KEY
165 }
166
167 1;
|
 |
|
 |
What if I need to post more than one video on a Page or Entry? It appears to only load one when using the JW FLV player [mp] code... how do I place multiple videos on the same page, please?
Do you have an example page where problem appears?
I figured it out -- it only shows the first video as it appears the code on the page is set to use the same div ID. I ended up entering the
Here is an idea I came up with today: why not put the MT Entry ID as the DIV ID, then every video/player would be unique to each post? div id="player{MTEntryID}" should do the trick. Then when more than one entry is displayed on a page/archive/etc it will work with all of them, yes?
Don't worry. As soon as possible (probabily next week) I distribute a version without this problem.
Thanks in advance
Greeatings Emiliano
Any news on an update for your plugin yet? Just curious.
Cheers!
Sorry jeremy for delay. In my mind I was sure to have change this component for your problem. When I read your comment I had to go and see the code to see that I have not actually done anything.
Now I distributed a new version (02.30) that should solve the DIV ID problem in JW FLV player.
Tell me if you have other problems.
Bye
Emiliano-
Excellent. It works now as I would expect. Thank you!!
For my purposes it works even better to write the code as:
my $id = "mplayer" . "_$ctime";
and then add a class to the div for consistent styling of all video player elements:
Very nice!
Here are the paths for my setup:
cgi-bin
--mt
----plugins
------MTVideoEmbedding
------mediaplayer.swf
------swfobject.js
httpdocs
--blog
----video
------testvideo.flv
--mt-static
The [yt] tag works for me just fine, but the [mp] tag (version 2.30) does nothing but display "You don't have Flash player enabled."
The code in the entry is as follows:
[mp height="480" width="320" mp_path="/plugins/"]/video/testvideo.flv[/mp]
What am I doing wrong?
Hi. THX for the useful plugin.
I am wondering whether it works with dynamic publishing?
Regards
Is there anybody?
Yes, I'm here :-D
What do you mean with "dynamic publishing"?
Dynamic Publishing means this:
http://www.movabletype.org/documentation/administrator/publishing/static-and-dynamic-publishing.html
regards
Hi again-
I still think it would work best to use the EntryID instead of the $ctime for local video files. Every entry is always unique, but I am somehow getting the same timestamp on multiple entries when rebuilding using 2.3 of your plugin. Is this possible?
Hi There! I have installed the fle where I was told, but it does not show up in my plugins page in the admn section of MT nor does it appear in the FORMAT pulldown section when entering a new post.