Ajaxing a Full Node View into a right column block from links in a list of Apache SOLR Facet Builder Search results, the full node does display, except for OSM player - only this displays -

OSM Player:
00:00
00:00

... but no actual player.

If I just browse the View normally, all is well and the OSM player is there and working. If I switch the View Row Style to Fields and add just my Mediafront preset, the rest of the node display is excluded and output is only the above.

I posted category as "support" but travist, if you see this (really hoping so), of course feel free to change to a bug if that turns out to be the case, which I think it might but I don't want to unnecessarily clog up your bug queue being wrong.

Comments

butler’s picture

A clarification - when I wrote:

"If I switch the View Row Style to Fields and add just my Mediafront preset, the rest of the node display is excluded and output is only the above"

... I meant "WHEN TARGETING THE VIEW TO THE RIGHT COLUMN if I switch the View Row Style to Fields and add just my Mediafront preset, the rest of the node display is excluded and output is only the above."

butler’s picture

Bump?

butler’s picture

Category: support » bug

The OSM PLayer will not display for a Node (not a View of a node) "Ahah-ed" into a right column block either - in order to see if the problem was with Views I tried rewriting my module slightly without Views so callback function is like so:

function dynamic_audio_node_get_by_node_id($nid){

$node = node_load($nid);

// REMOVE NODE TITLE -
$node -> title = NULL;

// PRINT THE NODE -
$nodeout = node_view( $node );

// create a JSON object. The object will contain a property named “audio_node” that will be set with the themed result of the executed view.
return drupal_json(array('audio_node'=>$nodeout));

exit;
}

... same behavior: node displays dynamically in right column block but without the OSM Player. OSM Player displays fine if the node is loaded normally (not asynchronously/via javascript) into a block with a new page though.

Except it is noticeably faster than it was using Views so I will probably stick with it this way. This seems to point to a problem with OSM Player at this point - why would node_view() not be able to access the player via Ahah/JQuery but would when loading a page normally?

travist’s picture

I am pretty sure this is because the CSS or JS files are not getting added to the page. What happens when you explicitly add them to the page before you drupal_json the player onto the page?

$player = osmplayer_get_player_object(array('preset' => 'mypreset'));
osmplayer_add_js($player);
osmplayer_add_css($player, 'mypreset');

I haven't actually tested this code, but it is worth a shot.

butler’s picture

Thanks very much for your reply travist. Will try this in a bit, will advise.

butler’s picture

Well, I added the code provided above by travist to the div I am targeting and the player does indeed show up. However, it still won't play the Audio node. I am guessing either I need to somehow provide $nid explicitly again to the player (maybe in my Drupal.behaviors function?) or maybe the osmplayer_functions() code should go my the callback function?

If I'm correct above, this brings up the question of how/why the player is not "aware" of the Audio node only when drupal_json-ed onto the page? Is this actually a bug, or am I just trying to do something that isn't really provided for out out of the box by the OSM Player?

Thanks also travist for pointing out the correct verb - to "drupal_json" ;)

butler’s picture

Nothing I can figure out will get the player to play the Audio node it is loading with. This would seem to be a bug... travist? Any workaround?

butler’s picture

Bump?

travist’s picture

butler,

It sounds like you will need to explicitly load the node into the media player since you have an unusual use case. You can do this within JavaScript using the loadNode function on the node object. Here is a little example of what I am talking about...

(function($) {
  jQuery.media.onLoaded('mediafront_PRESETNAME_0', function(player) {
     player.node.loadNode( NODEID );
  });
})(jQuery);

You will replace the PRESETNAME with the name of your preset, and NODEID with the node id for the node you wish to load.

I hope this provides you some more assistance.

Travis.

travist’s picture

I also need to mention that the "mediafront_PRESETNAME_0" is most likely going to change in a future release to just say "mediafront_PRESETNAME" unless there are more then one player on the page, which they would then include the instance number. I realized that I may have broken some tutorials due to this change to include instances, so just keep in mind that a future release will have that change.

butler’s picture

Travist, thanks very much, but after trying to understand, I still don't get where to put the js code from your comment 9 above. I would hugely appreciate any further direction you could provide.

To recap at this point (with a lot of help from zzadik) I have hacked together a module which works in conjunction with adding your code from comment 4 to the block I am trying to dynamically update, to display the OMS player and other content from the node in question (although again, the player still won't play the audio associated with the Audio node in question) in a block dynamically.

Where should the javascript you provided in comment 9 go - should it be in the block? Or should it be within the .js file called by my module via drupal_add_js() in order to accomplish updating the block via Json? Or...?

Then there is the question of how to provide Node ID. Node ID HAS been made available dynamically within the targeted block since node content is successfully/correctly loading into the block. So would that mean I can just provide that to the OMS player after all Json-ing has been accomplished - i.e. by figuring out what variable contains node ID?

Any further help would be greatly appreciated. Thanks very much again...

travist’s picture

butler,

The code above just needs to be added using drupal_add_js like the following php code....

<?php
drupal_add_js('
(function($) {
  jQuery.media.onLoaded("mediafront_PRESETNAME_0", function(player) {
     player.node.loadNode( NODEID );
  });
})(jQuery);
', 'inline');
?>

This should then execute the callback function when the player has finished loading... As for passing the NID along, you mentioned that the NID is provided dynamically. I cannot say how that is provided since I didn't implement what it is you are doing, but yes.... the NID should be available somehow, and you can just refer to that dynamic variable instead of hard-coding the NID value.

This is the most direction I can provide. Your use case is very custom, so I just don't know for sure how all the variables are passed around, but with a little debugging, this should put you at least on the right path.

Hope this helps.

Travis.

butler’s picture

Thanks again travist. I tried this in various ways with a hard-coded nid (to at least take that out of the equation for the moment):

- in the target block before and after the code you gave me to load OSM Player js and css,

- in the drupal_add_js statement in my module that calls the .js doc that does Json stuff

- at various points within the .js doc that does Json stuff

... and still no joy.

Would you consider consulting on this for an hour or 2 for pay? I tried emailing you re: this via Drupal site contact form but received no reply either way - please let me know whether or not you would consider this? Thanks much for all your help either way.