2222from django .conf import settings
2323from edx_django_utils .cache import RequestCache
2424from lxml import etree
25+ from opaque_keys .edx .keys import CourseKey
2526from opaque_keys .edx .locator import AssetLocator
2627from web_fragments .fragment import Fragment
2728from xblock .completable import XBlockCompletionMode
3132from xblocks_contrib .video import VideoBlock as _ExtractedVideoBlock
3233
3334from common .djangoapps .xblock_django .constants import ATTR_KEY_REQUEST_COUNTRY_CODE , ATTR_KEY_USER_ID
34- from openedx .core .djangoapps .video_config .models import HLSPlaybackEnabledFlag , CourseYoutubeBlockedFlag
35- from openedx .core .djangoapps .video_config .toggles import TRANSCRIPT_FEEDBACK
36- from openedx .core .djangoapps .video_pipeline .config .waffle import DEPRECATE_YOUTUBE
3735from openedx .core .lib .cache_utils import request_cached
3836from openedx .core .lib .license import LicenseMixin
3937from xmodule .contentstore .content import StaticContent
106104EXPORT_IMPORT_STATIC_DIR = 'static'
107105
108106
109- @XBlock .wants ('settings' , 'completion' , 'i18n' , 'request_cache' )
110- @XBlock .needs ('mako' , 'user' , 'video_config' )
107+ @XBlock .wants ('settings' , 'completion' , 'i18n' , 'request_cache' , 'video_config' )
108+ @XBlock .needs ('mako' , 'user' )
111109class _BuiltInVideoBlock (
112110 VideoFields , VideoTranscriptsMixin , VideoStudioViewHandlers , VideoStudentViewHandlers ,
113111 EmptyDataRawMixin , XmlMixin , EditingMixin , XModuleToXBlockMixin ,
@@ -188,18 +186,26 @@ def get_transcripts_for_student(self, transcripts, dest_lang=None):
188186 sorted_languages = OrderedDict (sorted_languages )
189187 return track_url , transcript_language , sorted_languages
190188
189+ def is_hls_playback_enabled (self , course_id : CourseKey ) -> bool :
190+ """
191+ Check if HLS playback is enabled for the course.
192+ """
193+ video_config_service = self .runtime .service (self , 'video_config' )
194+ return video_config_service .is_hls_playback_enabled (course_id ) if video_config_service else False
195+
191196 @property
192197 def youtube_deprecated (self ):
193198 """
194199 Return True if youtube is deprecated and hls as primary playback is enabled else False
195200 """
201+ video_config_service = self .runtime .service (self , 'video_config' )
196202 # Return False if `hls` playback feature is disabled.
197- if not HLSPlaybackEnabledFlag . feature_enabled (self .location .course_key ):
203+ if not self . is_hls_playback_enabled (self .location .course_key ):
198204 return False
199205
200206 # check if youtube has been deprecated and hls as primary playback
201207 # is enabled for this course
202- return DEPRECATE_YOUTUBE . is_enabled (self .location .course_key )
208+ return video_config_service . is_youtube_deprecated (self .location .course_key ) if video_config_service else False
203209
204210 def youtube_disabled_for_course (self ): # lint-amnesty, pylint: disable=missing-function-docstring
205211 if not self .location .context_key .is_course :
@@ -209,7 +215,9 @@ def youtube_disabled_for_course(self): # lint-amnesty, pylint: disable=missing-
209215 if cache_response .is_found :
210216 return cache_response .value
211217
212- youtube_is_disabled = CourseYoutubeBlockedFlag .feature_enabled (self .location .course_key )
218+ video_config_service = self .runtime .service (self , 'video_config' )
219+ youtube_is_disabled = video_config_service .is_youtube_blocked_for_course (
220+ self .location .course_key ) if video_config_service else False
213221 request_cache .set (self .location .context_key , youtube_is_disabled )
214222 return youtube_is_disabled
215223
@@ -300,7 +308,7 @@ def get_html(self, view=STUDENT_VIEW, context=None): # lint-amnesty, pylint: di
300308 try :
301309 val_profiles = ["youtube" , "desktop_webm" , "desktop_mp4" ]
302310
303- if HLSPlaybackEnabledFlag . feature_enabled (self .course_id ):
311+ if self . is_hls_playback_enabled (self .course_id ):
304312 val_profiles .append ('hls' )
305313
306314 # strip edx_video_id to prevent ValVideoNotFoundError error if unwanted spaces are there. TNL-5769
@@ -499,7 +507,9 @@ def is_transcript_feedback_enabled(self):
499507 return False # Only courses support this feature at all (not libraries)
500508 try :
501509 # Video transcript feedback must be enabled in order to show the widget
502- feature_enabled = TRANSCRIPT_FEEDBACK .is_enabled (self .context_key )
510+ video_config_service = self .runtime .service (self , 'video_config' )
511+ feature_enabled = video_config_service .is_transcript_feedback_enabled (
512+ self .context_key ) if video_config_service else False
503513 except Exception as err : # pylint: disable=broad-except
504514 log .exception (f"Error retrieving course for course ID: { self .context_key } " )
505515 return False
@@ -881,7 +891,7 @@ def get_youtube_link(video_id):
881891 if self .edx_video_id and edxval_api :
882892
883893 val_profiles = ['youtube' , 'desktop_webm' , 'desktop_mp4' ]
884- if HLSPlaybackEnabledFlag . feature_enabled (self .scope_ids .usage_id .context_key .for_branch (None )):
894+ if self . is_hls_playback_enabled (self .scope_ids .usage_id .context_key .for_branch (None )):
885895 val_profiles .append ('hls' )
886896
887897 # Get video encodings for val profiles.
@@ -1137,7 +1147,7 @@ def student_view_data(self, context=None):
11371147 # Check in VAL data first if edx_video_id exists
11381148 if self .edx_video_id :
11391149 video_profile_names = context .get ("profiles" , ["mobile_low" , 'desktop_mp4' , 'desktop_webm' , 'mobile_high' ])
1140- if HLSPlaybackEnabledFlag . feature_enabled (self .location .course_key ) and 'hls' not in video_profile_names :
1150+ if self . is_hls_playback_enabled (self .location .course_key ) and 'hls' not in video_profile_names :
11411151 video_profile_names .append ('hls' )
11421152
11431153 # get and cache bulk VAL data for course
0 commit comments