Patch to play youtube videos in you own player using flashvideo and a CCK field
Hi,
I did this because I wanted to play videos such as youtube ones. But I do not want them to embed in the youtube player so I want to make them play in my JW player.. And even more important, I do not want my users to have to put [video] tags. I use the flashvideo module and the CCK plugin.
What you have to do:
1) in the file flashvideo.admin.inc, add this (line 174):
<?php
$form['flashvideo_'. $node_type .'_cck_embed_video_field'] = array(
'#type' => 'select',
'#title' => t('Save url for the embed video to this CCK text field'),
'#description' => t('The field where the url for the embed video such as Youtube will be placed.<br /><strong>Note:</strong> You must create this file field yourself on your') .' '. $node_type .' '. t('content type. You\'ll then be able to select it from this list.<br /><strong>Note:</strong> Because this field is meant to be filled in by the FlashVideo module, this field will no longer be visible on the node creation form.'),
'#options' => _flashvideo_get_cck_fields($node_type),
'#default_value' => flashvideo_variable_get($node_type, 'cck_embed_video_field', 0),
);
?>Then you have to change the function _flashvideo_get_cck_fields in the flashvideo.module file line 2442
Here is the new function:
<?php
foreach (_flashvideo_content_fields($content_type) as $field) {
// Only display filefields => and text fields
if ($field['type'] == 'filefield' || 'textfield') { //there is the changement to take CCK text fields
$fields[$field['field_name']] = $field['widget']['label'];
}
}
?>Wherever you want, add this function in the file flashvideo.module
<?php
function get_flashvars_file($node){
// What is the name of the embed video field Let's find out
$cck_embed_video_field = flashvideo_variable_get($node->type, 'cck_embed_video_field', '');
//get the content of the CCK field where the user put the 3rd party url
$flashvars_file=db_result(db_query("SELECT ". $cck_embed_video_field ."_value FROM {content_type_drigg} WHERE nid= %d", $node->nid));
//if CCK field is empty (means there is a file uploaded)
if ($flashvars_file == ''){
$flashvars_file = 'file=@video';
}
return $flashvars_file;
}
?>Finally, in the flashvideo.module file, line 1900 or so in the function flashvideo_get_video change this:
<?php
//we set the file flashavars parameter from the function we created
$params['flashvars']['file'] = get_flashvars_file($node); //this is the line to add
$video = flashvideo_get_video_object($node, $params);
...
...
...
?>Test it:
And that's it ! So now you can go in content-> content type; create a new text field and add it to the content type you want.
Then, go to site configuration -> flashvideo settings and choose the CCK textfield you just created under "Save url for the embed video to this CCK text field".
Then you can test it by going to "create content" copy and paste a link from a youtube video and that works !
IMPORTANT:
-this code is mean to play youtube videos IN your player (I personally use the JW player). To make it works, you have to put the file yt.swf in the same directory than the Player.swf file on your server!
-do not forget to modify your users permissions in user management -> permissions to allow them to view and put urls in the CCK field you created :)
Enjoy this little patch :)
I am now fighting with other big problems and I would be very thankful if someone could help me:
P.S. : sorry for my english (I'm french :D)

Youtube support is already
Youtube support is already part of the module. All you have to do is drop the YouTube ID into the body field of your node in the format:
[video:id=SmVAWKfJ4Go]For more info, please see the included help files at: admin/help/flashvideo
Mark W. Jarrell
Manager of Web Services
Jones Knowledge Integration Group, Inc.
http://www.jones.com
http://www.jonesknowledge.com
http://www.jonesdifference.com
http://www.jiu.edu
Twitter: attheshow
Not without [video] tags
Well, I know but in order to do that you have to use the [video] tags.
I do not want that for my users so I disabled the [video] tag.
I want my users to only copy and paste the url in a field and do not ask them to write tags.
I was wondering something else, the flashvideomodule provides a vimeo code but it is an embed code right? You cannot play the vimeo video into a JW player for example?
Interesting Pirch... I will
Interesting Pirch... I will try your code :)
--
www.deltabridges.com
It's not working yet...
deleted because the solution is posted in the frist post :)
about not using a [video] tag
about not using a [video] tag :
If u dont use a [video] tag, how can your user control the position of the video?
say, user A may want to have his video in the top of the page.
user B, want to have the video at the end.
user C ....in the middle....
anyway..up to u ...
PS: if my memory is right, flashvideo does support JWPlayer already.
Good day.
---------------------------------------------------------
toll free is good, but pay toll may go faster ...
we go the drupalway. how about u?
www.drupalway.com - pay toll to go faster
We go the drupal way. How about you?
http://www.drupalway.com
RE: about not using a [video] tag
Well you made a good point, the thing is, for my website (failuo.com) I do not want my user to choose the place of the video. I will choose it with CSS so that it is always in the same position in a post.
You are right, flashvideo does support JWPlayer but it does NOT provide the code to play youtube videos IN the JWPlayer WITHOUT using [video]tags...
Done!
You can now see the solution in the first post which has been updated
got as far as...choose the cck textfield...
I am trying your patch and have made all the code changes, created a new text field and added it to my new video content type but when I go to choose the cck textfield it does not show in the 'select' box under 'Save url for the embed..." I have cleared the cache and double checked the content type and textfield...all show as created. Can you give me any guidance as to where I can look for a solution?
Drupal 6.10
I have also applied the patch
I have also applied the patch as suggested and able to see fields into select box under 'Save url for the embed...". I have selected proper textfield and added youtube-url into that but not able to see video. Its showing image of video not available.
Can anyone tell me what I am missing here ??
Thanks,
Anjan