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 4
4
5
5
var
6
6
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"
8
9
;
9
10
10
11
api . file = function ( file ) {
11
12
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
15
17
;
16
18
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 ( ) ;
20
28
this . isText = extText . indexOf ( ext ) > - 1 ;
21
29
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
+ }
23
37
} ;
24
38
25
39
api . file . prototype = {
26
40
createURL : function ( ) {
27
- this . url = URL . createObjectURL ( this . dataFile ) ;
41
+ if ( this . isLocal ) {
42
+ this . url = URL . createObjectURL ( this . dataFile ) ;
43
+ }
28
44
return this ;
29
45
} ,
30
46
revokeURL : function ( ) {
31
- URL . revokeObjectURL ( this . url ) ;
47
+ if ( this . isLocal ) {
48
+ URL . revokeObjectURL ( this . url ) ;
49
+ }
32
50
return this ;
33
51
}
34
52
} ;
Original file line number Diff line number Diff line change 3
3
( function ( ) {
4
4
5
5
window . api = {
6
- version : "0.5.2 " ,
6
+ version : "0.6.0 " ,
7
7
8
8
thumbnail : { }
9
9
} ;
Original file line number Diff line number Diff line change @@ -29,9 +29,9 @@ api.playlist = that = {
29
29
var
30
30
fileWrapper = new api . file ( this ) ,
31
31
ext = fileWrapper . extension ,
32
- debug = "[" + fileWrapper . dataFile . type + "] [" + ext + "]"
32
+ debug = "[" + fileWrapper . mediaType + "] [" + ext + "]"
33
33
;
34
- lg ( fileWrapper )
34
+
35
35
if ( fileWrapper . isMedia ) {
36
36
fMediaWraps . push ( fileWrapper ) ;
37
37
} else if ( fileWrapper . isText ) {
Original file line number Diff line number Diff line change 12
12
jqVideoThumb = dom . ctrlThumbnailVideo
13
13
;
14
14
15
+ video . crossOrigin = "use-credentials" ;
16
+ jqVideoThumb [ 0 ] . crossOrigin = "use-credentials" ;
17
+
15
18
api . video = that = {
16
19
17
20
// Manipulating the src="" attribute.
Original file line number Diff line number Diff line change 4
4
position : absolute ;
5
5
overflow : auto ;
6
6
width : 100% ;
7
- top : 40 px ;
7
+ top : 45 px ;
8
8
bottom : 0 ;
9
9
10
10
& :after {
Original file line number Diff line number Diff line change 5
5
}
6
6
7
7
.playlist nav {
8
- padding : 12px 8px ;
8
+ display : table ;
9
+ width : 100% ;
10
+ height : 45px ;
9
11
background : #222 ;
10
12
11
- * {
13
+ > * {
14
+ display : table-cell ;
15
+ height : 100% ;
16
+ padding : 0 10px ;
12
17
vertical-align : middle ;
13
18
}
14
19
.index {
20
+ white-space : nowrap ;
15
21
font-size : 12px ;
22
+ text-align : center ;
16
23
}
17
24
.current {
18
25
font-weight : bold ;
22
29
font-weight : normal ;
23
30
}
24
31
}
25
- .right {
26
- float : right ;
32
+ .input {
33
+ width : 100% ;
34
+ background : #111 ;
27
35
}
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 ;
32
52
}
33
53
.shuffle {
34
54
margin-right : .2em ;
35
55
}
36
56
.repeat {
37
57
position : relative ;
38
- margin-top : -2px ;
39
58
40
59
* {
41
60
display : none ;
68
87
top : -4px ;
69
88
}
70
89
}
90
+ .close {
91
+ margin-left : .5em ;
92
+ font-size : 2em ;
93
+ }
71
94
}
Original file line number Diff line number Diff line change 1
1
.playlist {
2
2
width : 350px ;
3
3
max-width : 100% ;
4
- min-width : 175 px ;
4
+ min-width : 250 px ;
5
5
border-left : 1px solid #222 ;
6
6
background : rgba ( 0 , 0 , 0 , .9 );
7
7
transition-duration : .3s ;
Original file line number Diff line number Diff line change @@ -37,6 +37,8 @@ window.dom = {
37
37
playlistNav : $ ( ".playlist nav" ) ,
38
38
playlistNavIndex : $ ( ".playlist nav .current" ) ,
39
39
playlistNavTotal : $ ( ".playlist nav .total" ) ,
40
+ playlistForm : $ ( ".playlist nav form" ) ,
41
+ playlistInputURL : $ ( ".playlist nav input" ) ,
40
42
playlistShuffleBtn : $ ( ".playlist nav .shuffle" ) ,
41
43
playlistRepeatBtn : $ ( ".playlist nav .repeat" ) ,
42
44
playlistCloseBtn : $ ( ".playlist nav .close" ) ,
Original file line number Diff line number Diff line change 38
38
< input type ="file " multiple />
39
39
< div class ="content ">
40
40
< nav >
41
- < span class ="index ">
41
+ < div class ="index ">
42
42
< span class ="current "> </ span >
43
43
< 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 ">
46
51
< i class ="btn shuffle fa fa-fw fa-random "
47
52
data-jquery-element ="tooltip "
48
53
data-tooltip-side ="bottom "> </ i >
49
54
< i class ="btn repeat fa fa-fw fa-retweet "
50
55
data-jquery-element ="tooltip "
51
56
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 >
54
59
</ nav >
55
60
< div class ="list "> </ div >
56
61
</ div >
228
233
< script src ="playlist/events/prevnextloop.js "> </ script >
229
234
< script src ="playlist/events/scroll.js "> </ script >
230
235
< script src ="playlist/events/inputfile.js "> </ script >
236
+ < script src ="playlist/events/inputtext.js "> </ script >
231
237
232
238
<!-- Audio visualisations -->
233
239
< 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
+ } ) ( ) ;
Original file line number Diff line number Diff line change @@ -111,6 +111,7 @@ window.playlistUI = that = {
111
111
jqToggleBtn [ 0 ] . dataset . tooltipContent = "Show playlist" ;
112
112
showing = false ;
113
113
api . screen . resizeFilename ( ) ;
114
+ dom . playlistInputURL . blur ( ) ;
114
115
Cookies . set ( "playlistshow" , showing , { expires : 365 } ) ;
115
116
return that ;
116
117
} ,
You can’t perform that action at this time.
0 commit comments