canvas-lms/lib/api/v1/media_object.rb

39 lines
1.3 KiB
Ruby
Raw Normal View History

Use html5 to show videos by default using a library called mediaElement.js, try to show all kaltura video and audio using html5 and fall back on flash if needed. Test Plan: * in all the different browsers (including mobile safari/chrome) * try recording webcam videos (as homework submission, as content in a wiki page, etc) * view those same pages * view recorded submission in speedgrader use the playlist urls to get kaltura urls This will get CDN-configured links from Kaltura instead of direct Kaltura links. It also allows for the case where a MediaObject does not exist. When one is requested, it will be created in the database and details fetched. Test Plan for cdn urls: * Make sure kaltura is enabled * Open your web inspector's network tab * Browse to a recorded media file in Canvas, and play it * Ensure that the file is streamed from kaltura's configured CDN (s3 in the case of instructure). Test Plan for nonexistent MediaObjects: * Make sure kaltura is enabled * In a wiki page, record a media comment * Destroy that MediaObject from the database (use Inspect Element to find the media_id which looks like 0_1234abcd) * Reload the page, and verify that you can still view the video fix error when viewing a video file that has an unknown source type There are some videos that have valid sources that don't have an extension for some reason. This fixes handling of those correctly. There was also a bug that would sort by bitrate as strings, instead of as integers. The sort function was refactored out and tests written to ensure that's fixed. Test Plan * find a video in kaltura that has an asset with no extension, and make sure you can view that video in a wiki page refs #CNVS-324 Change-Id: I8ff24a94b8af11fc29b84e45545f8a8b639eeaff Reviewed-on: https://gerrit.instructure.com/16824 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Bracken Mosbacker <bracken@instructure.com> QA-Review: Adam Phillipps <adam@instructure.com>
2013-01-16 05:14:29 +08:00
#
# Copyright (C) 2011 - present Instructure, Inc.
Use html5 to show videos by default using a library called mediaElement.js, try to show all kaltura video and audio using html5 and fall back on flash if needed. Test Plan: * in all the different browsers (including mobile safari/chrome) * try recording webcam videos (as homework submission, as content in a wiki page, etc) * view those same pages * view recorded submission in speedgrader use the playlist urls to get kaltura urls This will get CDN-configured links from Kaltura instead of direct Kaltura links. It also allows for the case where a MediaObject does not exist. When one is requested, it will be created in the database and details fetched. Test Plan for cdn urls: * Make sure kaltura is enabled * Open your web inspector's network tab * Browse to a recorded media file in Canvas, and play it * Ensure that the file is streamed from kaltura's configured CDN (s3 in the case of instructure). Test Plan for nonexistent MediaObjects: * Make sure kaltura is enabled * In a wiki page, record a media comment * Destroy that MediaObject from the database (use Inspect Element to find the media_id which looks like 0_1234abcd) * Reload the page, and verify that you can still view the video fix error when viewing a video file that has an unknown source type There are some videos that have valid sources that don't have an extension for some reason. This fixes handling of those correctly. There was also a bug that would sort by bitrate as strings, instead of as integers. The sort function was refactored out and tests written to ensure that's fixed. Test Plan * find a video in kaltura that has an asset with no extension, and make sure you can view that video in a wiki page refs #CNVS-324 Change-Id: I8ff24a94b8af11fc29b84e45545f8a8b639eeaff Reviewed-on: https://gerrit.instructure.com/16824 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Bracken Mosbacker <bracken@instructure.com> QA-Review: Adam Phillipps <adam@instructure.com>
2013-01-16 05:14:29 +08:00
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
module Api::V1::MediaObject
def media_object_api_json(media_object, current_user, session)
hash = {}
Allow uploading subtitle tracks to videos when you upload a video, you will now see a [cc] box in the player for that video if you are the uploader of that video and in a modern browser. it will have a link to upload a caption track in SRT or WebVTT format in any language you specify. once you attach a caption track to any of your videos, other people that view it will be able to choose that track while playing it. helpful for people that are deaf or that speak another language! this change also adds google analytics tracking to videos so we know when a given media_id was played, paused, and ended. Test Plan: * record a video, go to play the video * you should see a [cc] button * click the "upload subtitles" link, a dialog should appear that lets you choose a language and file to upload. here's one you can test with: http://mediaelementjs.com/media/NT113_u008_v005_transcript.srt * refresh, you (and anyone else that can see video) should now have the option to select that track for subtitles. (if using in HTML5 player) * you should see a delete 'x' on it to delete it, when you click it it should go away. reload to make sure it is not there. * The user who created the video, or any admins of the course the video is in should be able to manage these captions closes CNVS-324 Change-Id: Id6d4abcb581f0daf101d601221dc45edaad6eaa8 Reviewed-on: https://gerrit.instructure.com/16882 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Bracken Mosbacker <bracken@instructure.com> QA-Review: Adam Phillipps <adam@instructure.com>
2013-01-16 05:15:42 +08:00
hash['can_add_captions'] = media_object.grants_right?(current_user, session, :add_captions)
hash['media_sources'] = media_object.media_sources&.map do |mo|
mo[:src] = mo[:url]
mo[:label] = "#{(mo[:bitrate].to_i / 1024).floor} kbps"
mo
end
Allow uploading subtitle tracks to videos when you upload a video, you will now see a [cc] box in the player for that video if you are the uploader of that video and in a modern browser. it will have a link to upload a caption track in SRT or WebVTT format in any language you specify. once you attach a caption track to any of your videos, other people that view it will be able to choose that track while playing it. helpful for people that are deaf or that speak another language! this change also adds google analytics tracking to videos so we know when a given media_id was played, paused, and ended. Test Plan: * record a video, go to play the video * you should see a [cc] button * click the "upload subtitles" link, a dialog should appear that lets you choose a language and file to upload. here's one you can test with: http://mediaelementjs.com/media/NT113_u008_v005_transcript.srt * refresh, you (and anyone else that can see video) should now have the option to select that track for subtitles. (if using in HTML5 player) * you should see a delete 'x' on it to delete it, when you click it it should go away. reload to make sure it is not there. * The user who created the video, or any admins of the course the video is in should be able to manage these captions closes CNVS-324 Change-Id: Id6d4abcb581f0daf101d601221dc45edaad6eaa8 Reviewed-on: https://gerrit.instructure.com/16882 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Bracken Mosbacker <bracken@instructure.com> QA-Review: Adam Phillipps <adam@instructure.com>
2013-01-16 05:15:42 +08:00
hash['media_tracks'] = media_object.media_tracks.map do |track|
api_json(track, current_user, session, :only => %w(kind created_at updated_at id locale)).tap do |json|
json.merge! :url => show_media_tracks_url(media_object.media_id, track.id)
end
end
Use html5 to show videos by default using a library called mediaElement.js, try to show all kaltura video and audio using html5 and fall back on flash if needed. Test Plan: * in all the different browsers (including mobile safari/chrome) * try recording webcam videos (as homework submission, as content in a wiki page, etc) * view those same pages * view recorded submission in speedgrader use the playlist urls to get kaltura urls This will get CDN-configured links from Kaltura instead of direct Kaltura links. It also allows for the case where a MediaObject does not exist. When one is requested, it will be created in the database and details fetched. Test Plan for cdn urls: * Make sure kaltura is enabled * Open your web inspector's network tab * Browse to a recorded media file in Canvas, and play it * Ensure that the file is streamed from kaltura's configured CDN (s3 in the case of instructure). Test Plan for nonexistent MediaObjects: * Make sure kaltura is enabled * In a wiki page, record a media comment * Destroy that MediaObject from the database (use Inspect Element to find the media_id which looks like 0_1234abcd) * Reload the page, and verify that you can still view the video fix error when viewing a video file that has an unknown source type There are some videos that have valid sources that don't have an extension for some reason. This fixes handling of those correctly. There was also a bug that would sort by bitrate as strings, instead of as integers. The sort function was refactored out and tests written to ensure that's fixed. Test Plan * find a video in kaltura that has an asset with no extension, and make sure you can view that video in a wiki page refs #CNVS-324 Change-Id: I8ff24a94b8af11fc29b84e45545f8a8b639eeaff Reviewed-on: https://gerrit.instructure.com/16824 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Bracken Mosbacker <bracken@instructure.com> QA-Review: Adam Phillipps <adam@instructure.com>
2013-01-16 05:14:29 +08:00
hash
end
end