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
b96da671
Commit
b96da671
authored
Nov 26, 2015
by
Felix Paul Kühne
Browse files
Implement subtitles downloading
parent
3ff84d71
Changes
2
Hide whitespace changes
Inline
Side-by-side
Apple-TV/Playback/Playback Info/VLCPlaybackInfoSubtitlesFetcherViewController.m
View file @
b96da671
...
...
@@ -52,8 +52,6 @@
[
defaults
synchronize
];
}
_osoFetcher
.
subtitleLanguageId
=
selectedLocale
;
}
#pragma mark - OSO Fetcher delegation
...
...
@@ -80,6 +78,19 @@
[
self
.
tableView
reloadData
];
}
-
(
void
)
MDFOSOFetcher
:(
MDFOSOFetcher
*
)
aFetcher
didFailToDownloadForItem
:(
MDFSubtitleItem
*
)
subtitleItem
{
// FIXME: missing error handling
[
self
dismissViewControllerAnimated
:
YES
completion
:
nil
];
}
-
(
void
)
MDFOSOFetcher
:(
MDFOSOFetcher
*
)
aFetcher
subtitleDownloadSucceededForItem
:(
MDFSubtitleItem
*
)
subtitleItem
atPath
:(
NSString
*
)
pathToFile
{
VLCPlaybackController
*
vpc
=
[
VLCPlaybackController
sharedInstance
];
[
vpc
.
mediaPlayer
openVideoSubTitlesFromFile
:
pathToFile
];
[
self
dismissViewControllerAnimated
:
YES
completion
:
nil
];
}
#pragma mark - table view datasource
-
(
NSInteger
)
numberOfSectionsInTableView
:(
UITableView
*
)
tableView
...
...
@@ -142,8 +153,6 @@
MDFSubtitleLanguage
*
item
;
NSUserDefaults
*
defaults
=
[
NSUserDefaults
standardUserDefaults
];
NSString
*
currentCode
=
[
defaults
stringForKey
:
kVLCSettingLastUsedSubtitlesSearchLanguage
];
if
(
!
currentCode
)
currentCode
=
@"eng"
;
// FIXME
for
(
NSUInteger
i
=
0
;
i
<
count
;
i
++
)
{
NSString
*
itemID
=
item
.
ID
;
...
...
@@ -166,6 +175,13 @@
handler:
nil
]];
[
self
presentViewController
:
alertController
animated
:
YES
completion
:
nil
];
}
else
{
MDFSubtitleItem
*
item
=
_searchResults
[
indexPath
.
row
];
NSArray
*
searchPaths
=
NSSearchPathForDirectoriesInDomains
(
NSCachesDirectory
,
NSUserDomainMask
,
YES
);
NSString
*
folderPath
=
[
searchPaths
[
0
]
stringByAppendingPathComponent
:
@"tempsubs"
];
[[
NSFileManager
defaultManager
]
createDirectoryAtPath
:
folderPath
withIntermediateDirectories
:
YES
attributes
:
nil
error
:
nil
];
NSString
*
subStorageLocation
=
[
folderPath
stringByAppendingPathComponent
:
item
.
name
];
[
_osoFetcher
downloadSubtitleItem
:
item
toPath
:
subStorageLocation
];
}
}
...
...
Apple-TV/Playback/VLCFullscreenMovieTVViewController.m
View file @
b96da671
...
...
@@ -167,6 +167,13 @@ typedef NS_ENUM(NSInteger, VLCPlayerScanState)
[
self
stopAudioDescriptionAnimation
];
/* delete potentially downloaded subs */
NSArray
*
searchPaths
=
NSSearchPathForDirectoriesInDomains
(
NSCachesDirectory
,
NSUserDomainMask
,
YES
);
NSString
*
tempSubsDirPath
=
[
searchPaths
[
0
]
stringByAppendingPathComponent
:
@"tempsubs"
];
NSFileManager
*
fileManager
=
[
NSFileManager
defaultManager
];
if
([
fileManager
fileExistsAtPath
:
tempSubsDirPath
])
[
fileManager
removeItemAtPath
:
tempSubsDirPath
error
:
nil
];
[
super
viewWillDisappear
:
animated
];
}
...
...
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