Advertisement
Guest User

Closed Captioning in Church Online Platform

a guest
Apr 5th, 2020
503
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 10.77 KB | None | 0 0
  1. How to add closed captioning links to the Church Online Platform v3 (sites that end in .churchonline.org not those that end in .online.church). This requires you having two video embeds available, one with closed captioning and one without.
  2.  
  3. We use LivingAsOne and have 2 web encoders to do this. One of them is being fed with a feed from our switcher without captions, the other has audio going to a computer's mic which is on https://webcaptioner.com/ giving us captions in realtime. They are keyed out on the switcher and overlaid and sent to the second web encoder.
  4.  
  5. With that we now have two LA1 embed links. One with captions, one without. Now how do we get this on our site for users?
  6.  
  7. ----------------------------------------------------
  8.  
  9. Method 1: High/Low
  10. This doesn't work on mobile devices. Use Method 2 if you wan that. Use the built in "high" and "low" embed fields to embed "normal" and "caption" feeds. Having an embed code in both video fields will activate code that puts a "watch in low quality" and "watch in high quality" link respectively on your page. We can use JavaScript to change that text to read "Turn Captions On" and "Turn Captions Off" instead.
  11.  
  12. Edit your ChOP theme template (themes -> edit -> HTML -> template) and around line 118 or so, find:
  13.     <div class="row full-width event-details">
  14.       <div class="medium-7 columns">
  15.         <div>
  16.           <h2>{{ event.title }} <small>{{ event.speaker }}</small></h2>
  17.           <p>{{ event.description }}</p>
  18.           {{ component.next_service_time }}
  19.         </div>
  20.         <div class="share">
  21.           {% if settings.show_social == '1' %}
  22.             <h6>{{ 'share' | translate }}</h6>
  23.             {{ component.share }}
  24.             {% endif %}
  25.           {{ component.quality_switch }}
  26.         </div>
  27.       </div>
  28.  
  29. We're swapping the shortcode {{ component.quality_switch }} with the code it usually pulls, adding our own id attribute to it of "captiontoggle" and moving it all above the Event Title so it is just under the player window, so replace that code with:
  30.     <div class="row full-width event-details">
  31.       <div class="medium-7 columns">
  32.         <div>
  33.           <div id="captiontoggle" class="co-quality-switch" data-behavior="quality_switch" style="margin: -15px 0 10px;"></div>
  34.           <h2>{{ event.title }} <small>{{ event.speaker }}</small></h2>
  35.           <p>{{ event.description }}</p>
  36.           {{ component.next_service_time }}
  37.         </div>
  38.         <div class="share">
  39.           {% if settings.show_social == '1' %}
  40.             <h6>{{ 'share' | translate }}</h6>
  41.             {{ component.share }}
  42.             {% endif %}
  43.         </div>
  44.       </div>
  45.  
  46. Now we need to edit our high and low embed codes for the video on the event. Here is my regular feed with code to relabel "watch low quality" with "turn captions on". You'll notice I added a script before the embed code that holds a function called "ccrewrite2" and it looks for the div on the page with the ID "captiontoggle" which we set in our template above.
  47.  
  48. It then looks for the parent of that div and replaces the innerHTML of it's child. I couldn't get this to work any other way (like just replacing the outerHTML of captiontoggle) as they have unknown code that runs based on the data-behavior="quality_switch" tag and removing that broke the links.
  49.  
  50. Other than my script here before the embed code, you'll notice I added an onload="ccrewrite2()" to the script my embed code already had in it. This means that every time the video embed is called, it runs that code to relabel the link "turn captions on." (I'm curious if I simplified this by unwrapping my script in the function tag and removing the onload from the second script if it would still run the code correctly, but I no longer have this in place to test.)
  51.  
  52. change your default feed to:
  53. <script>
  54. function ccrewrite2() {
  55.   var xcc = parent.document.getElementById("captiontoggle");
  56.   var ycc = xcc.children[0];
  57.   ycc.innerHTML = "turn captions on";
  58.   }
  59. </script>
  60. <!-- Insert your normal Embed Code here -->
  61. <div id="la1-video-player" data-embed-id="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"></div>
  62. <script onload="ccrewrite2()" type="application/javascript" src="https://control.livingasone.com/webplayer/loader.min.js"></script>
  63. <!-- End of your Embed Code -->
  64.  
  65. change your low feed with code to relabel "watch high quality" with "turn captions off":
  66. <script>
  67. function ccrewrite1() {
  68.   var xcc = parent.document.getElementById("captiontoggle");
  69.   var ycc = xcc.children[0];
  70.   ycc.innerHTML = "turn captions off";
  71.   }
  72. </script>
  73. <!-- Insert your captioned Embed Code here -->
  74. <div id="la1-video-player" data-embed-id="bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"></div>
  75. <script onload="ccrewrite1()" type="application/javascript" src="https://control.livingasone.com/webplayer/loader.min.js"></script>
  76. <!-- End of your Embed Code -->
  77.  
  78. ----------------------------------------------------------------------
  79.  
  80. Method 2: Preview Theme
  81. We set up a second ChOP theme and use their "preview" link for that them to show the captioned embed. This works on desktop and mobile, but involves a dedicated theme for captions that doesn't close the video player based on the ChOP Schedule... This means "on demand" rewatching is possible outside of your service times if they have this link bookmarked or left open from the weekend. Not ideal, but it works. However the "turn captions on" link isn't visible on the normal page outside of service times, so that helps cut down on traffic on the caption page when it shouldn't be there.
  82.  
  83. Create a copy of your theme and add "with captions" or whatever to the end of the name so you know which is which.
  84.  
  85. We need to force the new theme's video embed to have the cc feed and not what the video embed code is from the event page. So edit the template (themes -> edit -> HTML -> template) and look for the shortcode of {{ component.video }} around line 76...
  86.       <div class="medium-8 columns no-padding-right" role="content">
  87.         {{ component.video }}
  88.         {{ component.slides }}
  89.       </div>
  90.  
  91. on the preview theme, change that to (obviously swap your embed code instead of mine):
  92.       <div class="medium-8 columns no-padding-right" role="content">
  93.         <!--change out component.video and embed caption feed -->
  94.         <div class="co-video">
  95.             <!-- Insert your captioned Embed Code here -->
  96.             <div id="la1-video-player" data-embed-id="bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"></div>
  97.             <script type="application/javascript" src="https://control.livingasone.com/webplayer/loader.min.js"></script>
  98.             <!-- End of your Embed Code -->
  99.         </div>
  100.         <!-- end changeout -->
  101.         {{ component.slides }}
  102.       </div>
  103.  
  104. Now your copied theme should always have captions on (but remember it also exists outside the functionality of the ChOP schedule so it no longer closes when it shouldn't be active). We need to insert links to direct people to turn captions on/off... Though we aren't using the high/low quality video embeds, we are using the quality switch code for our link placement just like in method 1 above. So edit the template and around line 127 or so, find (AND you need to do this to your normal template around line 121 or so as well):
  105.     <div class="row full-width event-details">
  106.       <div class="medium-7 columns">
  107.         <div>
  108.           <h2>{{ event.title }} <small>{{ event.speaker }}</small></h2>
  109.           <p>{{ event.description }}</p>
  110.           {{ component.next_service_time }}
  111.         </div>
  112.         <div class="share">
  113.           {% if settings.show_social == '1' %}
  114.             <h6>{{ 'share' | translate }}</h6>
  115.             {{ component.share }}
  116.             {% endif %}
  117.           {{ component.quality_switch }}
  118.         </div>
  119.       </div>
  120.  
  121. We're swapping the shortcode {{ component.quality_switch }} with the <div> code it usually pulls, adding our own id attribute to it of "captiontoggle" and moving it all above the Event Title so it is just under the player window, so replace that code with:
  122.     <div class="row full-width event-details">
  123.       <div class="medium-7 columns">
  124.         <div>
  125.           <div id="captiontoggle" class="co-quality-switch" data-behavior="quality_switch" style="margin: -15px 0 10px;"></div>
  126.           <h2>{{ event.title }} <small>{{ event.speaker }}</small></h2>
  127.           <p>{{ event.description }}</p>
  128.           {{ component.next_service_time }}
  129.         </div>
  130.         <div class="share">
  131.           {% if settings.show_social == '1' %}
  132.             <h6>{{ 'share' | translate }}</h6>
  133.             {{ component.share }}
  134.             {% endif %}
  135.         </div>
  136.       </div>
  137.  
  138. Though mobile doesn't run any code INSIDE that div, that div is still displayed and now that we have an id on it (captiontoggle) we can use that to put in our captioning on/off links. So let's do just that. At the bottom of your copied theme template, find:
  139.   {{ organization.google_analytics_code }}
  140. </body>
  141.  
  142. and change it to (obviously putting your info in for YOURCHURCH):
  143.   {{ organization.google_analytics_code }}
  144.   <script>
  145.     var xcc = parent.document.getElementById("captiontoggle");
  146.     xcc.innerHTML =  "<a href='https://YOURCHURCH.churchonline.org/' class='co-quality-switch'>turn captions off</a>";
  147.   </script>
  148. </body>
  149.  
  150. Now your captioned page will have a working "Turn Captions Off" link. You can click "preview" next to your captioned theme to see this. In fact, you need to preview it so we can get that URL... it should look something like: https://YOURCHURCH.churchonline.org/?preview=true&theme=##### Note that URL for our last step, adding a link to the captions theme from our normal theme.
  151.  
  152. Go to the Events tab and edit your event, click the video tab to see your embed codes, and for the default embed code (and mobile if you have one in there, though you don't need one most likely), add this script to your code (obviously putting your theme preview link in and your normal embed code):
  153. <script>
  154.  var xcc = parent.document.getElementById("captiontoggle");
  155.   xcc.innerHTML =  "<a href='https://YOURCHURCH.churchonline.org/?preview=true&theme=#####' class='co-quality-switch'>turn captions on</a>";
  156. </script>
  157. <!-- Insert your normal Embed Code here -->
  158. <div id="la1-video-player" data-embed-id="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"></div>
  159. <script type="application/javascript" src="https://control.livingasone.com/webplayer/loader.min.js"></script>
  160. <!-- End your Embed Code here -->
  161.  
  162. So this adds the "Turn Captions On" link to your page ONLY WHEN this event's video is live (based on your schedule on ChOP) which is nice! The end result is now that all devices see a "Turn Captions On" link under the video player, and when clicked, are redirected to your copied theme preview link that has the video player swapped out with the hard-coded captioning embed. That theme in turn, has a "Turn Captions Off" link that redirects back to the normal theme.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement