Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
VideoLAN
VLC-iOS
Commits
26264da5
Commit
26264da5
authored
Sep 29, 2017
by
Carola Nitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
VLCPlaybackController : remove playURL calls and use medialist instead everywhere
parent
0f8bdb39
Pipeline
#217
failed with stage
in 0 seconds
Changes
18
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
95 additions
and
119 deletions
+95
-119
Apple-TV/VLCOpenNetworkStreamTVViewController.m
Apple-TV/VLCOpenNetworkStreamTVViewController.m
+5
-1
Apple-TV/VLCRemotePlaybackViewController.m
Apple-TV/VLCRemotePlaybackViewController.m
+5
-2
Apple-TV/VLCServerListTVViewController.m
Apple-TV/VLCServerListTVViewController.m
+5
-3
SharedSources/Clouds/VLCBoxCollectionViewController.m
SharedSources/Clouds/VLCBoxCollectionViewController.m
+3
-2
SharedSources/Clouds/VLCOneDriveCollectionViewController.m
SharedSources/Clouds/VLCOneDriveCollectionViewController.m
+5
-2
SharedSources/ServerBrowsing/VLCServerBrowsingController.m
SharedSources/ServerBrowsing/VLCServerBrowsingController.m
+4
-5
SharedSources/VLCPlayerControlWebSocket.m
SharedSources/VLCPlayerControlWebSocket.m
+1
-1
Sources/LocalNetworkConnectivity/VLCServerListViewController.m
...es/LocalNetworkConnectivity/VLCServerListViewController.m
+4
-2
Sources/VLCAppDelegate.m
Sources/VLCAppDelegate.m
+14
-4
Sources/VLCBoxTableViewController.m
Sources/VLCBoxTableViewController.m
+4
-1
Sources/VLCDropboxController.m
Sources/VLCDropboxController.m
+4
-2
Sources/VLCGoogleDriveController.m
Sources/VLCGoogleDriveController.m
+4
-1
Sources/VLCHTTPConnection.m
Sources/VLCHTTPConnection.m
+2
-4
Sources/VLCOneDriveTableViewController.m
Sources/VLCOneDriveTableViewController.m
+6
-3
Sources/VLCOpenNetworkStreamViewController.m
Sources/VLCOpenNetworkStreamViewController.m
+4
-2
Sources/VLCPlaybackController+MediaLibrary.m
Sources/VLCPlaybackController+MediaLibrary.m
+1
-2
Sources/VLCPlaybackController.h
Sources/VLCPlaybackController.h
+1
-4
Sources/VLCPlaybackController.m
Sources/VLCPlaybackController.m
+23
-78
No files found.
Apple-TV/VLCOpenNetworkStreamTVViewController.m
View file @
26264da5
...
...
@@ -143,7 +143,11 @@
-
(
void
)
_openURLStringAndDismiss
:(
NSString
*
)
urlString
{
VLCPlaybackController
*
vpc
=
[
VLCPlaybackController
sharedInstance
];
[
vpc
playURL
:[
NSURL
URLWithString
:
urlString
]
subtitlesFilePath
:
nil
];
VLCMedia
*
media
=
[
VLCMedia
mediaWithURL
:[
NSURL
URLWithString
:
urlString
]];
VLCMediaList
*
medialist
=
[[
VLCMediaList
alloc
]
init
];
[
medialist
addMedia
:
media
];
[
vpc
playMediaList
:
medialist
firstIndex
:
0
subtitlesFilePath
:
nil
];
[
self
presentViewController
:[
VLCFullscreenMovieTVViewController
fullscreenMovieTVViewController
]
animated:
YES
completion:
nil
];
...
...
Apple-TV/VLCRemotePlaybackViewController.m
View file @
26264da5
...
...
@@ -268,12 +268,15 @@
-
(
void
)
collectionView
:(
UICollectionView
*
)
collectionView
didSelectItemAtIndexPath
:(
NSIndexPath
*
)
indexPath
{
VLCPlaybackController
*
vpc
=
[
VLCPlaybackController
sharedInstance
];
NSURL
*
url
;
@synchronized
(
_discoveredFiles
)
{
url
=
[
NSURL
fileURLWithPath
:
_discoveredFiles
[
indexPath
.
row
]];
}
[
vpc
playURL
:
url
subtitlesFilePath
:
nil
];
VLCMediaList
*
medialist
=
[[
VLCMediaList
alloc
]
init
];
[
medialist
addMedia
:[
VLCMedia
mediaWithURL
:
url
]];
[[
VLCPlaybackController
sharedInstance
]
playMediaList
:
medialist
firstIndex
:
0
subtitlesFilePath
:
nil
];
[
self
presentViewController
:[
VLCFullscreenMovieTVViewController
fullscreenMovieTVViewController
]
animated:
YES
completion:
nil
];
...
...
Apple-TV/VLCServerListTVViewController.m
View file @
26264da5
...
...
@@ -182,12 +182,14 @@
NSURL
*
url
=
service
.
directPlaybackURL
;
if
(
!
url
)
return
;
VLCPlaybackController
*
vpc
=
[
VLCPlaybackController
sharedInstance
];
[
vpc
playURL
:
url
subtitlesFilePath
:
nil
];
VLCMediaList
*
medialist
=
[[
VLCMediaList
alloc
]
init
];
[
medialist
addMedia
:[
VLCMedia
mediaWithURL
:
url
]];
[[
VLCPlaybackController
sharedInstance
]
playMediaList
:
medialist
firstIndex
:
0
subtitlesFilePath
:
nil
];
[
self
presentViewController
:[
VLCFullscreenMovieTVViewController
fullscreenMovieTVViewController
]
animated:
YES
completion:
nil
];
return
;
}
}
...
...
SharedSources/Clouds/VLCBoxCollectionViewController.m
View file @
26264da5
...
...
@@ -164,8 +164,9 @@
[
connection
cancel
];
/* now ask VLC to stream the URL we were just passed */
VLCPlaybackController
*
vpc
=
[
VLCPlaybackController
sharedInstance
];
[
vpc
playURL
:
theActualURL
successCallback
:
nil
errorCallback
:
nil
];
VLCMediaList
*
medialist
=
[[
VLCMediaList
alloc
]
init
];
[
medialist
addMedia
:[
VLCMedia
mediaWithURL
:
theActualURL
]];
[[
VLCPlaybackController
sharedInstance
]
playMediaList
:
medialist
firstIndex
:
0
subtitlesFilePath
:
nil
];
VLCFullscreenMovieTVViewController
*
movieVC
=
[
VLCFullscreenMovieTVViewController
fullscreenMovieTVViewController
];
[
self
presentViewController
:
movieVC
...
...
SharedSources/Clouds/VLCOneDriveCollectionViewController.m
View file @
26264da5
...
...
@@ -96,8 +96,11 @@
}
else
{
/* stream file */
NSURL
*
url
=
[
NSURL
URLWithString
:
selectedObject
.
downloadPath
];
VLCPlaybackController
*
vpc
=
[
VLCPlaybackController
sharedInstance
];
[
vpc
playURL
:
url
successCallback
:
nil
errorCallback
:
nil
];
VLCMediaList
*
medialist
=
[[
VLCMediaList
alloc
]
init
];
[
medialist
addMedia
:[
VLCMedia
mediaWithURL
:
url
]];
[[
VLCPlaybackController
sharedInstance
]
playMediaList
:
medialist
firstIndex
:
0
subtitlesFilePath
:
nil
];
VLCFullscreenMovieTVViewController
*
movieVC
=
[
VLCFullscreenMovieTVViewController
fullscreenMovieTVViewController
];
[
self
presentViewController
:
movieVC
animated:
YES
...
...
SharedSources/ServerBrowsing/VLCServerBrowsingController.m
View file @
26264da5
...
...
@@ -201,8 +201,7 @@
-
(
void
)
streamMediaList
:(
VLCMediaList
*
)
mediaList
startingAtIndex
:(
NSInteger
)
startIndex
{
VLCPlaybackController
*
vpc
=
[
VLCPlaybackController
sharedInstance
];
[
vpc
playMediaList
:
mediaList
firstIndex
:
startIndex
];
[[
VLCPlaybackController
sharedInstance
]
playMediaList
:
mediaList
firstIndex
:
startIndex
subtitlesFilePath
:
nil
];
[
self
showMovieViewController
];
}
...
...
@@ -221,10 +220,10 @@
if
(
remoteSubtitleURL
)
URLofSubtitle
=
[
self
_getFileSubtitleFromServer
:
remoteSubtitleURL
];
NSURL
*
URLToPlay
=
item
.
URL
;
VLCPlaybackController
*
vpc
=
[
VLCPlaybackController
sharedInstance
];
[
vpc
playURL
:
URLToPlay
subtitlesFilePath
:
URLofSubtitle
];
VLCMediaList
*
medialist
=
[[
VLCMediaList
alloc
]
init
];
[
medialist
addMedia
:[
VLCMedia
mediaWithURL
:
item
.
URL
]];
[
vpc
playMediaList
:
medialist
firstIndex
:
0
subtitlesFilePath
:
URLofSubtitle
];
[
self
showMovieViewController
];
}
...
...
SharedSources/VLCPlayerControlWebSocket.m
View file @
26264da5
...
...
@@ -358,7 +358,7 @@
[
mediaList
addMedia
:[
VLCMedia
mediaWithURL
:[
NSURL
URLWithString
:
urlString
]]];
if
(
needsMediaList
)
{
[
vpc
playMediaList
:
mediaList
firstIndex
:
0
];
[
vpc
playMediaList
:
mediaList
firstIndex
:
0
subtitlesFilePath
:
nil
];
VLCFullscreenMovieTVViewController
*
movieVC
=
[
VLCFullscreenMovieTVViewController
fullscreenMovieTVViewController
];
if
([[[
UIApplication
sharedApplication
].
delegate
.
window
rootViewController
]
presentedViewController
]
!=
nil
)
{
...
...
Sources/LocalNetworkConnectivity/VLCServerListViewController.m
View file @
26264da5
...
...
@@ -189,8 +189,10 @@
if
([
service
respondsToSelector
:
@selector
(
directPlaybackURL
)])
{
NSURL
*
playbackURL
=
[
service
directPlaybackURL
];
if
(
playbackURL
)
{
VLCPlaybackController
*
vpc
=
[
VLCPlaybackController
sharedInstance
];
[
vpc
playURL
:
playbackURL
successCallback
:
nil
errorCallback
:
nil
];
VLCMediaList
*
medialist
=
[[
VLCMediaList
alloc
]
init
];
[
medialist
addMedia
:[
VLCMedia
mediaWithURL
:
playbackURL
]];
[[
VLCPlaybackController
sharedInstance
]
playMediaList
:
medialist
firstIndex
:
0
subtitlesFilePath
:
nil
];
return
;
}
}
...
...
Sources/VLCAppDelegate.m
View file @
26264da5
...
...
@@ -340,7 +340,13 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType
if
([
action
isEqualToString
:
@"stream"
]
&&
movieURL
)
{
VLCPlaybackController
*
vpc
=
[
VLCPlaybackController
sharedInstance
];
vpc
.
fullscreenSessionRequested
=
YES
;
[
vpc
playURL
:
movieURL
successCallback
:
successCallback
errorCallback
:
errorCallback
];
VLCMediaList
*
medialist
=
[[
VLCMediaList
alloc
]
init
];
[
medialist
addMedia
:[
VLCMedia
mediaWithURL
:
movieURL
]];
vpc
.
successCallback
=
successCallback
;
vpc
.
errorCallback
=
errorCallback
;
[
vpc
playMediaList
:
medialist
firstIndex
:
0
subtitlesFilePath
:
nil
];
}
else
if
([
action
isEqualToString
:
@"download"
]
&&
movieURL
)
{
[
self
downloadMovieFromURL
:
movieURL
fileNameOfMedia
:
fileName
];
...
...
@@ -375,15 +381,19 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType
if
(
cancelled
)
[
self
downloadMovieFromURL
:
url
fileNameOfMedia
:
nil
];
else
{
VLCPlaybackController
*
vpc
=
[
VLCPlaybackController
sharedInstance
];
[
vpc
playURL
:
url
successCallback
:
nil
errorCallback
:
nil
];
VLCMedia
*
media
=
[
VLCMedia
mediaWithURL
:
url
];
VLCMediaList
*
medialist
=
[[
VLCMediaList
alloc
]
init
];
[
medialist
addMedia
:
media
];
[[
VLCPlaybackController
sharedInstance
]
playMediaList
:
medialist
firstIndex
:
0
subtitlesFilePath
:
nil
];
}
};
[
alert
show
];
}
else
{
VLCPlaybackController
*
vpc
=
[
VLCPlaybackController
sharedInstance
];
vpc
.
fullscreenSessionRequested
=
YES
;
[
vpc
playURL
:
url
successCallback
:
nil
errorCallback
:
nil
];
VLCMediaList
*
medialist
=
[[
VLCMediaList
alloc
]
init
];
[
medialist
addMedia
:[
VLCMedia
mediaWithURL
:
url
]];
[
vpc
playMediaList
:
medialist
firstIndex
:
0
subtitlesFilePath
:
nil
];
}
}
return
YES
;
...
...
Sources/VLCBoxTableViewController.m
View file @
26264da5
...
...
@@ -221,7 +221,10 @@
/* now ask VLC to stream the URL we were just passed */
VLCPlaybackController
*
vpc
=
[
VLCPlaybackController
sharedInstance
];
[
vpc
playURL
:
theActualURL
successCallback
:
nil
errorCallback
:
nil
];
VLCMedia
*
media
=
[
VLCMedia
mediaWithURL
:
theActualURL
];
VLCMediaList
*
medialist
=
[[
VLCMediaList
alloc
]
init
];
[
medialist
addMedia
:
media
];
[[
VLCPlaybackController
sharedInstance
]
playMediaList
:
medialist
firstIndex
:
0
subtitlesFilePath
:
nil
];
}
return
request
;
...
...
Sources/VLCDropboxController.m
View file @
26264da5
...
...
@@ -269,8 +269,10 @@
[[
_client
.
filesRoutes
getTemporaryLink
:
path
]
setResponseBlock
:
^
(
DBFILESGetTemporaryLinkResult
*
_Nullable
result
,
DBFILESGetTemporaryLinkError
*
_Nullable
routeError
,
DBRequestError
*
_Nullable
networkError
)
{
if
(
result
)
{
VLCPlaybackController
*
vpc
=
[
VLCPlaybackController
sharedInstance
];
[
vpc
playURL
:[
NSURL
URLWithString
:
result
.
link
]
successCallback
:
nil
errorCallback
:
nil
];
VLCMedia
*
media
=
[
VLCMedia
mediaWithURL
:[
NSURL
URLWithString
:
result
.
link
]];
VLCMediaList
*
medialist
=
[[
VLCMediaList
alloc
]
init
];
[
medialist
addMedia
:
media
];
[[
VLCPlaybackController
sharedInstance
]
playMediaList
:
medialist
firstIndex
:
0
subtitlesFilePath
:
nil
];
#if TARGET_OS_TV
if
(
_lastKnownNavigationController
)
{
VLCFullscreenMovieTVViewController
*
movieVC
=
[
VLCFullscreenMovieTVViewController
fullscreenMovieTVViewController
];
...
...
Sources/VLCGoogleDriveController.m
View file @
26264da5
...
...
@@ -219,7 +219,10 @@
file
.
identifier
,
token
];
VLCPlaybackController
*
vpc
=
[
VLCPlaybackController
sharedInstance
];
[
vpc
playURL
:[
NSURL
URLWithString
:
urlString
]
successCallback
:
nil
errorCallback
:
nil
];
VLCMedia
*
media
=
[
VLCMedia
mediaWithURL
:[
NSURL
URLWithString
:
urlString
]];
VLCMediaList
*
medialist
=
[[
VLCMediaList
alloc
]
init
];
[
medialist
addMedia
:
media
];
[
vpc
playMediaList
:
medialist
firstIndex
:
0
subtitlesFilePath
:
nil
];
}
-
(
void
)
_triggerNextDownload
...
...
Sources/VLCHTTPConnection.m
View file @
26264da5
...
...
@@ -646,18 +646,16 @@
[
_receivedFiles
addObject
:
path
];
VLCPlaybackController
*
vpc
=
[
VLCPlaybackController
sharedInstance
];
BOOL
needsMediaList
;
VLCMediaList
*
mediaList
=
vpc
.
mediaList
;
if
(
!
mediaList
)
{
mediaList
=
[[
VLCMediaList
alloc
]
init
];
needsMediaList
=
YES
;
}
[
mediaList
addMedia
:[
VLCMedia
mediaWithURL
:[
NSURL
fileURLWithPath
:
path
]]];
if
(
needsM
ediaList
)
{
[
vpc
playMediaList
:
mediaList
firstIndex
:
0
];
if
(
!
vpc
.
m
ediaList
)
{
[
vpc
playMediaList
:
mediaList
firstIndex
:
0
subtitlesFilePath
:
nil
];
}
VLCFullscreenMovieTVViewController
*
movieVC
=
[
VLCFullscreenMovieTVViewController
fullscreenMovieTVViewController
];
...
...
Sources/VLCOneDriveTableViewController.m
View file @
26264da5
...
...
@@ -113,7 +113,10 @@
NSString
*
subtitlePath
=
[
self
_searchSubtitle
:
selectedObject
.
name
];
subtitlePath
=
[
self
_getFileSubtitleFromServer
:[
NSURL
URLWithString
:
subtitlePath
]];
NSURL
*
url
=
[
NSURL
URLWithString
:
selectedObject
.
downloadPath
];
[
vpc
playURL
:
url
subtitlesFilePath
:
subtitlePath
];
VLCMediaList
*
medialist
=
[[
VLCMediaList
alloc
]
init
];
[
medialist
addMedia
:
[
VLCMedia
mediaWithURL
:
url
]];
[[
VLCPlaybackController
sharedInstance
]
playMediaList
:
medialist
firstIndex
:
0
subtitlesFilePath
:
subtitlePath
];
}
else
{
NSUInteger
count
=
folderItems
.
count
;
NSMutableArray
*
mediaItems
=
[[
NSMutableArray
alloc
]
init
];
...
...
@@ -135,7 +138,7 @@
if
(
mediaItems
.
count
>
0
)
{
firstIndex
=
mediaItems
.
count
-
posIndex
;
[
vpc
playMediaList
:[[
VLCMediaList
alloc
]
initWithArray
:
mediaItems
]
firstIndex
:
firstIndex
];
[
vpc
playMediaList
:[[
VLCMediaList
alloc
]
initWithArray
:
mediaItems
]
firstIndex
:
firstIndex
subtitlesFilePath
:
nil
];
}
}
}
...
...
@@ -211,7 +214,7 @@
}
if
(
mediaItems
.
count
>
0
)
{
[
vpc
playMediaList
:[[
VLCMediaList
alloc
]
initWithArray
:
mediaItems
]
firstIndex
:
0
];
[
vpc
playMediaList
:[[
VLCMediaList
alloc
]
initWithArray
:
mediaItems
]
firstIndex
:
0
subtitlesFilePath
:
nil
];
}
}
...
...
Sources/VLCOpenNetworkStreamViewController.m
View file @
26264da5
...
...
@@ -359,8 +359,10 @@ forRowAtIndexPath:(NSIndexPath *)indexPath
URLofSubtitle
=
[
self
_checkURLofSubtitle
:
url
];
}
VLCPlaybackController
*
vpc
=
[
VLCPlaybackController
sharedInstance
];
[
vpc
playURL
:[
NSURL
URLWithString
:
url
]
subtitlesFilePath
:
URLofSubtitle
];
VLCMedia
*
media
=
[
VLCMedia
mediaWithURL
:[
NSURL
URLWithString
:
url
]];
VLCMediaList
*
medialist
=
[[
VLCMediaList
alloc
]
init
];
[
medialist
addMedia
:
media
];
[[
VLCPlaybackController
sharedInstance
]
playMediaList
:
medialist
firstIndex
:
0
subtitlesFilePath
:
URLofSubtitle
];
}
-
(
NSString
*
)
_checkURLofSubtitle
:(
NSString
*
)
url
...
...
Sources/VLCPlaybackController+MediaLibrary.m
View file @
26264da5
...
...
@@ -132,8 +132,7 @@ Open a file in the libraryViewController without changing the playstate
-
(
void
)
configureMediaList
:(
VLCMediaList
*
)
list
atIndex
:(
int
)
index
{
self
.
pathToExternalSubtitlesFile
=
nil
;
[
self
playMediaList
:
list
firstIndex
:
index
];
[
self
playMediaList
:
list
firstIndex
:
index
subtitlesFilePath
:
nil
];
}
@end
Sources/VLCPlaybackController.h
View file @
26264da5
...
...
@@ -47,7 +47,6 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
@property
(
nonatomic
,
readwrite
)
BOOL
sessionWillRestart
;
@property
(
nonatomic
,
strong
)
NSURL
*
url
;
@property
(
nonatomic
,
strong
)
NSURL
*
successCallback
;
@property
(
nonatomic
,
strong
)
NSURL
*
errorCallback
;
...
...
@@ -96,8 +95,6 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
-
(
void
)
setNeedsMetadataUpdate
;
-
(
void
)
scheduleSleepTimerWithInterval
:(
NSTimeInterval
)
timeInterval
;
-
(
void
)
playMediaList
:(
VLCMediaList
*
)
mediaList
firstIndex
:(
NSInteger
)
index
;
-
(
void
)
playURL
:(
NSURL
*
)
url
successCallback
:(
NSURL
*
)
successCallback
errorCallback
:(
NSURL
*
)
errorCallback
;
-
(
void
)
playURL
:(
NSURL
*
)
url
subtitlesFilePath
:(
NSString
*
)
subsFilePath
;
-
(
void
)
playMediaList
:(
VLCMediaList
*
)
mediaList
firstIndex
:(
NSInteger
)
index
subtitlesFilePath
:(
NSString
*
)
subsFilePath
;
@end
Sources/VLCPlaybackController.m
View file @
26264da5
...
...
@@ -17,7 +17,6 @@
*****************************************************************************/
#import "VLCPlaybackController.h"
#import <CommonCrypto/CommonDigest.h>
#import "UIDevice+VLC.h"
#import <AVFoundation/AVFoundation.h>
#import "VLCPlayerDisplayController.h"
...
...
@@ -101,10 +100,13 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
{
self
=
[
super
init
];
if
(
self
)
{
// listen to audiosessions and appkit callback
_headphonesWasPlugged
=
[
self
areHeadphonesPlugged
];
NSNotificationCenter
*
defaultCenter
=
[
NSNotificationCenter
defaultCenter
];
[
defaultCenter
addObserver
:
self
selector
:
@selector
(
audioSessionRouteChange
:
)
name:
AVAudioSessionRouteChangeNotification
object
:
nil
];
// appkit because we neeed to know when we go to background in order to stop the video, so that we don't crash
[
defaultCenter
addObserver
:
self
selector
:
@selector
(
applicationWillResignActive
:
)
name:
UIApplicationWillResignActiveNotification
object
:
nil
];
[
defaultCenter
addObserver
:
self
selector
:
@selector
(
applicationDidBecomeActive
:
)
...
...
@@ -132,50 +134,14 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
}
#pragma mark - playback management
-
(
void
)
playMediaList
:(
VLCMediaList
*
)
mediaList
firstIndex
:(
NSInteger
)
index
-
(
void
)
playMediaList
:(
VLCMediaList
*
)
mediaList
firstIndex
:(
NSInteger
)
index
subtitlesFilePath
:(
NSString
*
)
subsFilePath
{
self
.
mediaList
=
mediaList
;
self
.
itemInMediaListToBePlayedFirst
=
(
int
)
index
;
self
.
pathToExternalSubtitlesFile
=
nil
;
if
(
self
.
activePlaybackSession
)
{
self
.
sessionWillRestart
=
YES
;
[
self
stopPlayback
];
}
else
{
self
.
sessionWillRestart
=
NO
;
[
self
startPlayback
];
}
}
-
(
void
)
playURL
:(
NSURL
*
)
url
successCallback
:(
NSURL
*
)
successCallback
errorCallback
:(
NSURL
*
)
errorCallback
{
self
.
url
=
url
;
self
.
successCallback
=
successCallback
;
self
.
errorCallback
=
errorCallback
;
if
(
self
.
activePlaybackSession
)
{
self
.
sessionWillRestart
=
YES
;
[
self
stopPlayback
];
}
else
{
self
.
sessionWillRestart
=
NO
;
[
self
startPlayback
];
}
}
-
(
void
)
playURL
:(
NSURL
*
)
url
subtitlesFilePath
:(
NSString
*
)
subsFilePath
{
self
.
url
=
url
;
self
.
pathToExternalSubtitlesFile
=
subsFilePath
;
if
(
self
.
activePlaybackSession
)
{
self
.
sessionWillRestart
=
YES
;
[
self
stopPlayback
];
}
else
{
self
.
sessionWillRestart
=
NO
;
dispatch_async
(
dispatch_get_main_queue
(),
^
{
[
self
startPlayback
];
});
}
self
.
sessionWillRestart
=
self
.
activePlaybackSession
;
self
.
activePlaybackSession
?
[
self
stopPlayback
]
:
[
self
startPlayback
];
}
-
(
void
)
startPlayback
...
...
@@ -199,7 +165,7 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
NSUserDefaults
*
defaults
=
[
NSUserDefaults
standardUserDefaults
];
if
(
!
self
.
url
&&
!
self
.
mediaList
)
{
if
(
!
self
.
mediaList
)
{
APLog
(
@"%s: no URL and no media list set, stopping playback"
,
__PRETTY_FUNCTION__
);
[
_playbackSessionManagementLock
unlock
];
[
self
stopPlayback
];
...
...
@@ -234,23 +200,13 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
if
(
self
.
pathToExternalSubtitlesFile
)
[
_mediaPlayer
addPlaybackSlave
:[
NSURL
fileURLWithPath
:
self
.
pathToExternalSubtitlesFile
]
type
:
VLCMediaPlaybackSlaveTypeSubtitle
enforce
:
YES
];
VLCMedia
*
media
;
if
(
_mediaList
)
{
media
=
[
_mediaList
mediaAtIndex
:
_itemInMediaListToBePlayedFirst
];
[
media
parseWithOptions
:
VLCMediaParseLocal
];
media
.
delegate
=
self
;
}
else
{
media
=
[
VLCMedia
mediaWithURL
:
self
.
url
];
media
.
delegate
=
self
;
[
media
parseWithOptions
:
VLCMediaParseLocal
];
[
media
addOptions
:
self
.
mediaOptionsDictionary
];
}
VLCMedia
*
media
=
[
_mediaList
mediaAtIndex
:
_itemInMediaListToBePlayedFirst
];
[
media
parseWithOptions
:
VLCMediaParseLocal
];
media
.
delegate
=
self
;
[
media
addOptions
:
self
.
mediaOptionsDictionary
];
[
_listPlayer
setMediaList
:
self
.
mediaList
];
if
(
self
.
mediaList
)
{
[
_listPlayer
setMediaList
:
self
.
mediaList
];
}
else
{
[
_listPlayer
setRootMedia
:
media
];
}
[
_listPlayer
setRepeatMode
:
VLCDoNotRepeat
];
[
_playbackSessionManagementLock
unlock
];
...
...
@@ -276,10 +232,7 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
[
_mediaPlayer
addObserver
:
self
forKeyPath
:
@"time"
options
:
0
context
:
nil
];
[
_mediaPlayer
addObserver
:
self
forKeyPath
:
@"remainingTime"
options
:
0
context
:
nil
];
if
(
self
.
mediaList
)
[
_listPlayer
playItemAtNumber
:
@
(
self
.
itemInMediaListToBePlayedFirst
)];
else
[
_listPlayer
playMedia
:
_listPlayer
.
rootMedia
];
[
_listPlayer
playItemAtNumber
:
@
(
self
.
itemInMediaListToBePlayedFirst
)];
if
([
self
.
delegate
respondsToSelector
:
@selector
(
prepareForMediaPlayback
:)])
[
self
.
delegate
prepareForMediaPlayback
:
self
];
...
...
@@ -320,16 +273,11 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
#endif
[
_mediaPlayer
stop
];
}
if
(
_mediaPlayer
)
_mediaPlayer
=
nil
;
if
(
_listPlayer
)
_listPlayer
=
nil
;
_mediaPlayer
=
nil
;
_listPlayer
=
nil
;
}
if
(
!
_sessionWillRestart
)
{
if
(
_mediaList
)
_mediaList
=
nil
;
if
(
_url
)
_url
=
nil
;
_mediaList
=
nil
;
if
(
_pathToExternalSubtitlesFile
)
{
NSFileManager
*
fileManager
=
[
NSFileManager
defaultManager
];
if
([
fileManager
fileExistsAtPath
:
_pathToExternalSubtitlesFile
])
...
...
@@ -340,10 +288,10 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
_playerIsSetup
=
NO
;
[
_shuffleStack
removeAllObjects
];
if
(
self
.
errorCallback
&&
_playbackFailed
&&
!
_sessionWillRestart
)
[[
UIApplication
sharedApplication
]
openURL
:
self
.
errorCallback
];
else
if
(
self
.
successCallback
&&
!
_sessionWillRestart
)
[[
UIApplication
sharedApplication
]
openURL
:
self
.
successCallback
];
if
(
_
errorCallback
&&
_playbackFailed
&&
!
_sessionWillRestart
)
[[
UIApplication
sharedApplication
]
openURL
:
_
errorCallback
];
else
if
(
_
successCallback
&&
!
_sessionWillRestart
)
[[
UIApplication
sharedApplication
]
openURL
:
_
successCallback
];
[[
self
remoteControlService
]
unsubscribeFromRemoteCommands
];
_activeSession
=
NO
;
...
...
@@ -369,10 +317,8 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
APLog
(
@"saving playback state failed"
);
}
MLFile
*
fileItem
;
NSArray
*
files
=
[
MLFile
fileForURL
:
_mediaPlayer
.
media
.
url
];
if
(
files
.
count
>
0
)
fileItem
=
files
.
firstObject
;
MLFile
*
fileItem
=
files
.
firstObject
;
if
(
!
fileItem
)
{
APLog
(
@"couldn't find file, not saving playback progress"
);
...
...
@@ -449,9 +395,8 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
_mediaWasJustStarted
=
NO
;
#if TARGET_OS_IOS
if
(
self
.
mediaList
)
{
MLFile
*
item
;
NSArray
*
matches
=
[
MLFile
fileForURL
:
_mediaPlayer
.
media
.
url
];
item
=
matches
.
firstObject
;
MLFile
*
item
=
matches
.
firstObject
;
[
self
_recoverLastPlaybackStateOfItem
:
item
];
}
#else
...
...
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