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
86219643
Commit
86219643
authored
Apr 07, 2015
by
Tobias
Committed by
Felix Paul Kühne
May 13, 2015
Browse files
use mediaLibraryObject for now playing info
parent
d49ef114
Changes
7
Hide whitespace changes
Inline
Side-by-side
Sources/VLCAppDelegate.m
View file @
86219643
...
...
@@ -146,7 +146,7 @@
[[
VLCNotificationRelay
sharedRelay
]
addRelayLocalName
:
NSManagedObjectContextDidSaveNotification
toRemoteName
:
@"org.videolan.ios-app.dbupdate"
];
[[
VLCNotificationRelay
sharedRelay
]
addRelayLocalName
:
@"n
owPlayingInfoUpdate
"
toRemoteName
:
@"org.videolan.ios-app.n
owPlayingInfoUpdate
"
];
[[
VLCNotificationRelay
sharedRelay
]
addRelayLocalName
:
kVLCNotificationN
owPlayingInfoUpdate
toRemoteName
:
kVLCDarwinNotificationN
owPlayingInfoUpdate
];
return
YES
;
}
...
...
@@ -570,7 +570,7 @@
-
(
void
)
application
:(
UIApplication
*
)
application
handleWatchKitExtensionRequest
:(
NSDictionary
*
)
userInfo
reply
:(
void
(
^
)(
NSDictionary
*
))
reply
{
NSDictionary
*
reponseDict
=
nil
;
if
([
userInfo
[
@"name"
]
isEqualToString
:
@"getNowPlayingInfo"
])
{
reponseDict
=
[
MPNowPlayingInfoCenter
defaultCenter
].
nowPlayingInfo
;
reponseDict
=
[
self
nowPlayingResponseDict
]
;
}
else
if
([
userInfo
[
@"name"
]
isEqualToString
:
@"playpause"
])
{
[
_movieViewController
playPause
];
}
else
if
([
userInfo
[
@"name"
]
isEqualToString
:
@"skipForward"
])
{
...
...
@@ -584,19 +584,32 @@
}
reply
(
reponseDict
);
}
-
(
void
)
playFileFromWatch
:(
NSDictionary
*
)
userInfo
{
MLMediaLibrary
*
library
=
[
MLMediaLibrary
sharedMediaLibrary
];
NSManagedObject
*
managedObject
=
nil
;
NSString
*
uriString
=
userInfo
[
@"URIRepresentation"
];
NSURL
*
uriRepresentation
=
[
NSURL
URLWithString
:
uriString
];
NSPersistentStoreCoordinator
*
persistentStoreCoordinator
=
library
.
persistentStoreCoordinator
;
if
(
persistentStoreCoordinator
)
{
NSManagedObjectID
*
objectID
=
[
persistentStoreCoordinator
managedObjectIDForURIRepresentation
:
uriRepresentation
];
NSManagedObjectContext
*
moc
=
[(
id
)
library
managedObjectContext
];
if
(
moc
)
{
NSManagedObject
*
managedObject
=
[
moc
objectWithID
:
objectID
];
[
self
openMediaFromManagedObject
:
managedObject
];
}
if
(
uriString
)
{
NSURL
*
uriRepresentation
=
[
NSURL
URLWithString
:
uriString
];
managedObject
=
[[
MLMediaLibrary
sharedMediaLibrary
]
objectForURIRepresentation
:
uriRepresentation
];
}
if
(
managedObject
)
{
[
self
openMediaFromManagedObject
:
managedObject
];
}
}
-
(
NSDictionary
*
)
nowPlayingResponseDict
{
NSMutableDictionary
*
response
=
[
NSMutableDictionary
new
];
NSDictionary
*
nowPlayingInfo
=
[
MPNowPlayingInfoCenter
defaultCenter
].
nowPlayingInfo
;
if
(
nowPlayingInfo
)
{
response
[
@"nowPlayingInfo"
]
=
nowPlayingInfo
;
}
MLFile
*
currentFile
=
_movieViewController
.
currentlyPlayingMediaFile
;
NSString
*
URIString
=
currentFile
.
objectID
.
URIRepresentation
.
absoluteString
;
if
(
URIString
)
{
response
[
@"URIRepresentation"
]
=
URIString
;
}
return
response
;
}
@end
Sources/VLCConstants.h
View file @
86219643
...
...
@@ -77,6 +77,10 @@
#define kBlobHash @"521923d214b9ae628da7987cf621e94c4afdd726"
#define kVLCNotificationNowPlayingInfoUpdate @"nowPlayingInfoUpdate"
#define kVLCDarwinNotificationNowPlayingInfoUpdate @"org.videolan.ios-app.nowPlayingInfoUpdate"
#if TARGET_IPHONE_SIMULATOR
#define WifiInterfaceName @"en1"
#else
...
...
Sources/VLCMovieViewController.h
View file @
86219643
...
...
@@ -92,6 +92,9 @@
@property
(
nonatomic
,
retain
)
VLCMediaList
*
mediaList
;
@property
(
nonatomic
,
readwrite
)
int
itemInMediaListToBePlayedFirst
;
/* returns nil if currenlty plaing item is not a MLFile, e.g. a url */
@property
(
nonatomic
,
strong
,
readonly
)
MLFile
*
currentlyPlayingMediaFile
;
-
(
IBAction
)
closePlayback
:(
id
)
sender
;
-
(
void
)
unanimatedPlaybackStop
;
...
...
Sources/VLCMovieViewController.m
View file @
86219643
...
...
@@ -179,6 +179,20 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
[
self
_startPlayback
];
}
-
(
MLFile
*
)
currentlyPlayingMediaFile
{
MLFile
*
mediaFile
=
self
.
fileFromMediaLibrary
;
if
(
mediaFile
)
{
return
mediaFile
;
}
// VLCMediaList *mediaList = self.mediaList;
// if (mediaList) {
// TODO: get current MLFile ?
// }
return
nil
;
}
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
...
...
@@ -2326,7 +2340,7 @@ static inline NSArray * RemoteCommandCenterCommandsToHandle(MPRemoteCommandCente
}
[
MPNowPlayingInfoCenter
defaultCenter
].
nowPlayingInfo
=
currentlyPlayingTrackInfo
;
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
@"n
owPlayingInfoUpdate
"
object
:
self
];
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
kVLCNotificationN
owPlayingInfoUpdate
object
:
self
];
}
#pragma mark - autorotation
...
...
VLC for iOS WatchKit App/Base.lproj/Interface.storyboard
View file @
86219643
...
...
@@ -135,9 +135,11 @@
</button>
</items>
</group>
<imageView
width=
"1"
alignment=
"center"
contentMode=
"scaleAspectFill"
id=
"3JI-SS-2Wb"
/>
</items>
<connections>
<outlet
property=
"durationLabel"
destination=
"D0h-cq-wsv"
id=
"3AN-YZ-yEj"
/>
<outlet
property=
"image"
destination=
"3JI-SS-2Wb"
id=
"rqC-Lb-tRt"
/>
<outlet
property=
"playPauseButton"
destination=
"BAZ-aC-ETt"
id=
"X17-bz-cFy"
/>
<outlet
property=
"titleLabel"
destination=
"H58-Y8-Tbc"
id=
"xZs-ZW-Shj"
/>
</connections>
...
...
VLC for iOS WatchKit Extension/VLCNowPlayingInterfaceController.h
View file @
86219643
...
...
@@ -14,6 +14,7 @@
#import <Foundation/Foundation.h>
@interface
VLCNowPlayingInterfaceController
:
WKInterfaceController
@property
(
weak
,
nonatomic
)
IBOutlet
WKInterfaceImage
*
image
;
@property
(
weak
,
nonatomic
)
IBOutlet
WKInterfaceLabel
*
titleLabel
;
@property
(
weak
,
nonatomic
)
IBOutlet
WKInterfaceLabel
*
durationLabel
;
@property
(
weak
,
nonatomic
)
IBOutlet
WKInterfaceButton
*
playPauseButton
;
...
...
VLC for iOS WatchKit Extension/VLCNowPlayingInterfaceController.m
View file @
86219643
...
...
@@ -13,7 +13,9 @@
#import "VLCNowPlayingInterfaceController.h"
#import <MediaPlayer/MediaPlayer.h>
#import <MobileVLCKit/VLCTime.h>
#import <MediaLibraryKit/MediaLibraryKit.h>
#import "VLCNotificationRelay.h"
#import "VLCThumbnailsCache.h"
@interface
VLCNowPlayingInterfaceController
()
@property
(
nonatomic
,
copy
)
NSString
*
titleString
;
...
...
@@ -56,13 +58,25 @@
-
(
void
)
requestNowPlayingInfo
{
[
WKInterfaceController
openParentApplication
:@{
@"name"
:
@"getNowPlayingInfo"
}
reply
:
^
(
NSDictionary
*
replyInfo
,
NSError
*
error
)
{
[
self
updateWithNowPlayingInfo
:
replyInfo
];
NSLog
(
@"nowplayingInfo: %@"
,
replyInfo
);
MLFile
*
file
=
nil
;
NSString
*
uriString
=
replyInfo
[
@"URIRepresentation"
];
if
(
uriString
)
{
NSURL
*
uriRepresentation
=
[
NSURL
URLWithString
:
uriString
];
file
=
[
MLFile
fileForURIRepresentation
:
uriRepresentation
];
}
[
self
updateWithNowPlayingInfo
:
replyInfo
[
@"nowPlayingInfo"
]
andFile
:
file
];
}];
}
-
(
void
)
updateWithNowPlayingInfo
:(
NSDictionary
*
)
nowPlayingInfo
{
self
.
titleString
=
nowPlayingInfo
[
MPMediaItemPropertyTitle
];
self
.
playBackDurationNumber
=
nowPlayingInfo
[
MPMediaItemPropertyPlaybackDuration
];
-
(
void
)
updateWithNowPlayingInfo
:(
NSDictionary
*
)
nowPlayingInfo
andFile
:(
MLFile
*
)
file
{
self
.
titleString
=
file
.
title
?:
nowPlayingInfo
[
MPMediaItemPropertyTitle
];
NSNumber
*
duration
=
file
.
duration
;
if
(
!
duration
)
{
float
durationFloat
=
duration
.
floatValue
;
duration
=
@
(
durationFloat
*
1000
);
}
self
.
playBackDurationNumber
=
duration
;
self
.
image
.
image
=
[
VLCThumbnailsCache
thumbnailForManagedObject
:
file
];
}
-
(
IBAction
)
playPausePressed
{
...
...
@@ -95,12 +109,7 @@
-
(
void
)
setPlayBackDurationNumber
:(
NSNumber
*
)
playBackDurationNumber
{
if
(
!
[
_playBackDurationNumber
isEqualToNumber
:
playBackDurationNumber
]
||
(
_playBackDurationNumber
==
nil
&&
playBackDurationNumber
))
{
_playBackDurationNumber
=
playBackDurationNumber
;
float
duratioFloat
=
playBackDurationNumber
.
floatValue
;
NSNumber
*
durationNumber
=
nil
;
if
(
duratioFloat
>
0
.
0
)
{
durationNumber
=
@
(
playBackDurationNumber
.
floatValue
*
1000
);
}
self
.
durationLabel
.
text
=
[
VLCTime
timeWithNumber
:
durationNumber
].
stringValue
;
self
.
durationLabel
.
text
=
[
VLCTime
timeWithNumber
:
playBackDurationNumber
].
stringValue
;
}
}
...
...
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