I'm trying to write a custom formatter that will allow my multi-valued file_video (filefield) to generate a playlist. I'd like to manually render the first video in the file array, then when clicking on the playlist items render that particular video in its place.
I've got Media:YouTube mixed with MediaElement.js rendered videos (using remote stream wrapper), mixed with Oembed files as values for the multi-valued video filefield. It does not appear that any one single video player solution can handle these varied use-cases, so I'm going to have to cram them together with a custom formatter of my own (including js, etc.).
The file entity managed display feature is AWESOME--the ordering of players, etc. is EXACTLY what I need for this case.
How do I process my filefield values array--or submit a single value from the array (fid?) to the File Entity module's display formatter logic?
Comments
Comment #1
dellis commentedWorking through this solution, part-way there. I'm using the Custom Formatters module which allows you to quickly incorporate new custom formatters for fields written in HTML+Tokens or PHP (this one is using PHP).
- I found the file_entity_field_formatter_view (hook_field_formatter_view), the call looks like this:
file_entity_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display);- returning the value of that call from the custom formatter preview screen gives me an array, so a print_r of that call shows that each file is listed in as a child of that array. If I were to instead add a "drupal_render()" around the call, it would display all of the videos in proper format as per the initial issue post
- So, to get the first value for this video field--and render it, I need to do something like this:
- to add the other filenames into a list below the player (which will serve as the html basis for the playlist), I can do something like:
- Now obviously, the javascript, etc. parts, but this gets me started - the remaining question/challenge is how to get the javascript actions to call the page to render the next video.
Comment #2
dellis commentedScreenshot of resulting formatted video_field. An obvious problem is the YouTube video--I haven't seen human-readable information available for it yet (I don't think the Media:YouTube wrapper provides it).
Comment #3
dave reidComment #4
devin carlson commentedI don't believe this should be File entity specific - any standard file formatter (to deal with fields) should work just fine.
I suggest you take a look at the Examples module which contains some great documentation on creating file formatters.
Comment #4.0
devin carlson commentedtweak