Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
VideoLAN
VLC-iOS
Commits
9390824b
Commit
9390824b
authored
May 12, 2016
by
Pierre SAGASPE
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
onedrive : add external subtitles (only without option automatically play next item)
parent
5415ed8e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
1 deletion
+54
-1
Sources/VLCOneDriveTableViewController.m
Sources/VLCOneDriveTableViewController.m
+54
-1
No files found.
Sources/VLCOneDriveTableViewController.m
View file @
9390824b
...
...
@@ -16,6 +16,7 @@
#import "VLCPlaybackController.h"
#import "VLCProgressView.h"
#import "UIDevice+VLC.h"
#import "NSString+SupportedMedia.h"
@interface
VLCOneDriveTableViewController
()
<
VLCCloudStorageDelegate
>
{
...
...
@@ -123,8 +124,10 @@
if
(
!
[[
NSUserDefaults
standardUserDefaults
]
boolForKey
:
kVLCAutomaticallyPlayNextItem
])
{
/* stream file */
NSString
*
subtitlePath
=
[
self
_searchSubtitle
:
selectedObject
.
name
];
subtitlePath
=
[
self
_getFileSubtitleFromServer
:[
NSURL
URLWithString
:
subtitlePath
]];
NSURL
*
url
=
[
NSURL
URLWithString
:
selectedObject
.
downloadPath
];
[
vpc
playURL
:
url
su
ccessCallback
:
nil
errorCallback
:
nil
];
[
vpc
playURL
:
url
su
btitlesFilePath
:
subtitlePath
];
}
else
{
NSUInteger
count
=
folderItems
.
count
;
NSMutableArray
*
mediaItems
=
[[
NSMutableArray
alloc
]
init
];
...
...
@@ -155,6 +158,56 @@
[
self
.
tableView
deselectRowAtIndexPath
:
indexPath
animated
:
NO
];
}
-
(
NSString
*
)
_searchSubtitle
:(
NSString
*
)
url
{
NSString
*
urlTemp
=
[[
url
lastPathComponent
]
stringByDeletingPathExtension
];
NSArray
*
folderItems
=
_oneDriveController
.
currentFolder
.
items
;
NSString
*
itemPath
=
nil
;
NSPredicate
*
predicate
=
[
NSPredicate
predicateWithFormat
:
@"name contains[c] %@"
,
urlTemp
];
NSArray
*
results
=
[
folderItems
filteredArrayUsingPredicate
:
predicate
];
for
(
int
cnt
=
0
;
cnt
<
results
.
count
;
cnt
++
)
{
VLCOneDriveObject
*
iter
=
results
[
cnt
];
NSString
*
itemName
=
iter
.
name
;
if
([
itemName
isSupportedSubtitleFormat
])
itemPath
=
iter
.
downloadPath
;
}
return
itemPath
;
}
-
(
NSString
*
)
_getFileSubtitleFromServer
:(
NSURL
*
)
subtitleURL
{
NSString
*
FileSubtitlePath
=
nil
;
NSData
*
receivedSub
=
[
NSData
dataWithContentsOfURL
:
subtitleURL
];
// TODO: fix synchronous load
if
(
receivedSub
.
length
<
[[
UIDevice
currentDevice
]
freeDiskspace
].
longLongValue
)
{
NSArray
*
searchPaths
=
NSSearchPathForDirectoriesInDomains
(
NSCachesDirectory
,
NSUserDomainMask
,
YES
);
NSString
*
directoryPath
=
searchPaths
[
0
];
FileSubtitlePath
=
[
directoryPath
stringByAppendingPathComponent
:[
subtitleURL
lastPathComponent
]];
NSFileManager
*
fileManager
=
[
NSFileManager
defaultManager
];
if
(
!
[
fileManager
fileExistsAtPath
:
FileSubtitlePath
])
{
//create local subtitle file
[
fileManager
createFileAtPath
:
FileSubtitlePath
contents
:
nil
attributes
:
nil
];
if
(
!
[
fileManager
fileExistsAtPath
:
FileSubtitlePath
])
{
APLog
(
@"file creation failed, no data was saved"
);
return
nil
;
}
}
[
receivedSub
writeToFile
:
FileSubtitlePath
atomically
:
YES
];
}
else
{
VLCAlertView
*
alert
=
[[
VLCAlertView
alloc
]
initWithTitle
:
NSLocalizedString
(
@"DISK_FULL"
,
nil
)
message:
[
NSString
stringWithFormat
:
NSLocalizedString
(
@"DISK_FULL_FORMAT"
,
nil
),
[
subtitleURL
lastPathComponent
],
[[
UIDevice
currentDevice
]
model
]]
delegate:
self
cancelButtonTitle:
NSLocalizedString
(
@"BUTTON_OK"
,
nil
)
otherButtonTitles:
nil
];
[
alert
show
];
}
return
FileSubtitlePath
;
}
-
(
void
)
playAllAction
:(
id
)
sender
{
VLCPlaybackController
*
vpc
=
[
VLCPlaybackController
sharedInstance
];
...
...
Pierre SAGASPE
@Pierre
mentioned in commit
1d32ae67
·
Jun 13, 2016
mentioned in commit
1d32ae67
mentioned in commit 1d32ae67d5e189cf37b3b46843515a7e3fb51c42
Toggle commit list
Write
Preview
Markdown
is supported
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