Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
display_name=_("Verification Key"),
help=_(
"Enter the Base64 encoded Verification Key from your Azure Management Portal"
),
default="",
scope=Scope.settings
)
protection_type = String(
display_name=_("Protection Type"),
help=_(
"This can be either blank (meaning unprotected), 'AES', or 'PlayReady'"
),
default="",
scope=Scope.settings
)
token_issuer = String(
display_name=_("Token Issuer"),
help=_(
"This value must match what is in the 'Content Protection' area of the Azure Media Services portal"
),
default="http://openedx.microsoft.com/",
scope=Scope.settings
)
token_scope = String(
display_name=_("Token Scope"),
help=_(
"This value must match what is in the 'Content Protection' area of the Azure Media Services portal"
),
default="urn:xblock-azure-media-services",
scope=Scope.settings
)
captions = List(
"""
The xBlock to play videos from Azure Media Services.
"""
RESOURCE = 'https://rest.media.azure.net'
display_name = String(
display_name=_("Display Name"),
help=_(
"Enter the name that students see for this component. "
"Analytics reports may also use the display name to identify this component."
),
scope=Scope.settings,
default=_("Azure Media Services Video Player"),
)
video_url = String(
display_name=_("Video Url"),
help=_(
"Enter the URL to your published video on Azure Media Services"
),
default="",
scope=Scope.settings
)
edx_video_id = String(
default="",
scope=Scope.settings
)
# Ultimately this should come via some secure means, but this is OK for a PoC
verification_key = String(
display_name=_("Verification Key"),
help=_(
"Enter the Base64 encoded Verification Key from your Azure Management Portal"
default=_("Azure Media Services Video Player"),
)
video_url = String(
display_name=_("Video Url"),
help=_(
"Enter the URL to your published video on Azure Media Services"
),
default="",
scope=Scope.settings
)
edx_video_id = String(
default="",
scope=Scope.settings
)
# Ultimately this should come via some secure means, but this is OK for a PoC
verification_key = String(
display_name=_("Verification Key"),
help=_(
"Enter the Base64 encoded Verification Key from your Azure Management Portal"
),
default="",
scope=Scope.settings
)
protection_type = String(
display_name=_("Protection Type"),
help=_(
"This can be either blank (meaning unprotected), 'AES', or 'PlayReady'"
),
default="",
scope=Scope.settings
)
token_issuer = String(
log = logging.getLogger(__name__)
loader = ResourceLoader(__name__)
# According to edx-platform vertical xblocks
CLASS_PRIORITY = ['video']
@XBlock.needs('i18n')
class AMSXBlock(StudioEditableXBlockMixin, XBlock):
"""
The xBlock to play videos from Azure Media Services.
"""
RESOURCE = 'https://rest.media.azure.net'
display_name = String(
display_name=_("Display Name"),
help=_(
"Enter the name that students see for this component. "
"Analytics reports may also use the display name to identify this component."
),
scope=Scope.settings,
default=_("Azure Media Services Video Player"),
)
video_url = String(
display_name=_("Video Url"),
help=_(
"Enter the URL to your published video on Azure Media Services"
),
default="",
scope=Scope.settings
)
display_name=_("Protection Type"),
help=_(
"This can be either blank (meaning unprotected), 'AES', or 'PlayReady'"
),
default="",
scope=Scope.settings
)
token_issuer = String(
display_name=_("Token Issuer"),
help=_(
"This value must match what is in the 'Content Protection' area of the Azure Media Services portal"
),
default="http://openedx.microsoft.com/",
scope=Scope.settings
)
token_scope = String(
display_name=_("Token Scope"),
help=_(
"This value must match what is in the 'Content Protection' area of the Azure Media Services portal"
),
default="urn:xblock-azure-media-services",
scope=Scope.settings
)
captions = List(
display_name=_("Captions"),
help=_("A list of caption definitions"),
scope=Scope.settings
)
caption_ids = List(
default=[],
scope=Scope.settings
)
help=_(
"Enter the name that students see for this component. "
"Analytics reports may also use the display name to identify this component."
),
scope=Scope.settings,
default=_("Azure Media Services Video Player"),
)
video_url = String(
display_name=_("Video Url"),
help=_(
"Enter the URL to your published video on Azure Media Services"
),
default="",
scope=Scope.settings
)
edx_video_id = String(
default="",
scope=Scope.settings
)
# Ultimately this should come via some secure means, but this is OK for a PoC
verification_key = String(
display_name=_("Verification Key"),
help=_(
"Enter the Base64 encoded Verification Key from your Azure Management Portal"
),
default="",
scope=Scope.settings
)
protection_type = String(
display_name=_("Protection Type"),
help=_(
"This can be either blank (meaning unprotected), 'AES', or 'PlayReady'"
captions = List(
display_name=_("Captions"),
help=_("A list of caption definitions"),
scope=Scope.settings
)
caption_ids = List(
default=[],
scope=Scope.settings
)
transcripts_enabled = Boolean(
display_name=_("Transcripts enabled"),
help=_("Transcripts switch"),
default=True,
scope=Scope.settings
)
download_url = String(
display_name=_("Video Download URL"),
help=_("A download URL"),
scope=Scope.settings
)
# These are what become visible in the Mixin editor
editable_fields = (
'display_name', 'video_url', 'verification_key', 'protection_type',
'token_issuer', 'token_scope', 'captions', 'transcripts_enabled', 'download_url',
'edx_video_id', 'caption_ids'
)
def studio_view(self, context):
"""
Render a form for editing this XBlock.
"""
scope=Scope.settings
)
edx_video_id = String(
default="",
scope=Scope.settings
)
# Ultimately this should come via some secure means, but this is OK for a PoC
verification_key = String(
display_name=_("Verification Key"),
help=_(
"Enter the Base64 encoded Verification Key from your Azure Management Portal"
),
default="",
scope=Scope.settings
)
protection_type = String(
display_name=_("Protection Type"),
help=_(
"This can be either blank (meaning unprotected), 'AES', or 'PlayReady'"
),
default="",
scope=Scope.settings
)
token_issuer = String(
display_name=_("Token Issuer"),
help=_(
"This value must match what is in the 'Content Protection' area of the Azure Media Services portal"
),
default="http://openedx.microsoft.com/",
scope=Scope.settings
)
token_scope = String(
class HelloWorldBlock(XBlock):
"""A simple block: just show some fixed content."""
def fallback_view(self, view_name, context=None): # pylint: disable=W0613
"""Provide a fallback view handler"""
return Fragment(u"Hello, world!")
class HtmlBlock(XBlock):
"""Render content as HTML.
The content can have $PLACEHOLDERS, which will be substituted with values
from the context.
"""
content = String(help="The HTML to display", scope=Scope.content, default=u"<b>DEFAULT</b>")
def fallback_view(self, view_name, context=None):
"""Provide a fallback view handler"""
context = context or {}
return Fragment(Template(self.content).substitute(**context))
@classmethod
def parse_xml(cls, node, runtime, keys, id_generator):
"""
Parse the XML for an HTML block.
The entire subtree under `node` is re-serialized, and set as the
content of the XBlock.
"""
block = runtime.construct_xblock_from_class(cls, keys)