From c362ff98471fe63801af5e590b3fead2ed33388e Mon Sep 17 00:00:00 2001 From: Waheed Ahmed Date: Tue, 6 Mar 2018 17:22:50 +0500 Subject: [PATCH] Enable HLS video encodings for mobile. Return HLS video encodings from blocks api for mobile. LEARNER-4167 --- .../lib/xmodule/xmodule/tests/test_video.py | 26 +++++++++++++++++++ .../xmodule/video_module/video_module.py | 2 ++ 2 files changed, 28 insertions(+) diff --git a/common/lib/xmodule/xmodule/tests/test_video.py b/common/lib/xmodule/xmodule/tests/test_video.py index 6a27491e99..c8e9f9ead4 100644 --- a/common/lib/xmodule/xmodule/tests/test_video.py +++ b/common/lib/xmodule/xmodule/tests/test_video.py @@ -894,6 +894,32 @@ class VideoDescriptorStudentViewDataTestCase(unittest.TestCase): student_view_data = descriptor.student_view_data() self.assertEquals(student_view_data, expected_student_view_data) + @patch('xmodule.video_module.video_module.HLSPlaybackEnabledFlag.feature_enabled', Mock(return_value=True)) + @patch('xmodule.video_module.video_module.is_val_transcript_feature_enabled_for_course', Mock(return_value=False)) + @patch('edxval.api.get_video_info_for_course_and_profiles', Mock(return_value={})) + @patch('edxval.api.get_video_info') + def test_student_view_data_with_hls_flag(self, mock_get_video_info): + mock_get_video_info.return_value = { + 'url': '/edxval/video/example', + 'edx_video_id': u'example_id', + 'duration': 111.0, + 'client_video_id': u'The example video', + 'encoded_videos': [ + { + 'url': u'http://www.meowmix.com', + 'file_size': 25556, + 'bitrate': 9600, + 'profile': u'hls' + } + ] + } + + descriptor = instantiate_descriptor(edx_video_id='example_id', only_on_web=False) + descriptor.runtime.course_id = MagicMock() + student_view_data = descriptor.student_view_data() + expected_video_data = {u'hls': {'url': u'http://www.meowmix.com', 'file_size': 25556}} + self.assertDictEqual(student_view_data.get('encoded_videos'), expected_video_data) + @ddt.ddt @patch.object(settings, 'YOUTUBE', create=True, new={ diff --git a/common/lib/xmodule/xmodule/video_module/video_module.py b/common/lib/xmodule/xmodule/video_module/video_module.py index b14ab5bbd6..96af974ac9 100644 --- a/common/lib/xmodule/xmodule/video_module/video_module.py +++ b/common/lib/xmodule/xmodule/video_module/video_module.py @@ -1028,6 +1028,8 @@ class VideoDescriptor(VideoFields, VideoTranscriptsMixin, VideoStudioViewHandler # Check in VAL data first if edx_video_id exists if self.edx_video_id: video_profile_names = context.get("profiles", ["mobile_low"]) + if HLSPlaybackEnabledFlag.feature_enabled(self.location.course_key) and 'hls' not in video_profile_names: + video_profile_names.append('hls') # get and cache bulk VAL data for course val_course_data = self.get_cached_val_data_for_course(video_profile_names, self.location.course_key)