Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
VideoLAN
VLC-iOS
Commits
99eb0828
Commit
99eb0828
authored
Sep 25, 2013
by
Pierre SAGASPE
Committed by
Felix Paul Kühne
Oct 22, 2013
Browse files
Add Download via UPNP
Signed-off-by:
Felix Paul Kühne
<
fkuehne@videolan.org
>
parent
52c62b5a
Changes
5
Hide whitespace changes
Inline
Side-by-side
AspenProject/VLCDownloadViewController.h
View file @
99eb0828
...
...
@@ -23,5 +23,5 @@
-
(
IBAction
)
downloadAction
:(
id
)
sender
;
-
(
IBAction
)
cancelDownload
:(
id
)
sender
;
-
(
void
)
addURLToDownloadList
:(
NSURL
*
)
aURL
;
-
(
void
)
addURLToDownloadList
:(
NSURL
*
)
aURL
fileNameOfMedia
:(
NSString
*
)
fileName
;
;
@end
AspenProject/VLCDownloadViewController.m
View file @
99eb0828
...
...
@@ -25,6 +25,7 @@
NSMutableArray
*
_currentDownloads
;
NSUInteger
_currentDownloadType
;
NSString
*
_humanReadableFilename
;
NSString
*
_MediaFilename
;
VLCHTTPFileDownloader
*
_httpDownloader
;
...
...
@@ -134,8 +135,13 @@
if
(
!
_httpDownloader
.
downloadInProgress
)
{
_currentDownloadType
=
kVLCDownloadViaHTTP
;
if
(
_MediaFilename
)
{
[
_httpDownloader
downloadFileFromURLwithFileName
:
_currentDownloads
[
0
]
fileNameOfMedia
:
_MediaFilename
];
_humanReadableFilename
=
_MediaFilename
;
}
else
{
[
_httpDownloader
downloadFileFromURL
:
_currentDownloads
[
0
]];
_humanReadableFilename
=
_httpDownloader
.
userReadableDownloadName
;
}
}
}
else
if
([
downloadScheme
isEqualToString
:
@"ftp"
])
{
_currentDownloadType
=
kVLCDownloadViaFTP
;
...
...
@@ -174,6 +180,7 @@
-
(
void
)
downloadStarted
{
[
self
.
activityIndicator
stopAnimating
];
[
UIApplication
sharedApplication
].
networkActivityIndicatorVisible
=
YES
;
self
.
currentDownloadLabel
.
text
=
_humanReadableFilename
;
self
.
progressView
.
progress
=
0
.;
self
.
currentDownloadLabel
.
hidden
=
NO
;
...
...
@@ -184,6 +191,7 @@
-
(
void
)
downloadEnded
{
[
UIApplication
sharedApplication
].
networkActivityIndicatorVisible
=
NO
;
self
.
currentDownloadLabel
.
hidden
=
YES
;
self
.
progressView
.
hidden
=
YES
;
self
.
cancelButton
.
hidden
=
YES
;
...
...
@@ -293,9 +301,10 @@
}
#pragma mark - communication with other VLC objects
-
(
void
)
addURLToDownloadList
:(
NSURL
*
)
aURL
-
(
void
)
addURLToDownloadList
:(
NSURL
*
)
aURL
fileNameOfMedia
:(
NSString
*
)
fileName
{
[
_currentDownloads
addObject
:
aURL
];
_MediaFilename
=
fileName
;
[
self
.
downloadsTable
reloadData
];
[
self
_triggerNextDownload
];
}
...
...
AspenProject/VLCHTTPFileDownloader.h
View file @
99eb0828
...
...
@@ -28,5 +28,6 @@
-
(
void
)
cancelDownload
;
-
(
void
)
downloadFileFromURL
:(
NSURL
*
)
url
;
-
(
void
)
downloadFileFromURLwithFileName
:(
NSURL
*
)
url
fileNameOfMedia
:(
NSString
*
)
fileName
;
@end
AspenProject/VLCHTTPFileDownloader.m
View file @
99eb0828
...
...
@@ -47,6 +47,24 @@
}
}
-
(
void
)
downloadFileFromURLwithFileName
:(
NSURL
*
)
url
fileNameOfMedia
:(
NSString
*
)
fileName
{
NSArray
*
searchPaths
=
NSSearchPathForDirectoriesInDomains
(
NSDocumentDirectory
,
NSUserDomainMask
,
YES
);
_fileName
=
fileName
;
_filePath
=
[
searchPaths
[
0
]
stringByAppendingPathComponent
:
_fileName
];
_expectedDownloadSize
=
_receivedDataSize
=
0
;
NSMutableURLRequest
*
theRequest
=
[
NSMutableURLRequest
requestWithURL
:
url
];
_urlConnection
=
[[
NSURLConnection
alloc
]
initWithRequest
:
theRequest
delegate
:
self
];
if
(
!
_urlConnection
)
{
APLog
(
@"failed to establish connection"
);
_downloadInProgress
=
NO
;
}
else
{
_downloadInProgress
=
YES
;
[
UIApplication
sharedApplication
].
networkActivityIndicatorVisible
=
YES
;
[(
VLCAppDelegate
*
)[
UIApplication
sharedApplication
].
delegate
disableIdleTimer
];
}
}
-
(
void
)
connection
:(
NSURLConnection
*
)
connection
didReceiveResponse
:(
NSHTTPURLResponse
*
)
response
{
NSUInteger
statusCode
=
[
response
statusCode
];
...
...
AspenProject/VLCLocalServerFolderListViewController.m
View file @
99eb0828
...
...
@@ -158,14 +158,15 @@
MediaServer1ItemObject
*
mediaItem
=
_mutableObjectList
[
indexPath
.
row
];
[
cell
setSubtitle
:
[
NSString
stringWithFormat
:
@"%0.2f MB (%@)"
,
(
float
)([
mediaItem
.
size
intValue
]
/
1e6
),
mediaItem
.
duration
]];
[
cell
setIsDirectory
:
NO
];
cell
.
isDownloadable
=
YES
;
if
(
!
[
mediaItem
.
albumArt
isEqualToString
:
NULL
])
{
NSData
*
imageData
=
[[
NSData
alloc
]
initWithContentsOfURL
:[
NSURL
URLWithString
:
mediaItem
.
albumArt
]];
UIImage
*
image
=
[[
UIImage
alloc
]
initWithData
:
imageData
];
[
cell
setIcon
:
image
];
cell
.
delegate
=
self
;
}
else
[
cell
setIcon
:[
UIImage
imageNamed
:
@"blank"
]];
cell
.
delegate
=
self
;
}
else
{
[
cell
setIsDirectory
:
YES
];
[
cell
setIcon
:[
UIImage
imageNamed
:
@"folder"
]];
...
...
@@ -278,7 +279,13 @@
{
NSURL
*
URLToQueue
=
[
NSURL
URLWithString
:[[
@"ftp"
stringByAppendingFormat
:
@"://%@%@/%@/%@"
,
[
self
_credentials
],
_ftpServerAddress
,
_ftpServerPath
,
fileName
]
stringByAddingPercentEscapesUsingEncoding
:
NSUTF8StringEncoding
]];
[[(
VLCAppDelegate
*
)[
UIApplication
sharedApplication
].
delegate
downloadViewController
]
addURLToDownloadList
:
URLToQueue
];
[[(
VLCAppDelegate
*
)[
UIApplication
sharedApplication
].
delegate
downloadViewController
]
addURLToDownloadList
:
URLToQueue
fileNameOfMedia
:
nil
];
}
-
(
void
)
_downloadUPNPFile
:(
NSURL
*
)
url
fileNameOfMedia
:(
NSString
*
)
fileName
;
{
fileName
=
[[
fileName
stringByAppendingString
:
@"."
]
stringByAppendingString
:[[
url
absoluteString
]
pathExtension
]];
[[(
VLCAppDelegate
*
)[
UIApplication
sharedApplication
].
delegate
downloadViewController
]
addURLToDownloadList
:
url
fileNameOfMedia
:
fileName
];
}
-
(
void
)
requestCompleted
:(
WRRequest
*
)
request
...
...
@@ -310,7 +317,22 @@
#pragma mark - VLCLocalNetworkListCell delegation
-
(
void
)
triggerDownloadForCell
:(
VLCLocalNetworkListCell
*
)
cell
{
if
(
_serverType
==
kVLCFTPServer
)
{
if
(
_serverType
==
kVLCUPNPFileServer
)
{
MediaServer1ItemObject
*
item
=
_mutableObjectList
[[
self
.
tableView
indexPathForCell
:
cell
].
row
];
MediaServer1ItemRes
*
resource
=
nil
;
NSEnumerator
*
e
=
[[
item
resources
]
objectEnumerator
];
NSURL
*
itemURL
;
while
((
resource
=
(
MediaServer1ItemRes
*
)[
e
nextObject
])){
itemURL
=
[
NSURL
URLWithString
:[[
item
uri
]
stringByAddingPercentEscapesUsingEncoding
:
NSUTF8StringEncoding
]];
}
if
(
!
[[
item
uri
]
isSupportedFormat
])
{
UIAlertView
*
alert
=
[[
UIAlertView
alloc
]
initWithTitle
:
NSLocalizedString
(
@"FILE_NOT_SUPPORTED"
,
@""
)
message
:[
NSString
stringWithFormat
:
NSLocalizedString
(
@"FILE_NOT_SUPPORTED_LONG"
,
@""
),
[
item
uri
]]
delegate
:
self
cancelButtonTitle
:
NSLocalizedString
(
@"BUTTON_CANCEL"
,
@""
)
otherButtonTitles
:
nil
];
[
alert
show
];
}
else
{
[
self
_downloadUPNPFile
:
itemURL
fileNameOfMedia
:[
item
title
]];
[
cell
.
statusLabel
showStatusMessage
:
NSLocalizedString
(
@"DOWNLOADING"
,
@""
)];
}
}
else
if
(
_serverType
==
kVLCFTPServer
)
{
NSString
*
objectName
=
[
_objectList
[[
self
.
tableView
indexPathForCell
:
cell
].
row
]
objectForKey
:(
id
)
kCFFTPResourceName
];
if
(
!
[
objectName
isSupportedFormat
])
{
UIAlertView
*
alert
=
[[
UIAlertView
alloc
]
initWithTitle
:
NSLocalizedString
(
@"FILE_NOT_SUPPORTED"
,
@""
)
message
:[
NSString
stringWithFormat
:
NSLocalizedString
(
@"FILE_NOT_SUPPORTED_LONG"
,
@""
),
objectName
]
delegate
:
self
cancelButtonTitle
:
NSLocalizedString
(
@"BUTTON_CANCEL"
,
@""
)
otherButtonTitles
:
nil
];
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment