(function($) {

  $.extend(MediaElementPlayer.prototype, {

    buildcustomtracks: function(player, controls, layers, media) {
      var t = this

      // Check if 'tracks'
      if (!t.captionsButton) return

      // Add custom track button
      t.captionsButton.find('div.arrow').before(
        $('<div class="head">Custom</div>')
      )


      // Debugging purposes
      setTimeout(function() {
        t.addTextTrack('test2.srt');
      }, 1000)

    },

    addTextTrack: function (src, kind) {
      var t = this

      var track = {
        kind:     (kind || 'subtitles'),
        src:      src,
        isLoaded: false,
        default:  true,
        label:    'Custom Track', // TODO filename
        srclang:  'custom'
      }

      var trackId = t.tracks.push(track)-1

      t.addTrackButton(track.srclang, track.label)

      t.loadTrack(trackId)
    }

  })

})(mejs.$);

@@ -217,31 +217,32 @@
  // 
-Add custom track b
+TODO: DESIGN ME! B
 utton
+?
 %0A   
@@ -316,22 +316,27 @@
 =%22head%22%3E
-Custom
+DROP TO ADD
 %3C/div%3E')
@@ -345,17 +345,16 @@
      )%0A%0A
-%0A
       //
@@ -359,107 +359,494 @@
 // D
-ebugging purposes%0A      setTimeout(function() %7B%0A        t.addTextTrack('test2.srt');%0A      %7D, 1000)
+rag&Drop support%0A      $('body').on('drop', function(e) %7B%0A        if (e.originalEvent.dataTransfer && e.originalEvent.dataTransfer.files.length) %7B%0A          var file = e.originalEvent.dataTransfer.files%5B0%5D%0A          var fileExt = file.name.toLowerCase().substr((~-file.name.lastIndexOf(%22.%22) %3E%3E%3E 0) + 2)%0A          if (fileExt == 'srt') %7B%0A            t.addTextTrackFromFile(file, 'ISO-8859-1')%0A            e.preventDefault()%0A            e.stopPropagation()%0A          %7D%0A        %7D%0A      %7D);
 %0A%0A  
@@ -867,16 +867,24 @@
 extTrack
+FromFile
 : functi
@@ -889,13 +889,22 @@
 tion
- (src
+(file, charset
 , ki
@@ -919,32 +919,33 @@
     var t = this
+;
 %0A%0A      var trac
@@ -1013,191 +1013,1016 @@
     
-src,%0A        isLoaded: false,%0A        default:  true,%0A        label:    'Custom Track', // TODO filename%0A        srclang:  'custom'%0A      %7D%0A%0A      var trackId = t.tracks.push(track)-1
+file.name,%0A        srclang:  'file',%0A        label:    file.name,%0A        default:  true,%0A        isLoaded: false%0A      %7D%0A%0A      // ensure a different srclang for each file%0A      track.srclang =+ t.tracks.push(track)-1 %0A      t.addTrackButton(track.srclang, track.label)%0A%0A      var reader = new FileReader();%0A      reader.readAsText(file, charset);%0A      reader.onload = function() %7B%0A        var d = reader.result%0A        track.entries = mejs.TrackFormatParser.webvvt.parse(d)%0A        track.isLoaded = true%0A        t.enableTrackButton(track.srclang, track.label)%0A        t.setTrack(track.srclang)%0A      %7D%0A    %7D,%0A%0A    /* Dynamically add a new TextTrack (instead of %3Ctrack src=... /%3E) %0A       Won't work on local files (Cross origins)%0A    */%0A    addTextTrack: function (src, kind, srclang, label) %7B%0A      var t = this%0A%0A      var track = %7B%0A        kind:     (kind %7C%7C 'subtitles'),%0A        src:      src,%0A        isLoaded: false,%0A        default:  true,%0A        label:    label,%0A        srclang:  srclang%0A      %7D
 %0A%0A  
@@ -2066,24 +2066,68 @@
 rack.label)%0A
+      t.trackToLoad = t.tracks.push(track)-1
 %0A      t.loa
@@ -2137,14 +2137,20 @@
 ack(
+t.
 track
-I
+ToLoa
 d)%0A 
@@ -2160,17 +2160,16 @@
 %7D%0A%0A  %7D)%0A
-%0A
 %7D)(mejs.

Support adding custom subs using FileReader and Drag&Drop.