Hi all,
I am looking for a functionality that does not seem to exist - at least I did not find any working solution. All the modules I tried did not check if a user is authenticated or could not get rid of the iFrame upon logging off (thus adding another iFrame each time I log on and off).
I need a function that loads an iFrame (audio player + Drupal website) when a user is authenticated. Likewise, that module would load just the drupal website without the iframe audio player when a user logs off. The audio player should only be accessible for authenticated users!
I found modules that will load a certain page on login, but they can not load the simple page without the iFrame upon logging off because they lack the function to define a target for the website. And they also would not stop an unauthenticated user from accessing the iFrame directly via a deep or direct link.
Does anyone have any ideas how to achieve this in Drupal 7?
Kind regards,
Paul
Comments
You can try the other
You can try the other approach.
The main idea is to create a block with the audio player and restrict access for this block for anonymous users.
For restricting access to audio files they will be uploaded to the private folder.
The steps to accomplish this:
1. Install 'AudioField' and 'Content Access' modules.
2. Create content type with file field.
3. Restrict access to this content type for anonymous users.
4. Create a node of this content type and upload an audio file.
5. Create a view block for display the field of this content.
6. In the field's settings select 'AudioField player' formatter.
7. Restrict access for this block for anonymous users.
See the screenshots:
https://cdn1.imggmi.com/uploads/2019/7/24/ae2f76d55b7a25ba74a7ba537e4250...
https://cdn1.imggmi.com/uploads/2019/7/24/f658309ce9439b8326f5d52823fc67...
https://cdn1.imggmi.com/uploads/2019/7/24/767945f28582ad4e96f9a514d2e344...
https://cdn1.imggmi.com/uploads/2019/7/24/4b67b7ec8b469a4ba62550ca2ce265...
https://cdn1.imggmi.com/uploads/2019/7/24/7024a04a71f166dd0a7298cf9aba75...
https://cdn1.imggmi.com/uploads/2019/7/24/c307f6b5c64b3083ffc2e997219973...
https://cdn1.imggmi.com/uploads/2019/7/24/4c9b17a3143274f4df74febb303fb5...
https://cdn1.imggmi.com/uploads/2019/7/24/880f09ac596ba966084f184923b9c3...
https://cdn1.imggmi.com/uploads/2019/7/24/2d9c5b39e81c177fd15f768eaefd51...
https://cdn1.imggmi.com/uploads/2019/7/24/ffeecb87ad7be12cc408fe5853dfed...
As an alternative to 'AudioField' you can use 'jPlayer' module.
Will not offer persistent audio
Thanks for the ideas :-) This approach will not work even tough it is a nice idea. Whenever a user navigates the page the audio will be lost because of a page reload. The only way to keep audio peristent is to place it somewhere where it will not be reloaded.
For this an iFrame is needed. The only other way would be to change the whole page navigation to ajax. Been there, done that. Unfortunately Ajax Pages is having so many conflicts with other modules that it is not usable, and the support is nonexistent. So iFrames offers the best solution so far.
Sorry, at first I didn't
Sorry, at first I didn't realize the task.
Now I got it, and I'll think about it.
An iframe isn't going to
An iframe isn't going to provide persistent audio, as the frame will be lost when the user navigates between pages.
For something like this, you need to set up a fully ajaxified site, so that any navigation around the site results in the new content being loaded without re-loading the entire page. Then you can have a player (doesn't need to be an iframe) to do this.
Unfortunately, there's not an easy way to do the above in Drupal.
Contact me to contract me for D7 -> D10/11 migrations.
iFrame works perfectly
As I have already tries this, the iFrame works perfectly. In fact the iFrame is the only thing that enables persistent audio while the user is navigating the drupal website below.
The ajax pages would be an alternative if they wouldn't mess up a lot of other functions on the page such as the wysiwyg module or the views autorefresh. And this is producing a ton of js errors in the console.
I have implemented the
I have implemented the persistent audio and the site in iFrame.
If this is still actual, then I can share the solution.
Yes please.
I'd love to hear your thoughts on creating an iFrame solution.
See the guide: "How to create
See the guide: "How to create a persistent audio with an iFrame, not using the 'Ajax pages' module".
Great
Hello Wombatbuddy,
thank you for the great documentation. I will try that out immediatelly. Specilally the part about the iFrame integretion is exactly what I was looking for. As for the proctected audio files that is great but unnessessary as I want to integrete a HTML5 Player to stream a webradio (Icecast stream).
I'll give feedback once I got this working.
Regards,
Paul
In this case you probably
In this case you probably needn't to install additional contrib modules.
And the code of 'html--player_and_iframe.tpl.php' file may look like this:
Not quite there yet
Sorry, did not get it to work.
Started a point 9 in your guide because I do not have the requirement to play files.
Created the content type with the name: 'player_and_iframe'.
Created a node 'player_and_iframe' with the name player as title and as an URL alias.
Could not load the player_amd_iframe node. Here is where I hit the first obstacle. When trying to open that node the server said: "Forbidden. You don't have permission to access /player/ on this server."
After that I created a folder "myframe" in the /htdocs/sites/all/modules" directory.
Inside that directory I created the file "myframe.module" with your content (taking care to replace "my_module" with "myframe".
After that I created the file "html--player_and_iframe.tpl.php" and places it in the template folder of my current theme. Here is the file's content:
Note that I removed the autoplay function.
After this I created the "logout_handler.js" file in the js folder of my current theme (Responsive Bartik).
Finally I added the line "
scripts[] = js/logout_handler.js"to "/htdocs/sites/all/themes/responsive_bartik/responsive_bartik.info".I cleared the cache, rebuild all permissions and logged in as a non-admin registered user and nothing appeared.
What did I miss?
1. I think, that you need
1. I think, that you need first to fix the access issue.
You must enable to view the node with 'player' alias without additional manipulation.
"Backap" to step 9 and make visible the node with 'plaer' alias.
Ensure that the current user has the permission to view a published content.
If you use the 'Content Access' module then give the permission for current user.
2. When you fix the access issue you need to install your custom module.
Create the 'myframe.info' file and install the module.
See 'Telling Drupal about your module'.
Thank you so much Wombatbuddy
<html>
Super!
Tried that before and it did not work. This time I noticed that I needed to reduce the height="100%" to height="92%" for the audio player to show. Sorry, should have noticed that myself :-)
Thanks again.
Paul
Caching Issue?
After testing this for a while I noticed, that sometimes the audioplayer will not appear. I found out that I had to delete the browser cache to make the player appear again. So after some help from Google I inserted the following code in the "html--player_and_iframe.tpl.php" file:
So far this seems to have worked. Have to test it a bil longer though to make sure it is so.
Have a great Sunday,
Paul
Nice work Wombatbuddy.
Nice work Wombatbuddy.
Contact me to contract me for D7 -> D10/11 migrations.
Thanks, Jaypan, I'm trying to
Thanks, Jaypan, I'm trying to follow your lead :)
By the way, how's it going with your book?