Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-62336

Generate unique IDs for multiple videos

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.4, 3.4.3
    • Fix Version/s: 3.4.4, 3.5.1
    • Component/s: Media
    • Labels:
    • Testing Instructions:
      Hide
      1. Login as an admin
      2. Go to "Site administration / Plugins / Media players / Manage media players"
      3. Make sure that "VideoJS player" is enabled and on the top of the list of "Available players".
      4. Save the changes.
      5. Create a course.
      6. Add an assignment.
      7. In the description record two videos.
      8. Save.
      9. Click to view the assignment.
      10. Inspect the HTML of the videos.
      11. Confirm one of the videos ids ends with '_1_html5_api' and the other '_2_html_api'.
      Show
      Login as an admin Go to " Site administration / Plugins / Media players / Manage media players " Make sure that " VideoJS player " is enabled and on the top of the list of " Available players ". Save the changes. Create a course. Add an assignment. In the description record two videos. Save. Click to view the assignment. Inspect the HTML of the videos. Confirm one of the videos ids ends with '_1_html5_api' and the other '_2_html_api'.
    • Affected Branches:
      MOODLE_34_STABLE
    • Fixed Branches:
      MOODLE_34_STABLE, MOODLE_35_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-62336_master

      Description

      The media_videojs class, in generating the ID attribute for a video/audio tag, will usually assign identical IDs to different video/audio elements when multiples appear in the same content block. 

      In media_videojs_plugin::embed(),

      $attributes = [
      'data-setup' => '{' . join(', ', $datasetup) . '}',
      'id' => 'id_videojs_' . uniqid() ,
      'class' => get_config('media_videojs', $isaudio ? 'audiocssclass' : 'videocssclass')
      ];

      The uniquid() function returns the same value for any given microsecond. Please consider appending a rand() value, e.g. $attributes['id'] = 'id_videojs_' . uniqid() . rand()

       

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                9/Jul/18

                Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour
                1h