It is noted in http://drupal.org/node/143656 that we can call swf($array_of_files).
It is noted in http://drupal.org/node/305225 that we can call swf($file, $args).

I tried combining both ideas, to create a playlist for youtube videos.

$files = array('http://www.youtube.com/v/uikgwR8YwfQ', 'http://www.youtube.com/v/iGmUs2o2WcE');
print swf($files, array('params' => array('height' => '400', 'width' => '300'), 'methods' => array('action' => 'swftools_swf_display_direct')));

and it doesn't work.

The single file version works:

$file = 'http://www.youtube.com/v/uikgwR8YwfQ';
print swf($file, array('params' => array('height' => '400', 'width' => '300'), 'methods' => array('action' => 'swftools_swf_display_direct')));

Can anyone enlighten how I should have done it?

Thank You.

Comments

Stuart Greenfield’s picture

Using action = swftools_swf_display_direct renders the video in the YouTube player, and you can't build playlists in that way. You need to retrieve just the video stream, and handle it in one of the SWF Tools media players (Wijering or Flowplayer). See this post which describes the steps that are needed.

The key points are that you need to set the action to swftools_flv_display, or swftools_flv_display_list (for single files, or playlists respectively), and that the format of the video url varies according to whether you are using Wijering or Flowplayer.

It's a bit fiddly to set up, but it can be done. However, there is a problem when using FlowPlayer3 as the "t" value changes over time!

And, when I just tried to test it locally I found a bug in the playlist function that means lists of full urls aren't properly processed either. So I need to fix that too!!

However, when the playlist function is fixed what you would write is (for FlowPlayer3)

$files = array(
  array(
    'filepath' => 'http://www.youtube.com/get_video?video_id=uikgwR8YwfQ%26t=vjVQa1PpcFM7-unzB_fkxAn28G9nogy8ZL0IAZCXEjM%3D',
    'title' => 'Hamster Dance'
  ),
  array(
    'filepath' => 'http://www.youtube.com/get_video?video_id=4vuW6tQ0218%26t=vjVQa1PpcFNYcrn6GTriOypFmkbl9KDSQQUBQR4-iM8%3D',
    'title' => 'Dead Parrot Sketch'
  ),
);

print swf($files, array('methods' => array('action' => 'swftools_flv_display_list')));

While the code for Wijering4 would be

$files = array(
  array(
    'filepath' => 'http://www.youtube.com/v/uikgwR8YwfQ',
    'title' => 'Hamster Dance'
  ),
  array(
    'filepath' => 'http://www.youtube.com/v/4vuW6tQ0218',
    'title' => 'Dead Parrot Sketch'
  ),
);

print swf($files, array('methods' => array('action' => 'swftools_flv_display_list')));

I'm going to open a new issue for the bug in the playlist function.