A playlist field formatter would take a multi-value field and display all videos in 1 player. This can be accomplished by building the playlist array of objects as described at http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/15... and setting the respective playlist.size and playlist.position variables.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rickvug’s picture

Excellent idea. It would be great to make this work with Views and in various other scenarios. I can't say this is top of my personal radar at the moment but I'd certainly be open for patches.

Ravi.J’s picture

Views integration is excellent idea. Looks like there are two options to provide playlist support in JW Player.

  1. Allow for site owners to setup a multi valued media field, and all the attached videos are played in a playlist.
  2. Allow for a view to be created of many media nodes and play them as a playlist. This would be more of a "Views display formatter" than a "field formatter".
    The current roadmap for JW Player is to abstract the presentation of media from storage where storage of media is taken care of by other modules such as File, media, video and JW Player is only responsible for presentation.

    The Logic seems to be create a view, set display as JW Player playlist, at this point in options user gets to see all fields that of type file, select the fields that are to be used for play list.

From the above two option 1, should be simpler to implement and option 2 can get quite complex depending on how much flexibility is to be offered to users.

-Ravi

recrit’s picture

Status: Active » Needs review
FileSize
15.57 KB

Attached is a first pass for playlist field formatter. For views, I suggest opening a separate ticket.

Modifications made in patch:

  • adds a playlist formatter
  • changes to processing for single file player formatter to use the same theme function for both
  • playlist titles - is set in order of first available of:
    1. file description
    2. $variables['playlist_base_title'] - can be set in a preprocess function. If base title was 'Sample', it would result in a playlist of 'Sample 1', 'Sample 2', etc
    3. basename($file->filename)
  • Image formatters - conditional checks added to detect if the image module exists - more work is still need to make the entire module not dependent on the image module
  • Default settings function added for easier access and merging of default settings

Testing

Playlist generation is working good for me. I have not been able to test preview images with multiple files.. testing is welcome.

recrit’s picture

settings to size and position the playlist can be set with the patch at #1230310: Add settings for controlbar position and playlist size/position

rickvug’s picture

Status: Needs review » Fixed

@recrit Thank you very much for the patch! I quite like the changes. I normally would like to handle everything in separate issues but in this case I committed this patch and #1230310: Add settings for controlbar position and playlist size/position in one go. Being a sandbox project (for now) I'm not quite as worried. I couldn't find any bugs, perhaps more testing will shake some out. In any case all follow ups should become new issues.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

brycesenz’s picture

Version: » 7.x-1.x-dev
Status: Closed (fixed) » Active

Sorry to second guess, but was the patch in #3 actually committed? I can't find the code supposedly implemented from it in the latest -dev version.

rickvug’s picture

@brycesenz A version of the patch was committed earlier. However the module later underwent heavy refactoring to remove legacy code and to make theme preprocessing clearer/cleaner, using the HTML5 version of the player. As part of this refactoring the playlist formatter was removed as the markup is now specific to the HTML 5 video tag. I'd like to add the functionality back in however and would accept a patch to do so.

brycesenz’s picture

@rickvug -

I ask because I'm working on a patch that would create a views Style to allow playlists to function well with views. However, I can't quite figure out how to send multiple files through to a JW Player instance, or if the current code even allows for that without a bigger overhaul. I came upon this issue hoping that it was sorted out.

Can you give any quick thoughts on what is needed in the code to support playlists in general?

rickvug’s picture

@brycesenz Sorry for the delay in responding. Without researching playlists on the JW Player side, what I'd say is the the first step would be adding general support for playlists outside of field formatting or views. At its heart the module is essentially a theme function that is passed various variables. We'd need to figure out if playlist should be one of these variables or if playlists should be handled as its own theme function. Once this is worked out then Views support and File Field support is "just" a matter of tying the two together, sending the theme function the correct values.

I hope this helps.

Perignon’s picture

Playlists for JWplayer are XML files you build on their namespace. I been tinkering with how to do this with this Module. I have about 20 playlists that power all my videos and I actually host the playlists on a content delivery network. So I got a lot of peculiar things about my setup. My entire player is loaded off a CDN actually..

rickvug’s picture

I'd be happy to see some of the code. :) From there we can look at ways of generalizing the components.

How is the CDN tied in? We've been using CloudFront via CDN with JW Player without any problems or need to adapt code to suit the CDN. I don't believe that the player is served from the CDN but I don't see it being a problem to do so.

brycesenz’s picture

@Perignon -

I too would love to see how you integrated the playlists with this code. I've been working on a larger patch of my own for this issue - #1352824: Views Playlist Support - but playlist integration is the missing piece.

As I've dug through it, my shell solution was going to be:
1) Dynamically build the XML files before we call the theme function
2) Figure out how to change the player template to properly render the playlist in HTML5 and Flash.

The first it sounds like you've done, probably in a better way than I've hacked together. The second has me stumped. I'd be more than happy to help build a playlist patch if we can swap code.

rickvug’s picture

@brycesenz Thank you for starting to take this on! I will say that I'm weary of taking on playlist generation and XML functionality within this module specifically as it isn't specific to JW Player itself (proper separation of concerns). What about working off the back of existing playlist projects such as http://drupal.org/project/mediaplaylist or http://drupal.org/project/xspf_playlist? Perhaps views is what will generate the playlist XML itself, which is then fed into the player.

Looking at the JW Player documentation supporting a playlist comes down to a few player variables such as:

'playlistfile': 'playlist.xml',
'playlist.position': 'right',
'playlist.size': '250',

If we can get Views generating the XML file, perhaps via one of the other contrib projects, should integration then become exposing these variables, allowing a pattern for the playlist.xml file? It is also possible to put your playlist directly in JSON inline. See http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/19....

Perignon’s picture

I'm going to be writing a JW player module eventually which will mostly be borrowed code from other modules for my particular use case.

I used Cloudfront before, we grew out of if it quickly cause it's not a true CDN. For what I am doing I am loading everything via the CDN. Only the server computes the PHP that composes the call to the JW Player JS api.

So my player.swf, the jwplayer.js, all thumbnails, the video streams, and all the XML playlists come from my CDN. This greatly increases video response time and video player load times. I have a considerable amount of customers not within the US so the CDN is a must for my use case.

Perignon’s picture

@brycesenz I will take a look at what you have done. Thus far I haven't laid fingers to keys yet to write anything in Drupal. Currently I'm running a custom PHP script I wrote that I use iframes right now to include where I need. That has to go of course as it's a gigantic bandaid.

What I wanted to do with this Drupal module is to have a sub-portion of the module that would be a "playlist" manger of sorts. I would define my playlists by supplying URL's to the playlists - mine being stored on a CDN. I could then insert a player on a page and if I wanted to run the playlist I could select it from a select list of pre-programmed playlists I have defined in the system. Cause I'm also going to be loading multiple playlists too for one video (different compression levels and resolutions).

The site I am working on has around 20GB of video that we broadcast around the world so my use case is a small percentage of most peoples needs.

rickvug’s picture

@Perignon Which CDN are you using, and does it support origin pull mode? Are files being placed on the CDN manually? I'm presently using this module with a major magazine publisher on large sites that have many GB of video. We are using CloudFront at present but our approach with using the CDN module is exactly the same as if we were using nearly any other major CDN provider.

You are of course welcome to write your own custom module(s) for JW Player and playlists but I've normally found better results by working with and improving existing contrib projects. At present I don't see any reason why the current module can't meet your needs or be extended to do so. As for custom playlist support, try implementing hook_preprocess_jw_player() in your own module. This will allow you to add and modify player variables, including adding support for playlists. I'd much prefer that playlist support was built in a configurable way with JW Player but this approach should provide the results you need none the less.

brycesenz’s picture

Ok, we have a bunch of concurrent conversations going on here, but this is my $0.02 in response to comment #14:

I have taken a look at the Mediaplaylist module, and would prefer to not have that be the way that playlists have to integrate. Judging by the functionality and comments in issue queues of both the jPlayer and the Mediafront module, Drupal architects seem split into two camps on how they would prefer to create playlists.

(1) Some would prefer to have a content type with a multi-value media field, in which all Media files attached to that field would serve as a playlist. jPlayer supports this, the Mediaplaylist module requires this, and it sounds like at one point JWPlayer supported this as well.

(2) Another camp would prefer create playlists out of Media nodes via Views. In this case, each media file would likely live in a separate node, and a Views style plugin would be the glue that marries them all together inside of a JWPlayer instance. MediaFront supports this case as well as the first case.

Relying on an XML playlist generation module seems like a needless complication. It might not be JWPlayer's job per se to deal with converting from Drupal's node arrays to XML, but bringing that function into this module will result in a much cleaner experience for site builders and allow this module to deal with both cases (1) and (2) as outlined above.

burningdog’s picture

My use case fits (1) better, because the videos in my playlist are all actually slices of one longer video, and I'd prefer not to have to create a node per video, but rather keep them all within one node. This would entail making the number of values that the Video field can accept be greater than 1.

There's no need to rely on XML playlist generation. JW Player will accept inline JSON (as pointed out in #14), like so:

<div id="container"></div>

<script type="text/javascript">
    jwplayer("container").setup({
        'flashplayer': 'jwplayer.swf',
        'playlist': [{
            'file': '/videos/video1.mp4', 
            'image': '/thumbs/video1.jpg',
            'title': 'The first video'
        },{ 
            'file': '/videos/video2.mp4', 
            'image': '/thumbs/video2.jpg',
            'title': 'The second video'
        }],
        repeat: 'list'
    });
</script>

Source: http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/19...

Nice and simple! Now to work on a patch...

davidgrayston’s picture

Status: Active » Needs review
FileSize
14.22 KB

I've created a patch that creates a playlist if there is more than 1 video. If there's only 1 video, the usual embedding method will be used.

Key features:

  • Field formatter settings so that you can set which title/description/image fields should be used in the playlist
  • Field formatter setting so that you can set which which image style should be used in the playlist
  • Preset setting to allow auto-height of a top/bottom positioned playlist

The patch can be applied to the most recent commit:
JW Player: January 3, 2013 18:39
Commit 2fef0d7 on 7.x-1.x
by Berdir

davidgrayston’s picture

I've removed a line of code that wasn't needed in the attached patch

davidgrayston’s picture

I've revised the patch to configure the playlist title/description/image fields on the preset

davidgrayston’s picture

(Please ignore patch attached to comment 22)

I've revised the patch to configure the playlist title/description/image fields on the preset

The patch can be applied to the most recent commit:
JW Player: January 3, 2013 18:39
Commit 2fef0d7 on 7.x-1.x
by Berdir

Hopiu’s picture

Just a few questions... Wouldn't it make sense (and reduce complexity) to always have a playlist even with only one entry in it? And did you lose some thoughts on how to have several files (mp4, m4v, several bit-rates) per playlist item? I am still thinking about that, but don't have enough experience to come up with a good solution.
Anyway I'd be willing to help implementing it.

davidgrayston’s picture

I think refactoring the module to always use playlists as you suggested is a good idea

I haven't looked into using several bit-rates per playlist item yet, but if you have some ideas feel free to post a patch

Hopiu’s picture

According to "Working with playlists" the playlist is displayed in a listbar (in JWPlayer 6). The allowed position properties are bottom, right or none.

jwplayer("myElement").setup({
    playlist: "http://example.com/playlist.rss",
    height: 360,
    listbar: {
        position: 'right',
        size: 320
    },
    width: 960
});

I'd propose to change that in the patch. (attached)

As for the controlbar, the positioning has been removed in JWPlayer6, it's now only "on" or "off". But actually it still works for me... (at least in the flash version)

Hopiu’s picture

How about getting this into the dev version? I would really appreciate some progress on this topic.

(I rewrote the patch for the latest dev, including switching to playlists even for one file only, and a preset to have multiple players for multiple videos or one player with a playlist containing multiple videos)

Unfortunately it collides with the latest dev release which is giving the player an id of a loaded file. As there are many files in a playlist. This probably isn't the best solution. (And makes the implementation more complicated)

Hopiu’s picture

If you want to have a look at that patch anyway, here it is... (Not sure it applies though)

kingfisher64’s picture

#23 patch doesn't apply cleanly to the latest dev - 26th Jan 2013

Hunk #2 succeeded at 97 (offset 1 line).
Hunk #3 succeeded at 157 (offset 1 line).
Hunk #4 FAILED at 184.
Hunk #5 succeeded at 332 (offset 8 lines).
Hunk #6 succeeded at 382 (offset 10 lines).
Hunk #7 succeeded at 473 (offset 10 lines).
1 out of 7 hunks FAILED -- saving rejects to file jw_player.module.rej
can't find file to patch at input line 200
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/plugins/export_ui/jw_player_ctools_export_ui.inc b/plugins/export_ui/jw_player_ctools_export_ui.inc
|index a74d815..e54b49e 100644
|--- a/plugins/export_ui/jw_player_ctools_export_ui.inc
|+++ b/plugins/export_ui/jw_player_ctools_export_ui.inc

  • rickvug committed 85a110c on 8.x-1.x authored by recrit
    #1215108 Playlist field formatter, #1230310 Extend player presets to...
deanflory’s picture

Issue summary: View changes

If this was committed, shouldn't it be set as Closed?

ron_s’s picture

Related issues: +#2713725: Refactor theming

@deanflory, looks like the commit was for 8.x-1.x, and this thread is for 7.x?

At this point I'd highly recommend reviewing 7.x-2.x-dev and the patch we've created to refactor theming. I think many of the points in this thread have been addressed there: https://www.drupal.org/node/2713725

Also the default 7.x-2.x version does support playlists, although I understand for some people upgrading might not be an option.

ron_s’s picture

Status: Needs review » Closed (duplicate)

Looking at these patches further, I think it makes sense to close this thread and direct people to review what has been created for the Refactor theming patch.

The approach we've taken is quite different from 7.x-1.x. Since all inline JS has been removed, we're just building an associative array that can take one or more files. The output is the structure expected by JW Player whether rendering just a single media player or a playlist. It also builds off of playlist functionality already present in 7.x-2.x.

Please review by downloading 7.x-2.x-dev, applying the following patches, and provide feedback if you encounter issues:

* Refactor theming: https://www.drupal.org/node/2713725
* Add not empty checks and Repeat option: https://www.drupal.org/node/2719995
* Add js file to build player: https://www.drupal.org/node/2719977

Feel free to open this thread again if anyone thinks additional discussion is necessary. Thanks.