Jump to content

Soundmanager2 Audio for Processwire


Macrura
 Share

Recommended Posts

The one in the tag looks good. It's the one coded in the template that doesn't have the right look. I prefer to have it in the template because it will always be just one audio file and it saves me a fraction not to put the tag into the text field all the time.

In the template it says

	$sm2 = $modules->get('TextformatterSoundmanager');
	$options = [
		'type' => 'cassette',
		'cassette' => 'ma-r90',
	];
	$track = $page->audio->first();
	echo $sm2->player($track, $options);

Am I missing something there?

Link to comment
Share on other sites

ok that's a bug, you can either uncheck the default skin in the module config, or upgrade to the latest version (110), which fixes that.

Also note that the newest version would be injecting the JS var into the header so you wouldn't need to hardcode that; also you shouldn't need any extra css, as the module should just work with this version...

Link to comment
Share on other sites

Just installed the new version and it works like a charm, drastically fantastically!

One little thing is that on the Soundmanager demo (http://www.schillmania.com/projects/soundmanager2/demo/cassette-tape/) you can see the tape as a thin line moving from the left reel to the right, that isn't there in the module.

I'm really happy with how it looks now. The first original Carl Cryplant thematic mix tapes I did in the 1980s were on real C-90 cassettes.

Link to comment
Share on other sites

  • 7 months later...

Hi,

thanks for this extension. I'm working now on a website with audio samples. I found and installed your module but can't get it work.

I installed and setup everything, following the descriptions step by step. What I also did is:
Created a file field – "audio_file" (0=No limit, Automatic … ). In the soundmodule-setup I applied this "audio_file" to the Audio Files Field.
I created a text-field and under details -> »text formatters« I applied the Soundmanager2 Audio… . In the soundmodule-setup I applied this text-field to the Tag Field.

This is in the template file:

<?php
    $options = [
      'type' => 'bar-ui',
      'skin' => 'gradient-fat',
    ];
  
    foreach($page->audio_file as $track) {
      $content .= $sm2->player($track, $options);
  }
  ?>

The template has the two fields ("audio_file" and the text field).

And on the page I uploaded a file – brahms_01.mp4 in the audio_file field. In the text field I'm trying to echo the mp.4 file with this: [smplayer tag=brahms_01]
 

Tracy doesn't show any errors.

Link to comment
Share on other sites

@neophron

(1) Are you just wanting to output your own player on a page, or use the Textformatter? The Textformatter is for putting in shortcodes into Textarea fields, like Body.

(2) The code you posted would only work if you are doing delayed output using a $content var, otherwise if your templates are direct output, you have to echo the content, something like:

<?php
    $options = [
      'type' => 'bar-ui',
      'skin' => 'gradient-fat',
    ];
  
    foreach($page->audio_file as $track) {
      echo $sm2->player($track, $options);
  }

(3) if you want to use the text field to output an audio player based on a shortcode, then you have to echo the textfield, with the Textformatter applied, like:

echo $page->myTextField;

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 2 years later...

Hi I have a problem on this simple side:

http://physicalplaces.com/work/un-common-spaces/

I tried to create the API player and the Ckeditor player and both just link to a file and does not really look like players at all, as you can see.
If im checking if the "java script" link work in the inspector it does not show to code as with other scripts, it does show and "page does not exist"-page. Is there are problem here?
I can see it links to "/site/modules/TextformatterSoundmanager/soundmanager2/script/soundmanager2-nodebug-jsmin.js" but in my directory the folder is called "textformatterSoundmanager-master" can this be the problem? When changing the name nothing works anymore - should i try to delete the module and install it again with out the folder called "-master"?

Or can any of you see another problem?

Link to comment
Share on other sites

@Atlasfreeman

3 hours ago, Atlasfreeman said:

Or can any of you see another problem?

>called "textformatterSoundmanager-master" can this be the problem?

yes, rename it "TextformatterSoundmanager"

Also you have to output the CSS files - you can choose your output option in the module, but it won't look right without the CSS. So you can output the $config->styles, or use one of the options..

Let me know how it goes..

  • Confused 1
Link to comment
Share on other sites

Okay! So Now I Edited the name in the directory and reinstalled the module. And i see it does find the Scripts now. Never the less I am not with you with the whole. It will not work without the CSS:

In the head i wrote:
<!-- SoundManager2 -->
<?php 
foreach($sm2->cssFiles as $style) 
echo "<link rel='stylesheet' type='text/css' href='{$style}' />\n"; 
?>

And it does output something see IMG

You are saying something with the module and i toggled around a little to se if anything helped. Can you see what i dit wrong?

Screen Shot 2022-05-10 at 14.16.03.png

Screen Shot 2022-05-10 at 14.22.55.png

Screen Shot 2022-05-10 at 14.22.50.png

Link to comment
Share on other sites

@Macrura

$sm2 = $modules->get('TextformatterSoundmanager');

Should it not go in the _init.php its already there...

-

I have now changed to use the config have also changed the assets option to "$config class"

//In Header
	foreach($config->styles as $style) echo "<link rel='stylesheet' type='text/css' href='{$style}' />\n";

	// In Footer
	foreach($config->scripts as $script) echo "<script type='text/javascript' src='{$script}'></script>\n";

Again it looks like fining the javascript and creating some sort of css script.

Now on the page there is only CKeditor input. It sill does no show up correctly. It find the file and all but won't show the play correctly where is it i miss to put what in?

Link to comment
Share on other sites

@Atlasfreeman

yes technically if it is in the _init, then it should work, unless that variable is out of scope for any reason on this particular file.

all of the code you showed should all work, so you just need to figure out why those are not working; Did you try the auto option for the assets? How are you getting the JS files to output?

if the audio is inside a CK editor field then you need to make sure the textformatter is applied to that field in the field settings.

If you are outputting manually then i think you need to pass the options to the $sm2 instance like is shown in a lot of the posts above with the examples for how to output audio player using the API, as opposed to audio players that live inside a CK editor field and are being parsed like shortcodes, with the textformatter.

 

Link to comment
Share on other sites

The _init.php is located in the template folder - I have never touched it before so i guess that the place it goes.
Only thing it says is:

<?php
include_once("./_func.php"); // include our shared functions
$sm2 = $modules->get('TextformatterSoundmanager');
?>

The Auto version do somewhat work while it does have problems with Pause and play and will start the song over from the beginning and play it when you wish to pause.

And what do you mean by getting the JS file to output? I have the code in the footer I tought that was enough - is this where the problem lies?

For now I will only have the CKeditor on the page. Lets focus on that. The text formatter is applied for "Soundmanger2 audio for process wire" under details.

 

And thanks for helping.!

 

 

Link to comment
Share on other sites

(1) if you are using the textformatter, then you do not need to module init in _init.php

(2) There is no CSS being output on your page, so the players will not look right

(3) If everything is automatic, then it should just work, and you shouldn't have to do any code in the header or footer. If you want to use the $config option, then you need to put the foreach for the $config->styles and $config-scripts in the header and footer respectively.

(4) What does your shortcode look like in the CK editor?

(5) If you are using Tracy Debugger then you can check the contents of the variables to see what is going on and trace the issue.

You may also want to look into using Plyr instead of soundmanager;

Here's an example of how I'm using it instead of SM2, within a CK editor field:

https://www.equinoxmusic.com/technology/

https://plyr.io/

 

Link to comment
Share on other sites

(1) if you are using the textformatter, then you do not need to module init in _init.php
Okay I deleted it.

(2) There is no CSS being output on your page, so the players will not look right
Okay, I put it to automatic and now it works but the play 
boston pause a second after pushed.

(3) If everything is automatic, then it should just work, and you shouldn't have to do any code in the header or footer. If you want to use the $config option, then you need to put the foreach for the $config->styles and $config-scripts in the header and footer respectively.
I have removed everything and did the 
automated function. It did work yesterday evening now it does not.

(4) What does your shortcode look like in the CK editor?
[smplayer tag=replace type=bar-ui bar-ui=full-width]

(5) If you are using Tracy Debugger then you can check the contents of the variables to see what is going on and trace the issue.
I will try to install this module and se what it says never used it ?

I feel like im close hehe but maybe I will need to use Plyr in the end but and the site looks ver good buy the way ?

Link to comment
Share on other sites

@Atlasfreeman the player is working when i visit that page, so i don't know why the play button is pausing after you hit it, because that's not happening to me, i can play all of the tracks.  What browser are you using? I'm on firefox and the players work well..

Link to comment
Share on other sites

  • 8 months later...

Can't seem to get this to work on local dev environment. Looks really cool. Just not understanding how to get the player generated.

CSS + JS is loading in the page. I have manually declared swf. I have declared the module in _init.php

I have a text field `tag-audio` with the Soundmanager2 textformatter applied in the field Details settings pane. I have Tags enabled on the file field and am using `audio` as the tag on the file.

I have the Assets Output Method set to Module API.

Seems like I tried everything but neither this nor this works.

// in Latte this doesn't work
{var $options = ['type' => 'bar-ui', 'skin' => 'gradient-fat',]}
{$sm2->player($page->audio, $options)}


// neither does calling the shortcode directly from the textformatter field
{$pages->get('song-1')->tag_audio} // [smplayer tag=audio]

Screen Shot 2023-02-01 at 1.19.15 PM.png

Screen Shot 2023-02-01 at 1.20.51 PM.png

Link to comment
Share on other sites

@protro

(1) the way the tag field would work is if you had a page somewhere holding a whole bunch of audio files, and you had a page reference field on that page named "media_tags", and you added a "tag" (page reference) to that field, say using like ASM select, and the tag was called "Sunday", then you would use the playlist tag, like [smplaylist tag=Sunday], in a textarea or text field, then it is supposed to output that whole playlist.

(2) To get the players to output in your scenario, all you would need to do is echo $page->tag_audio.  Because you need to echo the field holding the shortcode, so that will initiate the processShortCode() method.

You don't need to use the shortcode though - especially in how you have it setup. The shortcode is really for putting players inside other content, like long articles where the players are between paragraphs.

For your application you can just init the module and then do this:

echo $sm2->player($page->audio, $options);

It should work if your audio field is a single or multiple files field.

I would use TracyDebugger to check to see what $sm2 is at the point of where you are echoing it.

Link to comment
Share on other sites

Thank you @Macrura I finally got the player GUI to load, but am getting errors and nothing will play. I suppose I am not understanding what $page->audio is really doing. Is that a ProcessWire Audio class on any page? is `audio` the name of a tag?

I installed Tracy and don't really understand what these errors mean. I'm doing exactly what is in your documentation.

I am attempting to put a playlist on the homepage sidebar using this include playlist.php

<?php

$options = [
    'type' => 'bar-ui',
    'skin' => 'gradient-fat',
  ];

echo $sm2->player($page->audio, $options);

But the page with the Audio File Field is called 'Song-1'. I have a template called Songs with children Song-1, Song-2, etc. and I am trying to add them to a playlist.

So I thought $page->audio looks like it's trying to reference the current page, let me try $pages->get('template=Song')->audio … but that does not seem to work.

Thanks for your help I feel like this is almost working. Took a long time just getting the GUI up.

 

Screen Shot 2023-02-01 at 6.29.13 PM.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...