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

It work now... 🤣 But I haven't done anything. Maybe it just needed some time. 

Now i need to try it out on another page. I wish i could say what I did to the community but i really don't know.

Again thank you a lot for the help!

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...