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
0f8bdb39
Commit
0f8bdb39
authored
Sep 28, 2017
by
Carola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
VLCPlaybackController: Decouple Metadata and controlcenter code from playback
parent
ce03cb9c
Pipeline
#216
failed with stage
in 0 seconds
Changes
12
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
210 additions
and
214 deletions
+210
-214
Apple-TV/Playback/Playback Info/VLCPlaybackInfoMediaInfoTVViewController.m
.../Playback Info/VLCPlaybackInfoMediaInfoTVViewController.m
+4
-3
Apple-TV/Playback/Playback Info/VLCPlaybackInfoSubtitlesFetcherViewController.m
...back Info/VLCPlaybackInfoSubtitlesFetcherViewController.m
+2
-1
SharedSources/VLCMetadata.h
SharedSources/VLCMetadata.h
+22
-0
SharedSources/VLCMetadata.m
SharedSources/VLCMetadata.m
+125
-0
SharedSources/VLCPlayerControlWebSocket.m
SharedSources/VLCPlayerControlWebSocket.m
+2
-1
Sources/VLCHTTPConnection.m
Sources/VLCHTTPConnection.m
+2
-1
Sources/VLCMiniPlaybackView.m
Sources/VLCMiniPlaybackView.m
+10
-14
Sources/VLCMovieViewControlPanelView.m
Sources/VLCMovieViewControlPanelView.m
+2
-1
Sources/VLCMovieViewController.m
Sources/VLCMovieViewController.m
+9
-13
Sources/VLCPlaybackController.h
Sources/VLCPlaybackController.h
+4
-8
Sources/VLCPlaybackController.m
Sources/VLCPlaybackController.m
+14
-172
VLC.xcodeproj/project.pbxproj
VLC.xcodeproj/project.pbxproj
+14
-0
No files found.
Apple-TV/Playback/Playback Info/VLCPlaybackInfoMediaInfoTVViewController.m
View file @
0f8bdb39
...
...
@@ -10,6 +10,7 @@
*****************************************************************************/
#import "VLCPlaybackInfoMediaInfoTVViewController.h"
#import "VLCMetadata.h"
@interface
VLCPlaybackInfoMediaInfoTVViewController
()
...
...
@@ -46,7 +47,7 @@
-
(
void
)
viewWillAppear
:(
BOOL
)
animated
{
VLCPlaybackController
*
vpc
=
[
VLCPlaybackController
sharedInstance
];
self
.
titleLabel
.
text
=
vpc
.
me
diaT
itle
;
self
.
titleLabel
.
text
=
vpc
.
me
tadata
.
t
itle
;
VLCMediaPlayer
*
player
=
vpc
.
mediaPlayer
;
VLCMedia
*
media
=
player
.
media
;
...
...
@@ -104,7 +105,7 @@
NSLocalizedString
(
@"DURATION"
,
nil
),
media
.
length
.
verboseStringValue
];
}
if
(
!
vpc
.
audioOnlyPlaybackSession
)
{
if
(
!
vpc
.
metadata
.
isAudioOnly
)
{
metaDataString
=
[
metaDataString
stringByAppendingFormat
:
@"%@: %@ (%@)
\n
"
,
NSLocalizedString
(
@"VIDEO_DIMENSIONS"
,
nil
),
[
NSString
stringWithFormat
:
NSLocalizedString
(
@"FORMAT_VIDEO_DIMENSIONS"
,
nil
),
...
...
@@ -144,7 +145,7 @@
-
(
void
)
updateMediaTitle
{
self
.
titleLabel
.
text
=
[
VLCPlaybackController
sharedInstance
].
me
diaT
itle
;
self
.
titleLabel
.
text
=
[
VLCPlaybackController
sharedInstance
].
me
tadata
.
t
itle
;
}
@end
Apple-TV/Playback/Playback Info/VLCPlaybackInfoSubtitlesFetcherViewController.m
View file @
0f8bdb39
...
...
@@ -12,6 +12,7 @@
#import "VLCPlaybackInfoSubtitlesFetcherViewController.h"
#import "MetadataFetcherKit.h"
#import "NSString+Locale.h"
#import "VLCMetadata.h"
#define SPUDownloadReUseIdentifier @"SPUDownloadReUseIdentifier"
#define SPUDownloadHeaderReUseIdentifier @"SPUDownloadHeaderReUseIdentifier"
...
...
@@ -95,7 +96,7 @@
VLCPlaybackController
*
vpc
=
[
VLCPlaybackController
sharedInstance
];
NSUserDefaults
*
defaults
=
[
NSUserDefaults
standardUserDefaults
];
_osoFetcher
.
subtitleLanguageId
=
[
defaults
stringForKey
:
kVLCSettingLastUsedSubtitlesSearchLanguage
];
[
_osoFetcher
searchForSubtitlesWithQuery
:
vpc
.
me
diaT
itle
];
[
_osoFetcher
searchForSubtitlesWithQuery
:
vpc
.
me
tadata
.
t
itle
];
}
-
(
void
)
MDFOSOFetcher
:(
MDFOSOFetcher
*
)
aFetcher
didFindSubtitles
:(
NSArray
<
MDFSubtitleItem
*>
*
)
subtitles
forSearchRequest
:(
NSString
*
)
searchRequest
...
...
SharedSources/VLCMetadata.h
0 → 100644
View file @
0f8bdb39
//
// VLCMediaPlayer + Metadata.h
// VLC
//
// Created by Carola Nitz on 9/27/17.
// Copyright © 2017 VideoLAN. All rights reserved.
//
@interface
VLCMetaData
:
NSObject
@property
(
readwrite
,
copy
)
NSString
*
title
;
@property
(
readwrite
)
UIImage
*
artworkImage
;
@property
(
readwrite
,
copy
)
NSString
*
artist
;
@property
(
readwrite
,
copy
)
NSString
*
albumName
;
@property
(
readwrite
,
assign
)
BOOL
isAudioOnly
;
@property
(
readwrite
)
NSNumber
*
trackNumber
;
@property
(
readwrite
)
NSNumber
*
playbackDuration
;
@property
(
readwrite
)
NSNumber
*
elapsedPlaybackTime
;
@property
(
readwrite
)
NSNumber
*
playbackRate
;
-
(
void
)
updateMetadataFromMediaPlayer
:(
VLCMediaPlayer
*
)
mediaPlayer
;
@end
SharedSources/VLCMetadata.m
0 → 100644
View file @
0f8bdb39
//
// VLCMediaPlayer + Metadata.m
// VLC
//
// Created by Carola Nitz on 9/27/17.
// Copyright © 2017 VideoLAN. All rights reserved.
//
#import "VLCMetadata.h"
#import <MediaPlayer/MediaPlayer.h>
#import "VLCPlaybackController.h"
#if TARGET_OS_IOS
#import "VLCKeychainCoordinator.h"
#import "VLCThumbnailsCache.h"
#endif
@implementation
VLCMetaData
-
(
instancetype
)
init
{
self
=
[
super
init
];
if
(
self
)
{
}
return
self
;
}
-
(
void
)
updateMetadataFromMediaPlayer
:(
VLCMediaPlayer
*
)
mediaPlayer
;
{
#if TARGET_OS_IOS
MLFile
*
item
;
if
([
VLCPlaybackController
sharedInstance
].
mediaList
)
{
NSArray
*
matches
=
[
MLFile
fileForURL
:
mediaPlayer
.
media
.
url
];
item
=
matches
.
firstObject
;
}
if
(
item
)
{
if
(
item
.
isAlbumTrack
)
{
self
.
title
=
item
.
albumTrack
.
title
;
self
.
artist
=
item
.
albumTrack
.
artist
;
self
.
albumName
=
item
.
albumTrack
.
album
.
name
;
}
else
self
.
title
=
item
.
title
;
/* MLKit knows better than us if this thing is audio only or not */
self
.
isAudioOnly
=
[
item
isSupportedAudioFile
];
}
else
{
#endif
NSDictionary
*
metaDict
=
mediaPlayer
.
media
.
metaDictionary
;
if
(
metaDict
)
{
self
.
title
=
metaDict
[
VLCMetaInformationNowPlaying
]
?
metaDict
[
VLCMetaInformationNowPlaying
]
:
metaDict
[
VLCMetaInformationTitle
];
self
.
artist
=
metaDict
[
VLCMetaInformationArtist
];
self
.
albumName
=
metaDict
[
VLCMetaInformationAlbum
];
self
.
trackNumber
=
metaDict
[
VLCMetaInformationTrackNumber
];
}
#if TARGET_OS_IOS
}
#endif
if
(
!
self
.
isAudioOnly
)
{
/* either what we are playing is not a file known to MLKit or
* MLKit fails to acknowledge that it is audio-only.
* Either way, do a more expensive check to see if it is really audio-only */
NSArray
*
tracks
=
mediaPlayer
.
media
.
tracksInformation
;
NSUInteger
trackCount
=
tracks
.
count
;
self
.
isAudioOnly
=
YES
;
for
(
NSUInteger
x
=
0
;
x
<
trackCount
;
x
++
)
{
if
([[
tracks
[
x
]
objectForKey
:
VLCMediaTracksInformationType
]
isEqualToString
:
VLCMediaTracksInformationTypeVideo
])
{
self
.
isAudioOnly
=
NO
;
break
;
}
}
}
if
(
self
.
isAudioOnly
)
{
#if TARGET_OS_IOS
self
.
artworkImage
=
[
VLCThumbnailsCache
thumbnailForManagedObject
:
item
];
if
(
self
.
artworkImage
)
{
if
(
self
.
artist
)
self
.
title
=
[
self
.
title
stringByAppendingFormat
:
@" — %@"
,
self
.
artist
];
if
(
self
.
albumName
)
self
.
title
=
[
self
.
title
stringByAppendingFormat
:
@" — %@"
,
self
.
albumName
];
}
#endif
if
(
self
.
title
.
length
<
1
)
self
.
title
=
[[
mediaPlayer
.
media
url
]
lastPathComponent
];
}
self
.
playbackDuration
=
@
(
mediaPlayer
.
media
.
length
.
intValue
/
1000
.);
self
.
playbackRate
=
@
(
mediaPlayer
.
rate
);
self
.
elapsedPlaybackTime
=
@
(
mediaPlayer
.
media
.
length
.
intValue
/
1000
.);
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
VLCPlaybackControllerPlaybackMetadataDidChange
object
:
self
];
#if TARGET_OS_IOS
if
([[
VLCKeychainCoordinator
defaultCoordinator
]
passcodeLockEnabled
])
return
;
#endif
[
self
populateInfoCenterFromMetadata
];
}
-
(
void
)
populateInfoCenterFromMetadata
{
NSMutableDictionary
*
currentlyPlayingTrackInfo
=
[
NSMutableDictionary
dictionary
];
currentlyPlayingTrackInfo
[
MPMediaItemPropertyPlaybackDuration
]
=
self
.
playbackDuration
;
currentlyPlayingTrackInfo
[
MPNowPlayingInfoPropertyElapsedPlaybackTime
]
=
self
.
elapsedPlaybackTime
;
currentlyPlayingTrackInfo
[
MPNowPlayingInfoPropertyPlaybackRate
]
=
self
.
playbackRate
;
currentlyPlayingTrackInfo
[
MPMediaItemPropertyTitle
]
=
self
.
title
;
currentlyPlayingTrackInfo
[
MPMediaItemPropertyArtist
]
=
self
.
artist
;
currentlyPlayingTrackInfo
[
MPMediaItemPropertyAlbumTitle
]
=
self
.
albumName
;
if
([
self
.
trackNumber
intValue
]
>
0
)
currentlyPlayingTrackInfo
[
MPMediaItemPropertyAlbumTrackNumber
]
=
self
.
trackNumber
;
#if TARGET_OS_IOS
if
(
self
.
artworkImage
)
{
MPMediaItemArtwork
*
mpartwork
=
[[
MPMediaItemArtwork
alloc
]
initWithImage
:
self
.
artworkImage
];
currentlyPlayingTrackInfo
[
MPMediaItemPropertyArtwork
]
=
mpartwork
;
}
#endif
[
MPNowPlayingInfoCenter
defaultCenter
].
nowPlayingInfo
=
currentlyPlayingTrackInfo
;
}
@end
SharedSources/VLCPlayerControlWebSocket.m
View file @
0f8bdb39
...
...
@@ -11,6 +11,7 @@
*****************************************************************************/
#import "VLCPlayerControlWebSocket.h"
#import "VLCMetadata.h"
@implementation
VLCPlayerControlWebSocket
...
...
@@ -122,7 +123,7 @@
if
(
media
)
{
NSURL
*
url
=
media
.
url
;
NSString
*
mediaTitle
=
vpc
.
me
diaT
itle
;
NSString
*
mediaTitle
=
vpc
.
me
tadata
.
t
itle
;
if
(
!
mediaTitle
)
mediaTitle
=
url
.
lastPathComponent
;
NSDictionary
*
mediaDict
=
@{
@"id"
:
url
.
absoluteString
,
...
...
Sources/VLCHTTPConnection.m
View file @
0f8bdb39
...
...
@@ -25,6 +25,7 @@
#import "NSString+SupportedMedia.h"
#import "UIDevice+VLC.h"
#import "VLCHTTPUploaderController.h"
#import "VLCMetaData.h"
#if TARGET_OS_IOS
#import "VLCThumbnailsCache.h"
...
...
@@ -463,7 +464,7 @@
return
[[
HTTPErrorResponse
alloc
]
initWithErrorCode
:
404
];
}
NSString
*
mediaTitle
=
vpc
.
me
diaT
itle
;
NSString
*
mediaTitle
=
vpc
.
me
tadata
.
t
itle
;
if
(
!
mediaTitle
)
mediaTitle
=
@""
;
NSDictionary
*
mediaDict
=
@{
@"id"
:
media
.
url
.
absoluteString
,
...
...
Sources/VLCMiniPlaybackView.m
View file @
0f8bdb39
...
...
@@ -13,6 +13,7 @@
#import "VLCMiniPlaybackView.h"
#import "VLCPlaybackController.h"
#import "VLCPlayerDisplayController.h"
#import "VLCMetadata.h"
#if TARGET_OS_IOS
#import "VLCLibraryViewController.h"
...
...
@@ -208,16 +209,11 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
[
self
updatePlayPauseButton
];
}
-
(
void
)
displayMetadataForPlaybackController
:(
VLCPlaybackController
*
)
controller
title
:(
NSString
*
)
title
artwork
:(
UIImage
*
)
artwork
artist
:(
NSString
*
)
artist
album
:(
NSString
*
)
album
audioOnly
:(
BOOL
)
audioOnly
-
(
void
)
displayMetadataForPlaybackController
:(
VLCPlaybackController
*
)
controller
metadata
:(
VLCMetaData
*
)
metadata
{
if
(
a
udioOnly
)
{
if
(
metadata
.
isA
udioOnly
)
{
_artworkView
.
contentMode
=
UIViewContentModeScaleAspectFill
;
_artworkView
.
image
=
artwork
?
artwork
:
[
UIImage
imageNamed
:
@"no-artwork"
];
_artworkView
.
image
=
metadata
.
artwork
Image
?
:
[
UIImage
imageNamed
:
@"no-artwork"
];
if
(
_videoView
)
{
[
_videoView
removeFromSuperview
];
_videoView
=
nil
;
...
...
@@ -242,14 +238,14 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
}
NSString
*
metaDataString
;
if
(
artist
)
metaDataString
=
artist
;
if
(
album
)
metaDataString
=
[
metaDataString
stringByAppendingFormat
:
@" — %@"
,
album
];
if
(
metadata
.
artist
)
metaDataString
=
metadata
.
artist
;
if
(
metadata
.
album
Name
)
metaDataString
=
[
metaDataString
stringByAppendingFormat
:
@" — %@"
,
metadata
.
album
Name
];
if
(
metaDataString
)
metaDataString
=
[
metaDataString
stringByAppendingFormat
:
@"
\n
%@"
,
title
];
metaDataString
=
[
metaDataString
stringByAppendingFormat
:
@"
\n
%@"
,
metadata
.
title
];
else
metaDataString
=
title
;
metaDataString
=
metadata
.
title
;
_metaDataLabel
.
text
=
metaDataString
;
}
...
...
Sources/VLCMovieViewControlPanelView.m
View file @
0f8bdb39
...
...
@@ -13,6 +13,7 @@
#import "VLCMovieViewControlPanelView.h"
#import "VLCPlaybackController.h"
#import "VLCMetadata.h"
@interface
VLCMovieViewControlPanelView
()
...
...
@@ -246,7 +247,7 @@ static const CGFloat maxCompactWidth = 420.0;
[
self
updatePlayPauseButton
];
self
.
trackSwitcherButton
.
hidden
=
!
self
.
playbackController
.
currentMediaHasTrackToChooseFrom
;
self
.
videoFilterButton
.
hidden
=
self
.
playbackController
.
audioOnlyPlaybackSession
;
self
.
videoFilterButton
.
hidden
=
self
.
playbackController
.
metadata
.
isAudioOnly
;
}
-
(
void
)
updatePlayPauseButton
...
...
Sources/VLCMovieViewController.m
View file @
0f8bdb39
...
...
@@ -34,6 +34,7 @@
#import "VLCSlider.h"
#import "VLCLibraryViewController.h"
#import "VLCTrackSelectorView.h"
#import "VLCMetadata.h"
#define FORWARD_SWIPE_DURATION 30
#define BACKWARD_SWIPE_DURATION 10
...
...
@@ -992,28 +993,23 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
}];
}
-
(
void
)
displayMetadataForPlaybackController
:(
VLCPlaybackController
*
)
controller
title
:(
NSString
*
)
title
artwork
:(
UIImage
*
)
artwork
artist
:(
NSString
*
)
artist
album
:(
NSString
*
)
album
audioOnly
:(
BOOL
)
audioOnly
-
(
void
)
displayMetadataForPlaybackController
:(
VLCPlaybackController
*
)
controller
metadata
:(
VLCMetaData
*
)
metadata
{
if
(
!
_viewAppeared
)
return
;
self
.
trackNameLabel
.
text
=
title
;
self
.
artworkImageView
.
image
=
artwork
;
if
(
!
artwork
)
{
self
.
artistNameLabel
.
text
=
artist
;
self
.
albumNameLabel
.
text
=
album
;
self
.
trackNameLabel
.
text
=
metadata
.
title
;
self
.
artworkImageView
.
image
=
metadata
.
artwork
Image
;
if
(
!
metadata
.
artwork
Image
)
{
self
.
artistNameLabel
.
text
=
metadata
.
artist
;
self
.
albumNameLabel
.
text
=
metadata
.
album
Name
;
}
else
self
.
artistNameLabel
.
text
=
self
.
albumNameLabel
.
text
=
nil
;
[
self
hideShowAspectratioButton
:
a
udioOnly
];
[
self
hideShowAspectratioButton
:
metadata
.
isA
udioOnly
];
[
_controllerPanel
updateButtons
];
_audioOnly
=
a
udioOnly
;
_audioOnly
=
metadata
.
isA
udioOnly
;
}
-
(
IBAction
)
playPause
...
...
Sources/VLCPlaybackController.h
View file @
0f8bdb39
...
...
@@ -22,6 +22,7 @@ extern NSString *const VLCPlaybackControllerPlaybackMetadataDidChange;
extern
NSString
*
const
VLCPlaybackControllerPlaybackPositionUpdated
;
@class
VLCPlaybackController
;
@class
VLCMetaData
;
@protocol
VLCPlaybackControllerDelegate
<
NSObject
>
@optional
...
...
@@ -33,12 +34,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
forPlaybackController
:(
VLCPlaybackController
*
)
controller
;
-
(
void
)
prepareForMediaPlayback
:(
VLCPlaybackController
*
)
controller
;
-
(
void
)
showStatusMessage
:(
NSString
*
)
statusMessage
forPlaybackController
:(
VLCPlaybackController
*
)
controller
;
-
(
void
)
displayMetadataForPlaybackController
:(
VLCPlaybackController
*
)
controller
title
:(
NSString
*
)
title
artwork
:(
UIImage
*
)
artwork
artist
:(
NSString
*
)
artist
album
:(
NSString
*
)
album
audioOnly
:(
BOOL
)
audioOnly
;
-
(
void
)
displayMetadataForPlaybackController
:(
VLCPlaybackController
*
)
controller
metadata
:(
VLCMetaData
*
)
metadata
;
@end
...
...
@@ -67,6 +63,8 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
@property
(
nonatomic
,
weak
)
id
<
VLCPlaybackControllerDelegate
>
delegate
;
@property
(
nonatomic
,
readonly
)
VLCMediaPlayerState
mediaPlayerState
;
@property
(
nonatomic
,
readonly
)
VLCMetaData
*
metadata
;
@property
(
nonatomic
,
readonly
)
NSInteger
mediaDuration
;
@property
(
nonatomic
,
readonly
)
BOOL
isPlaying
;
@property
(
nonatomic
,
readwrite
)
VLCRepeatMode
repeatMode
;
...
...
@@ -77,8 +75,6 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
@property
(
nonatomic
,
readonly
)
BOOL
currentMediaHasChapters
;
@property
(
nonatomic
,
readonly
)
BOOL
currentMediaHasTrackToChooseFrom
;
@property
(
nonatomic
,
readonly
)
BOOL
activePlaybackSession
;
@property
(
nonatomic
,
readonly
)
BOOL
audioOnlyPlaybackSession
;
@property
(
nonatomic
,
readonly
)
NSString
*
mediaTitle
;
@property
(
nonatomic
,
readwrite
)
BOOL
fullscreenSessionRequested
;
@property
(
nonatomic
,
readonly
)
NSDictionary
*
mediaOptionsDictionary
;
@property
(
nonatomic
,
readonly
)
NSTimer
*
sleepTimer
;
...
...
Sources/VLCPlaybackController.m
View file @
0f8bdb39
...
...
@@ -20,17 +20,10 @@
#import <CommonCrypto/CommonDigest.h>
#import "UIDevice+VLC.h"
#import <AVFoundation/AVFoundation.h>
#import <MediaPlayer/MediaPlayer.h>
#import "VLCPlayerDisplayController.h"
#import "VLCConstants.h"
#import "VLCRemoteControlService.h"
#if TARGET_OS_IOS
#import "VLCKeychainCoordinator.h"
#import "VLCThumbnailsCache.h"
#import "VLCLibraryViewController.h"
#import <WatchKit/WatchKit.h>
#endif
#import "VLCMetadata.h"
NSString
*
const
VLCPlaybackControllerPlaybackDidStart
=
@"VLCPlaybackControllerPlaybackDidStart"
;
NSString
*
const
VLCPlaybackControllerPlaybackDidPause
=
@"VLCPlaybackControllerPlaybackDidPause"
;
...
...
@@ -63,18 +56,10 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
NSUInteger
_currentAspectRatio
;
float
_currentPlaybackRate
;
UIView
*
_videoOutputViewWrapper
;
UIView
*
_actualVideoOutputView
;
UIView
*
_preBackgroundWrapperView
;
/* cached stuff for the VC */
NSString
*
_title
;
UIImage
*
_artworkImage
;
NSString
*
_artist
;
NSString
*
_albumName
;
BOOL
_mediaIsAudioOnly
;
BOOL
_needsMetadataUpdate
;
BOOL
_mediaWasJustStarted
;
BOOL
_recheckForExistingThumbnail
;
...
...
@@ -127,6 +112,7 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
[
defaultCenter
addObserver
:
self
selector
:
@selector
(
applicationDidEnterBackground
:
)
name:
UIApplicationDidEnterBackgroundNotification
object
:
nil
];
_metadata
=
[
VLCMetaData
new
];
_dialogProvider
=
[[
VLCDialogProvider
alloc
]
initWithLibrary
:[
VLCLibrary
sharedLibrary
]
customUI
:
NO
];
_playbackSessionManagementLock
=
[[
NSLock
alloc
]
init
];
...
...
@@ -487,7 +473,7 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
-
(
NSInteger
)
mediaDuration
{
return
_
listPlayer
.
mediaPlayer
.
media
.
length
.
intValue
;;
return
_mediaPlayer
.
media
.
length
.
intValue
;;
}
-
(
BOOL
)
isPlaying
...
...
@@ -520,38 +506,27 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
return
_activeSession
;
}
-
(
BOOL
)
audioOnlyPlaybackSession
{
return
_mediaIsAudioOnly
;
}
-
(
NSString
*
)
mediaTitle
{
return
_title
;
}
-
(
float
)
playbackRate
{
float
f_rate
=
_mediaPlayer
.
rate
;
_currentPlaybackRate
=
f_rate
;
return
f_rate
;
return
_mediaPlayer
.
rate
;
}
-
(
void
)
setPlaybackRate
:(
float
)
playbackRate
{
if
(
_currentPlaybackRate
!=
playbackRate
)
[
_mediaPlayer
setRate
:
playbackRate
];
_currentPlaybackRate
=
playbackRate
;
[
_mediaPlayer
setRate
:
playbackRate
];
_metadata
.
playbackRate
=
@
(
_mediaPlayer
.
rate
);
}
-
(
void
)
setAudioDelay
:(
float
)
audioDelay
{
_mediaPlayer
.
currentAudioPlaybackDelay
=
1000000
.
*
audioDelay
;
}
-
(
float
)
audioDelay
{
return
_mediaPlayer
.
currentAudioPlaybackDelay
/
1000000
.;
}
-
(
void
)
setSubtitleDelay
:(
float
)
subtitleDeleay
{
_mediaPlayer
.
currentVideoSubTitleDelay
=
1000000
.
*
subtitleDeleay
;
...
...
@@ -914,142 +889,14 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
if
(
_needsMetadataUpdate
==
NO
)
{
_needsMetadataUpdate
=
YES
;
dispatch_async
(
dispatch_get_main_queue
(),
^
{
[
self
_updateDisplayedMetadata
];
[
_metadata
updateMetadataFromMediaPlayer
:
_mediaPlayer
];
_needsMetadataUpdate
=
NO
;
if
([
self
.
delegate
respondsToSelector
:
@selector
(
displayMetadataForPlaybackController
:
metadata
:
)])
[
self
.
delegate
displayMetadataForPlaybackController
:
self
metadata
:
_metadata
];
});
}
}
-
(
void
)
_updateDisplayedMetadata
{
_needsMetadataUpdate
=
NO
;
NSNumber
*
trackNumber
;
NSString
*
title
;
NSString
*
artist
;
NSString
*
albumName
;
UIImage
*
artworkImage
;
BOOL
mediaIsAudioOnly
=
NO
;
#if TARGET_OS_IOS
MLFile
*
item
;
if
(
self
.
mediaList
)
{
NSArray
*
matches
=
[
MLFile
fileForURL
:
_mediaPlayer
.
media
.
url
];
item
=
matches
.
firstObject
;
}
if
(
item
)
{
if
(
item
.
isAlbumTrack
)
{
title
=
item
.
albumTrack
.
title
;
artist
=
item
.
albumTrack
.
artist
;
albumName
=
item
.
albumTrack
.
album
.
name
;
}
else
title
=
item
.
title
;
/* MLKit knows better than us if this thing is audio only or not */
mediaIsAudioOnly
=
[
item
isSupportedAudioFile
];
}
else
{
#endif
NSDictionary
*
metaDict
=
_mediaPlayer
.
media
.
metaDictionary
;
if
(
metaDict
)
{
title
=
metaDict
[
VLCMetaInformationNowPlaying
]
?
metaDict
[
VLCMetaInformationNowPlaying
]
:
metaDict
[
VLCMetaInformationTitle
];
artist
=
metaDict
[
VLCMetaInformationArtist
];
albumName
=
metaDict
[
VLCMetaInformationAlbum
];
trackNumber
=
metaDict
[
VLCMetaInformationTrackNumber
];
}
#if TARGET_OS_IOS
}
#endif
if
(
!
mediaIsAudioOnly
)
{
/* either what we are playing is not a file known to MLKit or
* MLKit fails to acknowledge that it is audio-only.
* Either way, do a more expensive check to see if it is really audio-only */
NSArray
*
tracks
=
_mediaPlayer
.
media
.
tracksInformation
;
NSUInteger
trackCount
=
tracks
.
count
;
mediaIsAudioOnly
=
YES
;
for
(
NSUInteger
x
=
0
;
x
<
trackCount
;
x
++
)
{
if
([[
tracks
[
x
]
objectForKey
:
VLCMediaTracksInformationType
]
isEqualToString
:
VLCMediaTracksInformationTypeVideo
])
{
mediaIsAudioOnly
=
NO
;
break
;
}
}
}
if
(
mediaIsAudioOnly
)
{
#if TARGET_OS_IOS
artworkImage
=
[
VLCThumbnailsCache
thumbnailForManagedObject
:
item
];
if
(
artworkImage
)
{
if
(
artist
)
title
=
[
title
stringByAppendingFormat
:
@" — %@"
,
artist
];
if
(
albumName
)
title
=
[
title
stringByAppendingFormat
:
@" — %@"
,
albumName
];
}
#endif
if
(
title
.
length
<
1
)
title
=
[[
_mediaPlayer
.
media
url
]
lastPathComponent
];
}
/* populate delegate with metadata info */
if
([
self
.
delegate
respondsToSelector
:
@selector
(
displayMetadataForPlaybackController
:
title
:
artwork
:
artist
:
album
:
audioOnly
:
)])
[
self
.
delegate
displayMetadataForPlaybackController
:
self
title:
title
artwork:
artworkImage
artist:
artist
album:
albumName
audioOnly:
mediaIsAudioOnly
];
/* populate now playing info center with metadata information */
NSMutableDictionary
*
currentlyPlayingTrackInfo
=
[
NSMutableDictionary
dictionary
];
currentlyPlayingTrackInfo
[
MPMediaItemPropertyPlaybackDuration
]
=
@
(
_mediaPlayer
.
media
.
length
.
intValue
/
1000
.);
currentlyPlayingTrackInfo
[
MPNowPlayingInfoPropertyElapsedPlaybackTime
]
=
@
(
_mediaPlayer
.
time
.
intValue
/
1000
.);
currentlyPlayingTrackInfo
[
MPNowPlayingInfoPropertyPlaybackRate
]
=
@
(
_mediaPlayer
.
isPlaying
?
_mediaPlayer
.
rate
:
0
.
0
);
/* don't leak sensitive information to the OS, if passcode lock is enabled */
#if TARGET_OS_IOS
if
(
!
[[
VLCKeychainCoordinator
defaultCoordinator
]
passcodeLockEnabled
])
{
#endif
if
(
title
)
currentlyPlayingTrackInfo
[
MPMediaItemPropertyTitle
]
=
title
;
if
(
artist
.
length
>
0
)
currentlyPlayingTrackInfo
[
MPMediaItemPropertyArtist
]
=
artist
;
if
(
albumName
.
length
>
0
)
currentlyPlayingTrackInfo
[
MPMediaItemPropertyAlbumTitle
]
=
albumName
;
if
([
trackNumber
intValue
]
>
0
)
currentlyPlayingTrackInfo
[
MPMediaItemPropertyAlbumTrackNumber
]
=
trackNumber
;
#if TARGET_OS_IOS
/* FIXME: UGLY HACK
* iOS 8.2 and 8.3 include an issue which will lead to a termination of the client app if we set artwork
* when the playback initialized through the watch extension
* radar://pending */
if
([
WKInterfaceDevice
class
]
!=
nil
)
{