Media Player implementation

infinityssm
infinityssm
@makande
7 years ago
53 posts
Hi,

I need help setting up a media player in my site skin. In my jamroom4 site i was able to figure out how to setup a video.tpl page that listed videos from a video_row.tpl page and played them on the same video.tpl page (not directed or played on the profiles video pages).

I am trying to duplicate this function in jam5. I setup a video.tpl page and inserted the following script.

{jrCore_media_player module="jrVideo" field="video_file" item_id=4}

Tested it and video 4 works fine when I load the page. Now I want to be able to successfully load videos 5 or 6 or 7 by linking from a video_row.tpl I created.

How do I code the video.tpl page? I tried replacing

{jrCore_media_player module="jrVideo" field="video_file" item_id=4}

with;

{jrCore_media_player module="jrVideo" field="video_file" item=$item},

{jrCore_media_player module="jrVideo" field="video_file" item=$item.video_url},

{jrCore_media_player module="jrVideo" field="video_file" item=$item._item_id}

Tested each and when I load the page, nothing. What am I doing wrong?

and once coded correctly how do i call it from the video_row.tpl. Is the following correct?

{$jamroom_url}/{$murl}/{$item._item_id}/{$item.video_url}">{$item.video_title}

Please advise

Thanks
MAkande

updated by @makande: 05/03/17 05:29:32AM
michael
@michael
7 years ago
7,746 posts
not sure what you're wanting to put in video_row.tpl

if you visit yoursite.com/video and video #4 plays (careful not to conflict with the video modules url, thought that was 'video' ), then you can also pass in the video parameter to use:

yoursite.com/video/play_id=4

and use:
{jrCore_media_player module="jrVideo" field="video_file" item_id=$play_id}
to get #4. If that doesnt work then the variable to use is $_post.play_id . Throw a {debug} in the template to get the correct variable name.

If you're saying you want to use that code in a row of items, then jrCore_list is the function to get a list of items.

eg
{jrCore_list module="jrVideo" template="video_row.tpl"}
and in video_row.tpl put your video call. That will get you a list of videos and a player for each one.

--edit--
in video_row.tpl something like this:
{if isset($_items)}
{foreach $_items as $item}
HERE IS THE PLAYER FOR ITEM ID: {$item._item_id}<br>
{jrCore_media_player module="jrVideo" field="video_file" item=$item._item_id}
<br>
{/foreach}
{/if}

Docs: "{debug}"
https://www.jamroom.net/the-jamroom-network/documentation/jamroom-developers-guide/1477/debug

Docs: "{jrCore_list}"
https://www.jamroom.net/the-jamroom-network/documentation/jamroom-developers-guide/89/jrcore-list
updated by @michael: 01/17/17 01:20:36AM
infinityssm
infinityssm
@makande
7 years ago
53 posts
Hi Michael,

Im sorry, I made a mistake in my explanation. The two files that I created were videos.tpl and video_row.tpl. However, thanks to your examples I was able to figure it out. I replaced the "$item._item_id" with "item_id=$item_id"

Videos.tpl - {jrCore_media_player module="jrVideo" field="video_file" item_id=$item_id}

video_row.tpl - href="{$jamroom_url}/Videos/item_id={$item._item_id}">{$item.video_title}

Now I can list all videos and play them on the same videos.tpl page.

So my next problem...

Now that the video plays correctly, how do i avoid the page refreshing with every video click?

I tried the following

Videos.tpl - added a div id="vplayer" to the page

video_row.tpl - onclick="jrLoad('#vplayer','{$jamroom_url}/Videos/item_id={$item._item_id}');">{$item.video_title}

My first attempt loaded in the correct area, but displayed the whole page instead of just the player.

I then created video_player.tpl with just a player and changed the video_row.tpl to:

video_row.tpl - onclick="jrLoad('#vplayer','{$jamroom_url}/video_player/item_id={$item._item_id}');">{$item.video_title}

but it does not work. What is wrong with the code in the video_row.tpl "onclick" link?

Please advise

Again, thanks for your earlier response

MAkande
updated by @makande: 01/17/17 10:58:08PM
michael
@michael
7 years ago
7,746 posts
infinityssm:...Now that the video plays correctly, how do i avoid the page refreshing with every video click? ....

Kind of flying blind here. Its not easy to set that up when I'm doing it myself, here I can't see the code.

So you have your player div loading at yoursite.com/videos/item_id=4 and when you click on on the link it tries to load in to a div with the ID="vplayer".

It seams like it should be working. perhaps have an href="#" to stop the page refresh, or a ;return false; after the jrLoad may work.

<a href="#" onclick="jrLoad('#vplayer','{$jamroom_url}/video_player/item_id={$item._item_id}');return false">{$item.video_title}

updated by @michael: 01/18/17 12:55:12AM