Merge pull request #17622 from edx/waheed/LEARNER-4167-return-hls-in-encoded-videos

Enable HLS video encodings for mobile.
This commit is contained in:
Waheed Ahmed
2018-03-13 15:37:21 +05:00
committed by GitHub
2 changed files with 28 additions and 0 deletions

View File

@@ -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={

View File

@@ -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)