3131from xblocks_contrib .video import VideoBlock as _ExtractedVideoBlock
3232
3333from 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
3734from openedx .core .lib .cache_utils import request_cached
3835from openedx .core .lib .license import LicenseMixin
3936from xmodule .contentstore .content import StaticContent
106103EXPORT_IMPORT_STATIC_DIR = 'static'
107104
108105
109- @XBlock .wants ('settings' , 'completion' , 'i18n' , 'request_cache' )
110- @XBlock .needs ('mako' , 'user' , 'video_config' )
106+ @XBlock .wants ('settings' , 'completion' , 'i18n' , 'request_cache' , 'video_config' )
107+ @XBlock .needs ('mako' , 'user' )
111108class _BuiltInVideoBlock (
112109 VideoFields , VideoTranscriptsMixin , VideoStudioViewHandlers , VideoStudentViewHandlers ,
113110 EmptyDataRawMixin , XmlMixin , EditingMixin , XModuleToXBlockMixin ,
@@ -188,18 +185,26 @@ def get_transcripts_for_student(self, transcripts, dest_lang=None):
188185 sorted_languages = OrderedDict (sorted_languages )
189186 return track_url , transcript_language , sorted_languages
190187
188+ def is_hls_playback_enabled (self , course_id ):
189+ """
190+ Check if HLS playback is enabled for the course.
191+ """
192+ video_config_service = self .runtime .service (self , 'video_config' )
193+ return video_config_service .is_hls_playback_enabled (course_id ) if video_config_service else False
194+
191195 @property
192196 def youtube_deprecated (self ):
193197 """
194198 Return True if youtube is deprecated and hls as primary playback is enabled else False
195199 """
200+ video_config_service = self .runtime .service (self , 'video_config' )
196201 # Return False if `hls` playback feature is disabled.
197- if not HLSPlaybackEnabledFlag . feature_enabled (self .location .course_key ):
202+ if video_config_service and not self . is_hls_playback_enabled (self .location .course_key ):
198203 return False
199204
200205 # check if youtube has been deprecated and hls as primary playback
201206 # is enabled for this course
202- return DEPRECATE_YOUTUBE . is_enabled (self .location .course_key )
207+ return video_config_service . is_youtube_deprecated (self .location .course_key ) if video_config_service else False
203208
204209 def youtube_disabled_for_course (self ): # lint-amnesty, pylint: disable=missing-function-docstring
205210 if not self .location .context_key .is_course :
@@ -209,7 +214,9 @@ def youtube_disabled_for_course(self): # lint-amnesty, pylint: disable=missing-
209214 if cache_response .is_found :
210215 return cache_response .value
211216
212- youtube_is_disabled = CourseYoutubeBlockedFlag .feature_enabled (self .location .course_key )
217+ video_config_service = self .runtime .service (self , 'video_config' )
218+ youtube_is_disabled = video_config_service .is_youtube_blocked_for_course (
219+ self .location .course_key ) if video_config_service else False
213220 request_cache .set (self .location .context_key , youtube_is_disabled )
214221 return youtube_is_disabled
215222
@@ -300,7 +307,7 @@ def get_html(self, view=STUDENT_VIEW, context=None): # lint-amnesty, pylint: di
300307 try :
301308 val_profiles = ["youtube" , "desktop_webm" , "desktop_mp4" ]
302309
303- if HLSPlaybackEnabledFlag . feature_enabled (self .course_id ):
310+ if self . is_hls_playback_enabled (self .course_id ):
304311 val_profiles .append ('hls' )
305312
306313 # strip edx_video_id to prevent ValVideoNotFoundError error if unwanted spaces are there. TNL-5769
@@ -499,7 +506,9 @@ def is_transcript_feedback_enabled(self):
499506 return False # Only courses support this feature at all (not libraries)
500507 try :
501508 # Video transcript feedback must be enabled in order to show the widget
502- feature_enabled = TRANSCRIPT_FEEDBACK .is_enabled (self .context_key )
509+ video_config_service = self .runtime .service (self , 'video_config' )
510+ feature_enabled = video_config_service .is_transcript_feedback_enabled (
511+ self .context_key ) if video_config_service else False
503512 except Exception as err : # pylint: disable=broad-except
504513 log .exception (f"Error retrieving course for course ID: { self .context_key } " )
505514 return False
@@ -881,7 +890,7 @@ def get_youtube_link(video_id):
881890 if self .edx_video_id and edxval_api :
882891
883892 val_profiles = ['youtube' , 'desktop_webm' , 'desktop_mp4' ]
884- if HLSPlaybackEnabledFlag . feature_enabled (self .scope_ids .usage_id .context_key .for_branch (None )):
893+ if self . is_hls_playback_enabled (self .scope_ids .usage_id .context_key .for_branch (None )):
885894 val_profiles .append ('hls' )
886895
887896 # Get video encodings for val profiles.
@@ -1137,7 +1146,7 @@ def student_view_data(self, context=None):
11371146 # Check in VAL data first if edx_video_id exists
11381147 if self .edx_video_id :
11391148 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 :
1149+ if self . is_hls_playback_enabled (self .location .course_key ) and 'hls' not in video_profile_names :
11411150 video_profile_names .append ('hls' )
11421151
11431152 # get and cache bulk VAL data for course
0 commit comments