File tree Expand file tree Collapse file tree 11 files changed +104
-29
lines changed
Expand file tree Collapse file tree 11 files changed +104
-29
lines changed Original file line number Diff line number Diff line change 44
55var
66 extText = "srt-vtt" ,
7- extMedia = "mp3-mp4-mpeg-ogg-wav-webm-mpg-weba-ogm"
7+ extMedia = "mp3-mp4-mpeg-ogg-wav-webm-mpg-weba-ogm" ,
8+ extAudio = "mp3-ogg-wav-weba"
89;
910
1011api . file = function ( file ) {
1112 var
12- name = file . name ,
13- ind = name . lastIndexOf ( "." ) ,
14- ext = name . substr ( ind + 1 ) . toLowerCase ( )
13+ indA ,
14+ indB ,
15+ ext ,
16+ path = file . name || file
1517 ;
1618
17- this . dataFile = file ;
18- this . name = name . substr ( 0 , ind ) ,
19- this . extension = ext ;
19+ this . isLocal = ! ! file . name ;
20+
21+ // Name.
22+ indA = path . lastIndexOf ( "/" ) ;
23+ indB = path . lastIndexOf ( "." ) ;
24+ this . name = path . substr ( indA + 1 , indB - indA - 1 ) ;
25+
26+ // Extension / type.
27+ this . extension = ext = path . substr ( indB + 1 ) . toLowerCase ( ) ;
2028 this . isText = extText . indexOf ( ext ) > - 1 ;
2129 this . isMedia = extMedia . indexOf ( ext ) > - 1 ;
22- this . mediaType = file . type . substr ( 0 , file . type . indexOf ( "/" ) ) ; 7
30+ this . mediaType = extAudio . indexOf ( ext ) > - 1 ? "audio" : "video" ;
31+
32+ if ( this . isLocal ) {
33+ this . dataFile = file ;
34+ } else {
35+ this . url = file ;
36+ }
2337} ;
2438
2539api . file . prototype = {
2640 createURL : function ( ) {
27- this . url = URL . createObjectURL ( this . dataFile ) ;
41+ if ( this . isLocal ) {
42+ this . url = URL . createObjectURL ( this . dataFile ) ;
43+ }
2844 return this ;
2945 } ,
3046 revokeURL : function ( ) {
31- URL . revokeObjectURL ( this . url ) ;
47+ if ( this . isLocal ) {
48+ URL . revokeObjectURL ( this . url ) ;
49+ }
3250 return this ;
3351 }
3452} ;
Original file line number Diff line number Diff line change 33( function ( ) {
44
55window . api = {
6- version : "0.5.2 " ,
6+ version : "0.6.0 " ,
77
88 thumbnail : { }
99} ;
Original file line number Diff line number Diff line change @@ -29,9 +29,9 @@ api.playlist = that = {
2929 var
3030 fileWrapper = new api . file ( this ) ,
3131 ext = fileWrapper . extension ,
32- debug = "[" + fileWrapper . dataFile . type + "] [" + ext + "]"
32+ debug = "[" + fileWrapper . mediaType + "] [" + ext + "]"
3333 ;
34- lg ( fileWrapper )
34+
3535 if ( fileWrapper . isMedia ) {
3636 fMediaWraps . push ( fileWrapper ) ;
3737 } else if ( fileWrapper . isText ) {
Original file line number Diff line number Diff line change 1212 jqVideoThumb = dom . ctrlThumbnailVideo
1313;
1414
15+ video . crossOrigin = "use-credentials" ;
16+ jqVideoThumb [ 0 ] . crossOrigin = "use-credentials" ;
17+
1518api . video = that = {
1619
1720 // Manipulating the src="" attribute.
Original file line number Diff line number Diff line change 44 position : absolute ;
55 overflow : auto ;
66 width : 100% ;
7- top : 40 px ;
7+ top : 45 px ;
88 bottom : 0 ;
99
1010 & :after {
Original file line number Diff line number Diff line change 55}
66
77.playlist nav {
8- padding : 12px 8px ;
8+ display : table ;
9+ width : 100% ;
10+ height : 45px ;
911 background : #222 ;
1012
11- * {
13+ > * {
14+ display : table-cell ;
15+ height : 100% ;
16+ padding : 0 10px ;
1217 vertical-align : middle ;
1318 }
1419 .index {
20+ white-space : nowrap ;
1521 font-size : 12px ;
22+ text-align : center ;
1623 }
1724 .current {
1825 font-weight : bold ;
2229 font-weight : normal ;
2330 }
2431 }
25- .right {
26- float : right ;
32+ .input {
33+ width : 100% ;
34+ background : #111 ;
2735 }
28- .close {
29- margin-left : .1em ;
30- margin-top : -.16em ;
31- font-size : 2em ;
36+ input {
37+ width : 100% ;
38+ height : 100% ;
39+ padding : 0 ;
40+ border : 0 ;
41+ font-size : 18px ;
42+ color : inherit ;
43+ background : transparent ;
44+
45+ & ::-webkit-input-placeholder {
46+ color : #444 ;
47+ }
48+ }
49+ .right {
50+ text-align : right ;
51+ white-space : nowrap ;
3252 }
3353 .shuffle {
3454 margin-right : .2em ;
3555 }
3656 .repeat {
3757 position : relative ;
38- margin-top : -2px ;
3958
4059 * {
4160 display : none ;
6887 top : -4px ;
6988 }
7089 }
90+ .close {
91+ margin-left : .5em ;
92+ font-size : 2em ;
93+ }
7194}
Original file line number Diff line number Diff line change 11.playlist {
22 width : 350px ;
33 max-width : 100% ;
4- min-width : 175 px ;
4+ min-width : 250 px ;
55 border-left : 1px solid #222 ;
66 background : rgba ( 0 , 0 , 0 , .9 );
77 transition-duration : .3s ;
Original file line number Diff line number Diff line change @@ -37,6 +37,8 @@ window.dom = {
3737 playlistNav : $ ( ".playlist nav" ) ,
3838 playlistNavIndex : $ ( ".playlist nav .current" ) ,
3939 playlistNavTotal : $ ( ".playlist nav .total" ) ,
40+ playlistForm : $ ( ".playlist nav form" ) ,
41+ playlistInputURL : $ ( ".playlist nav input" ) ,
4042 playlistShuffleBtn : $ ( ".playlist nav .shuffle" ) ,
4143 playlistRepeatBtn : $ ( ".playlist nav .repeat" ) ,
4244 playlistCloseBtn : $ ( ".playlist nav .close" ) ,
Original file line number Diff line number Diff line change 3838 < input type ="file " multiple />
3939 < div class ="content ">
4040 < nav >
41- < span class ="index ">
41+ < div class ="index ">
4242 < span class ="current "> </ span >
4343 < span class ="total "> </ span >
44- </ span >
45- < span class ="right ">
44+ </ div >
45+ < div class ="input ">
46+ < form action ="/ " method ="GET ">
47+ < input type ="url " placeholder ="http://... *.mp3 *.mp4 "/>
48+ </ form >
49+ </ div >
50+ < div class ="right ">
4651 < i class ="btn shuffle fa fa-fw fa-random "
4752 data-jquery-element ="tooltip "
4853 data-tooltip-side ="bottom "> </ i >
4954 < i class ="btn repeat fa fa-fw fa-retweet "
5055 data-jquery-element ="tooltip "
5156 data-tooltip-side ="bottom "> < b > </ b > </ i >
52- < i class ="btn close fa fa-fw fa- times "> </ i >
53- </ span >
57+ < i class ="btn close fa fa-times "> </ i >
58+ </ div >
5459 </ nav >
5560 < div class ="list "> </ div >
5661 </ div >
228233< script src ="playlist/events/prevnextloop.js "> </ script >
229234< script src ="playlist/events/scroll.js "> </ script >
230235< script src ="playlist/events/inputfile.js "> </ script >
236+ < script src ="playlist/events/inputtext.js "> </ script >
231237
232238<!-- Audio visualisations -->
233239< script src ="../visualisations/oscilloscope.js "> </ script >
Original file line number Diff line number Diff line change 1+ "use strict" ;
2+
3+ ( function ( ) {
4+
5+ var
6+ url = dom . playlistInputURL
7+ ;
8+
9+ // When we press Enter in the input.
10+ dom . playlistForm . submit ( function ( ) {
11+ playlistUI . dragover ( dom . screen ) ;
12+ api . playlist . addFiles ( [ url . val ( ) ] , true ) ;
13+ url . val ( "" ) ;
14+ return false ;
15+ } ) ;
16+
17+ // Don't interfere with all the keyboard's shorcuts.
18+ url . keydown ( function ( e ) {
19+ e . stopPropagation ( ) ;
20+ } ) ;
21+
22+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments