{"action":"created","comment":{"url":"https://api.github.com/repos/oppia/oppia/pulls/comments/132121279","pull_request_review_id":55151340,"id":132121279,"diff_hunk":"@@ -0,0 +1,101 @@\n+// Copyright 2017 The Oppia Authors. All Rights Reserved.\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+//      http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS-IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+/**\n+ * @fileoverview Service to preload audio into AssetsBackendApiService's cache.\n+ */\n+\n+oppia.factory('AudioPreloaderService', [\n+  '$modal', 'explorationContextService', 'AssetsBackendApiService',\n+  'ExplorationPlayerStateService', 'UrlInterpolationService',\n+  function($modal, explorationContextService, AssetsBackendApiService,\n+      ExplorationPlayerStateService, UrlInterpolationService) {\n+    var NUM_BYTES_IN_MB = 1000;\n+    var _hasPreloaded = false;\n+    var _excludedFilename = null;\n+\n+    var _preload = function() {\n+      var allAudioTranslations =\n+        ExplorationPlayerStateService\n+          .getExploration().getAllAudioTranslations();\n+      for (var languageCode in allAudioTranslations) {\n+        var audioTranslation = allAudioTranslations[languageCode];\n+        if (audioTranslation.filename !== _excludedFilename) {\n+          AssetsBackendApiService.loadAudio(\n+            explorationContextService.getExplorationId(),\n+            audioTranslation.filename);\n+        }\n+      }\n+      _hasPreloaded = true;\n+    };\n+\n+    var _showBandwidthConfirmationModal = function(confirmationCallback) {\n+      $modal.open({\n+        templateUrl: UrlInterpolationService.getDirectiveTemplateUrl(\n+          '/pages/exploration_player/' +\n+          'audio_preload_bandwidth_confirmation_modal_directive.html'),\n+        resolve: {},\n+        backdrop: false,\n+        controller: [\n+          '$scope', '$modalInstance',\n+          'ExplorationPlayerStateService', 'AudioPreloaderService',\n+          function(\n+              $scope, $modalInstance,\n+              ExplorationPlayerStateService, AudioPreloaderService) {\n+            $scope.totalFileSizeOfAllAudioTranslationsBytes =\n+              _calculateTotalFileSize(","path":"core/templates/dev/head/pages/exploration_player/AudioPreloaderService.js","position":57,"original_position":57,"commit_id":"22b8f0c3c5c9a663a075e03d22c442014124d1ce","original_commit_id":"22b8f0c3c5c9a663a075e03d22c442014124d1ce","user":{"login":"seanlip","id":10575562,"avatar_url":"https://avatars0.githubusercontent.com/u/10575562?v=4","gravatar_id":"","url":"https://api.github.com/users/seanlip","html_url":"https://github.com/seanlip","followers_url":"https://api.github.com/users/seanlip/followers","following_url":"https://api.github.com/users/seanlip/following{/other_user}","gists_url":"https://api.github.com/users/seanlip/gists{/gist_id}","starred_url":"https://api.github.com/users/seanlip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seanlip/subscriptions","organizations_url":"https://api.github.com/users/seanlip/orgs","repos_url":"https://api.github.com/users/seanlip/repos","events_url":"https://api.github.com/users/seanlip/events{/privacy}","received_events_url":"https://api.github.com/users/seanlip/received_events","type":"User","site_admin":false},"body":"Maybe define this as a method on the exploration object? (Please add tests too.)","created_at":"2017-08-09T08:34:10Z","updated_at":"2017-08-09T08:39:11Z","html_url":"https://github.com/oppia/oppia/pull/3727#discussion_r132121279","pull_request_url":"https://api.github.com/repos/oppia/oppia/pulls/3727","_links":{"self":{"href":"https://api.github.com/repos/oppia/oppia/pulls/comments/132121279"},"html":{"href":"https://github.com/oppia/oppia/pull/3727#discussion_r132121279"},"pull_request":{"href":"https://api.github.com/repos/oppia/oppia/pulls/3727"}}},"pull_request":{"url":"https://api.github.com/repos/oppia/oppia/pulls/3727","id":134804963,"html_url":"https://github.com/oppia/oppia/pull/3727","diff_url":"https://github.com/oppia/oppia/pull/3727.diff","patch_url":"https://github.com/oppia/oppia/pull/3727.patch","issue_url":"https://api.github.com/repos/oppia/oppia/issues/3727","number":3727,"state":"open","locked":false,"title":"Preloading of audio and bandwidth confirmation","user":{"login":"tjiang11","id":11807091,"avatar_url":"https://avatars2.githubusercontent.com/u/11807091?v=4","gravatar_id":"","url":"https://api.github.com/users/tjiang11","html_url":"https://github.com/tjiang11","followers_url":"https://api.github.com/users/tjiang11/followers","following_url":"https://api.github.com/users/tjiang11/following{/other_user}","gists_url":"https://api.github.com/users/tjiang11/gists{/gist_id}","starred_url":"https://api.github.com/users/tjiang11/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjiang11/subscriptions","organizations_url":"https://api.github.com/users/tjiang11/orgs","repos_url":"https://api.github.com/users/tjiang11/repos","events_url":"https://api.github.com/users/tjiang11/events{/privacy}","received_events_url":"https://api.github.com/users/tjiang11/received_events","type":"User","site_admin":false},"body":"- Users are asked to confirm bandwidth usage when trying to download audio\r\n- Audio is loaded and cached after confirming bandwidth usage","created_at":"2017-08-09T03:54:56Z","updated_at":"2017-08-09T08:39:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d8992d76447ab789e41458620cdcbcb1befedafd","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/oppia/oppia/pulls/3727/commits","review_comments_url":"https://api.github.com/repos/oppia/oppia/pulls/3727/comments","review_comment_url":"https://api.github.com/repos/oppia/oppia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/oppia/oppia/issues/3727/comments","statuses_url":"https://api.github.com/repos/oppia/oppia/statuses/22b8f0c3c5c9a663a075e03d22c442014124d1ce","head":{"label":"tjiang11:preload-audio","ref":"preload-audio","sha":"22b8f0c3c5c9a663a075e03d22c442014124d1ce","user":{"login":"tjiang11","id":11807091,"avatar_url":"https://avatars2.githubusercontent.com/u/11807091?v=4","gravatar_id":"","url":"https://api.github.com/users/tjiang11","html_url":"https://github.com/tjiang11","followers_url":"https://api.github.com/users/tjiang11/followers","following_url":"https://api.github.com/users/tjiang11/following{/other_user}","gists_url":"https://api.github.com/users/tjiang11/gists{/gist_id}","starred_url":"https://api.github.com/users/tjiang11/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjiang11/subscriptions","organizations_url":"https://api.github.com/users/tjiang11/orgs","repos_url":"https://api.github.com/users/tjiang11/repos","events_url":"https://api.github.com/users/tjiang11/events{/privacy}","received_events_url":"https://api.github.com/users/tjiang11/received_events","type":"User","site_admin":false},"repo":{"id":73205489,"name":"oppia","full_name":"tjiang11/oppia","owner":{"login":"tjiang11","id":11807091,"avatar_url":"https://avatars2.githubusercontent.com/u/11807091?v=4","gravatar_id":"","url":"https://api.github.com/users/tjiang11","html_url":"https://github.com/tjiang11","followers_url":"https://api.github.com/users/tjiang11/followers","following_url":"https://api.github.com/users/tjiang11/following{/other_user}","gists_url":"https://api.github.com/users/tjiang11/gists{/gist_id}","starred_url":"https://api.github.com/users/tjiang11/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjiang11/subscriptions","organizations_url":"https://api.github.com/users/tjiang11/orgs","repos_url":"https://api.github.com/users/tjiang11/repos","events_url":"https://api.github.com/users/tjiang11/events{/privacy}","received_events_url":"https://api.github.com/users/tjiang11/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tjiang11/oppia","description":"Tool for collaboratively building interactive lessons.","fork":true,"url":"https://api.github.com/repos/tjiang11/oppia","forks_url":"https://api.github.com/repos/tjiang11/oppia/forks","keys_url":"https://api.github.com/repos/tjiang11/oppia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tjiang11/oppia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tjiang11/oppia/teams","hooks_url":"https://api.github.com/repos/tjiang11/oppia/hooks","issue_events_url":"https://api.github.com/repos/tjiang11/oppia/issues/events{/number}","events_url":"https://api.github.com/repos/tjiang11/oppia/events","assignees_url":"https://api.github.com/repos/tjiang11/oppia/assignees{/user}","branches_url":"https://api.github.com/repos/tjiang11/oppia/branches{/branch}","tags_url":"https://api.github.com/repos/tjiang11/oppia/tags","blobs_url":"https://api.github.com/repos/tjiang11/oppia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tjiang11/oppia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tjiang11/oppia/git/refs{/sha}","trees_url":"https://api.github.com/repos/tjiang11/oppia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tjiang11/oppia/statuses/{sha}","languages_url":"https://api.github.com/repos/tjiang11/oppia/languages","stargazers_url":"https://api.github.com/repos/tjiang11/oppia/stargazers","contributors_url":"https://api.github.com/repos/tjiang11/oppia/contributors","subscribers_url":"https://api.github.com/repos/tjiang11/oppia/subscribers","subscription_url":"https://api.github.com/repos/tjiang11/oppia/subscription","commits_url":"https://api.github.com/repos/tjiang11/oppia/commits{/sha}","git_commits_url":"https://api.github.com/repos/tjiang11/oppia/git/commits{/sha}","comments_url":"https://api.github.com/repos/tjiang11/oppia/comments{/number}","issue_comment_url":"https://api.github.com/repos/tjiang11/oppia/issues/comments{/number}","contents_url":"https://api.github.com/repos/tjiang11/oppia/contents/{+path}","compare_url":"https://api.github.com/repos/tjiang11/oppia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tjiang11/oppia/merges","archive_url":"https://api.github.com/repos/tjiang11/oppia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tjiang11/oppia/downloads","issues_url":"https://api.github.com/repos/tjiang11/oppia/issues{/number}","pulls_url":"https://api.github.com/repos/tjiang11/oppia/pulls{/number}","milestones_url":"https://api.github.com/repos/tjiang11/oppia/milestones{/number}","notifications_url":"https://api.github.com/repos/tjiang11/oppia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tjiang11/oppia/labels{/name}","releases_url":"https://api.github.com/repos/tjiang11/oppia/releases{/id}","deployments_url":"https://api.github.com/repos/tjiang11/oppia/deployments","created_at":"2016-11-08T16:31:40Z","updated_at":"2016-11-08T16:31:44Z","pushed_at":"2017-08-09T03:54:42Z","git_url":"git://github.com/tjiang11/oppia.git","ssh_url":"git@github.com:tjiang11/oppia.git","clone_url":"https://github.com/tjiang11/oppia.git","svn_url":"https://github.com/tjiang11/oppia","homepage":"https://www.oppia.org","size":67528,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"oppia:develop","ref":"develop","sha":"8410ed486f0148b67c333d8a5b3fa9e44697a1e3","user":{"login":"oppia","id":11620230,"avatar_url":"https://avatars1.githubusercontent.com/u/11620230?v=4","gravatar_id":"","url":"https://api.github.com/users/oppia","html_url":"https://github.com/oppia","followers_url":"https://api.github.com/users/oppia/followers","following_url":"https://api.github.com/users/oppia/following{/other_user}","gists_url":"https://api.github.com/users/oppia/gists{/gist_id}","starred_url":"https://api.github.com/users/oppia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oppia/subscriptions","organizations_url":"https://api.github.com/users/oppia/orgs","repos_url":"https://api.github.com/users/oppia/repos","events_url":"https://api.github.com/users/oppia/events{/privacy}","received_events_url":"https://api.github.com/users/oppia/received_events","type":"Organization","site_admin":false},"repo":{"id":40687563,"name":"oppia","full_name":"oppia/oppia","owner":{"login":"oppia","id":11620230,"avatar_url":"https://avatars1.githubusercontent.com/u/11620230?v=4","gravatar_id":"","url":"https://api.github.com/users/oppia","html_url":"https://github.com/oppia","followers_url":"https://api.github.com/users/oppia/followers","following_url":"https://api.github.com/users/oppia/following{/other_user}","gists_url":"https://api.github.com/users/oppia/gists{/gist_id}","starred_url":"https://api.github.com/users/oppia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oppia/subscriptions","organizations_url":"https://api.github.com/users/oppia/orgs","repos_url":"https://api.github.com/users/oppia/repos","events_url":"https://api.github.com/users/oppia/events{/privacy}","received_events_url":"https://api.github.com/users/oppia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/oppia/oppia","description":"Tool for collaboratively building interactive lessons.","fork":false,"url":"https://api.github.com/repos/oppia/oppia","forks_url":"https://api.github.com/repos/oppia/oppia/forks","keys_url":"https://api.github.com/repos/oppia/oppia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/oppia/oppia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/oppia/oppia/teams","hooks_url":"https://api.github.com/repos/oppia/oppia/hooks","issue_events_url":"https://api.github.com/repos/oppia/oppia/issues/events{/number}","events_url":"https://api.github.com/repos/oppia/oppia/events","assignees_url":"https://api.github.com/repos/oppia/oppia/assignees{/user}","branches_url":"https://api.github.com/repos/oppia/oppia/branches{/branch}","tags_url":"https://api.github.com/repos/oppia/oppia/tags","blobs_url":"https://api.github.com/repos/oppia/oppia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/oppia/oppia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/oppia/oppia/git/refs{/sha}","trees_url":"https://api.github.com/repos/oppia/oppia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/oppia/oppia/statuses/{sha}","languages_url":"https://api.github.com/repos/oppia/oppia/languages","stargazers_url":"https://api.github.com/repos/oppia/oppia/stargazers","contributors_url":"https://api.github.com/repos/oppia/oppia/contributors","subscribers_url":"https://api.github.com/repos/oppia/oppia/subscribers","subscription_url":"https://api.github.com/repos/oppia/oppia/subscription","commits_url":"https://api.github.com/repos/oppia/oppia/commits{/sha}","git_commits_url":"https://api.github.com/repos/oppia/oppia/git/commits{/sha}","comments_url":"https://api.github.com/repos/oppia/oppia/comments{/number}","issue_comment_url":"https://api.github.com/repos/oppia/oppia/issues/comments{/number}","contents_url":"https://api.github.com/repos/oppia/oppia/contents/{+path}","compare_url":"https://api.github.com/repos/oppia/oppia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/oppia/oppia/merges","archive_url":"https://api.github.com/repos/oppia/oppia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/oppia/oppia/downloads","issues_url":"https://api.github.com/repos/oppia/oppia/issues{/number}","pulls_url":"https://api.github.com/repos/oppia/oppia/pulls{/number}","milestones_url":"https://api.github.com/repos/oppia/oppia/milestones{/number}","notifications_url":"https://api.github.com/repos/oppia/oppia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/oppia/oppia/labels{/name}","releases_url":"https://api.github.com/repos/oppia/oppia/releases{/id}","deployments_url":"https://api.github.com/repos/oppia/oppia/deployments","created_at":"2015-08-14T00:16:14Z","updated_at":"2017-08-04T11:17:54Z","pushed_at":"2017-08-09T08:37:57Z","git_url":"git://github.com/oppia/oppia.git","ssh_url":"git@github.com:oppia/oppia.git","clone_url":"https://github.com/oppia/oppia.git","svn_url":"https://github.com/oppia/oppia","homepage":"https://www.oppia.org","size":67678,"stargazers_count":341,"watchers_count":341,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":446,"mirror_url":null,"open_issues_count":342,"forks":446,"open_issues":342,"watchers":341,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/oppia/oppia/pulls/3727"},"html":{"href":"https://github.com/oppia/oppia/pull/3727"},"issue":{"href":"https://api.github.com/repos/oppia/oppia/issues/3727"},"comments":{"href":"https://api.github.com/repos/oppia/oppia/issues/3727/comments"},"review_comments":{"href":"https://api.github.com/repos/oppia/oppia/pulls/3727/comments"},"review_comment":{"href":"https://api.github.com/repos/oppia/oppia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/oppia/oppia/pulls/3727/commits"},"statuses":{"href":"https://api.github.com/repos/oppia/oppia/statuses/22b8f0c3c5c9a663a075e03d22c442014124d1ce"}}}}
{"actor":{"display_login":"seanlip"}}