Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
VLC-iOS
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
264
Issues
264
List
Boards
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
VideoLAN
VLC-iOS
Commits
1d32ae67
Commit
1d32ae67
authored
May 12, 2016
by
Pierre SAGASPE
Committed by
Felix Paul Kühne
Jun 13, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
onedrive : add external subtitles (only without option automatically play next item)
(cherry picked from commit
9390824b
)
parent
a397a0a1
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 @
1d32ae67
...
...
@@ -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
];
...
...
@@ -154,6 +157,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
];
...
...
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