Skip to content

Commit 1661f3b

Browse files
committed
...
1 parent d7c8284 commit 1661f3b

File tree

11 files changed

+104
-29
lines changed

11 files changed

+104
-29
lines changed

api/file.js

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,49 @@
44

55
var
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

1011
api.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

2539
api.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
};

api/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
(function() {
44

55
window.api = {
6-
version: "0.5.2",
6+
version: "0.6.0",
77

88
thumbnail: {}
99
};

api/playlist.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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 ) {

api/video.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ var
1212
jqVideoThumb = dom.ctrlThumbnailVideo
1313
;
1414

15+
video.crossOrigin = "use-credentials";
16+
jqVideoThumb[ 0 ].crossOrigin = "use-credentials";
17+
1518
api.video = that = {
1619

1720
// Manipulating the src="" attribute.

css/playlist/list.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
position: absolute;
55
overflow: auto;
66
width: 100%;
7-
top: 40px;
7+
top: 45px;
88
bottom: 0;
99

1010
&:after {

css/playlist/nav.scss

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,21 @@
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;
@@ -22,20 +29,32 @@
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;
@@ -68,4 +87,8 @@
6887
top: -4px;
6988
}
7089
}
90+
.close {
91+
margin-left: .5em;
92+
font-size: 2em;
93+
}
7194
}

css/playlist/playlist.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.playlist {
22
width: 350px;
33
max-width: 100%;
4-
min-width: 175px;
4+
min-width: 250px;
55
border-left: 1px solid #222;
66
background: rgba( 0, 0, 0, .9 );
77
transition-duration: .3s;

dom.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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" ),

index.html

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,24 @@
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>
@@ -228,6 +233,7 @@
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>

playlist/events/inputtext.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
})();

playlist/playlist-ui.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ window.playlistUI = that = {
111111
jqToggleBtn[ 0 ].dataset.tooltipContent = "Show playlist";
112112
showing = false;
113113
api.screen.resizeFilename();
114+
dom.playlistInputURL.blur();
114115
Cookies.set( "playlistshow", showing, { expires: 365 } );
115116
return that;
116117
},

0 commit comments

Comments
 (0)