Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-1.1
Commits
35f97beb
Commit
35f97beb
authored
Dec 24, 2007
by
Pierre d'Herbemont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sources/VLCMedia.m: Implement a KeyValueCoding enabled -state property.
parent
141e740f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
2 deletions
+57
-2
extras/MacOSX/Framework/Headers/Public/VLCMedia.h
extras/MacOSX/Framework/Headers/Public/VLCMedia.h
+16
-1
extras/MacOSX/Framework/Sources/VLCMedia.m
extras/MacOSX/Framework/Sources/VLCMedia.m
+41
-1
No files found.
extras/MacOSX/Framework/Headers/Public/VLCMedia.h
View file @
35f97beb
...
...
@@ -61,6 +61,14 @@ extern NSString *VLCMediaMetaChanged; //< Notification message for when t
@class
VLCMediaList
;
@class
VLCMedia
;
typedef
enum
VLCMediaState
{
VLCMediaStateNothingSpecial
,
//< Nothing
VLCMediaStateBuffering
,
//< Stream is buffering
VLCMediaStatePlaying
,
//< Stream is playing
VLCMediaStateError
,
//< Can't be played because an error occured
}
VLCMediaState
;
/**
* Informal protocol declaration for VLCMedia delegates. Allows data changes to be
* trapped.
...
...
@@ -108,6 +116,7 @@ extern NSString *VLCMediaMetaChanged; //< Notification message for when t
NSMutableDictionary
*
metaDictionary
;
//< Meta data storage
id
delegate
;
//< Delegate object
BOOL
preparsed
;
//< Value used to determine of the file has been preparsed
VLCMediaState
state
;
}
/* Object Factories */
...
...
@@ -195,4 +204,10 @@ extern NSString *VLCMediaMetaChanged; //< Notification message for when t
* \return The receiver's meta data as a NSDictionary object.
*/
-
(
NSDictionary
*
)
metaDictionary
;
/**
* Returns the receiver's state.
* \return The receiver's state, such as Playing, Error, NothingSpecial, Buffering.
*/
-
(
VLCMediaState
)
state
;
@end
extras/MacOSX/Framework/Sources/VLCMedia.m
View file @
35f97beb
...
...
@@ -72,6 +72,22 @@ NSString *VLCMediaMetaChanged = @"VLCMediaMetaChanged";
-
(
void
)
metaChanged
:(
NSString
*
)
metaType
;
@end
static
VLCMediaState
libvlc_state_to_media_state
[]
=
{
[
libvlc_NothingSpecial
]
=
VLCMediaStateNothingSpecial
,
[
libvlc_Stopped
]
=
VLCMediaStateNothingSpecial
,
[
libvlc_Opening
]
=
VLCMediaStateNothingSpecial
,
[
libvlc_Buffering
]
=
VLCMediaStateBuffering
,
[
libvlc_Ended
]
=
VLCMediaStateNothingSpecial
,
[
libvlc_Error
]
=
VLCMediaStateError
,
[
libvlc_Playing
]
=
VLCMediaStatePlaying
,
[
libvlc_Paused
]
=
VLCMediaStatePlaying
,
};
static
inline
VLCMediaState
LibVLCStateToMediaState
(
libvlc_state_t
state
)
{
return
libvlc_state_to_media_state
[
state
];
}
/******************************************************************************
* LibVLC Event Callback
...
...
@@ -96,6 +112,16 @@ static void HandleMediaDurationChanged(const libvlc_event_t *event, void *self)
[
pool
release
];
}
static
void
HandleMediaStateChanged
(
const
libvlc_event_t
*
event
,
void
*
self
)
{
NSAutoreleasePool
*
pool
=
[[
NSAutoreleasePool
alloc
]
init
];
[[
VLCEventManager
sharedManager
]
callOnMainThreadObject
:
self
withMethod:
@selector
(
setState
:)
withArgumentAsObject:
[
NSNumber
numberWithInt
:
LibVLCStateToMediaState
(
event
->
u
.
media_descriptor_state_changed
.
new_state
)]];
[
pool
release
];
}
/******************************************************************************
* Implementation
*/
...
...
@@ -179,6 +205,7 @@ static void HandleMediaDurationChanged(const libvlc_event_t *event, void *self)
libvlc_event_manager_t
*
p_em
=
libvlc_media_descriptor_event_manager
(
p_md
,
NULL
);
libvlc_event_detach
(
p_em
,
libvlc_MediaDescriptorMetaChanged
,
HandleMediaMetaChanged
,
self
,
NULL
);
libvlc_event_detach
(
p_em
,
libvlc_MediaDescriptorDurationChanged
,
HandleMediaDurationChanged
,
self
,
NULL
);
libvlc_event_detach
(
p_em
,
libvlc_MediaDescriptorStateChanged
,
HandleMediaStateChanged
,
self
,
NULL
);
}
[
super
release
];
}
...
...
@@ -283,6 +310,11 @@ static void HandleMediaDurationChanged(const libvlc_event_t *event, void *self)
{
return
delegate
;
}
-
(
VLCMediaState
)
state
{
return
state
;
}
@end
/******************************************************************************
...
...
@@ -394,6 +426,7 @@ static void HandleMediaDurationChanged(const libvlc_event_t *event, void *self)
libvlc_event_manager_t
*
p_em
=
libvlc_media_descriptor_event_manager
(
p_md
,
&
ex
);
libvlc_event_attach
(
p_em
,
libvlc_MediaDescriptorMetaChanged
,
HandleMediaMetaChanged
,
self
,
&
ex
);
libvlc_event_attach
(
p_em
,
libvlc_MediaDescriptorDurationChanged
,
HandleMediaDurationChanged
,
self
,
&
ex
);
libvlc_event_attach
(
p_em
,
libvlc_MediaDescriptorStateChanged
,
HandleMediaStateChanged
,
self
,
&
ex
);
quit_on_exception
(
&
ex
);
libvlc_media_list_t
*
p_mlist
=
libvlc_media_descriptor_subitems
(
p_md
,
NULL
);
...
...
@@ -405,7 +438,7 @@ static void HandleMediaDurationChanged(const libvlc_event_t *event, void *self)
subitems
=
[[
VLCMediaList
mediaListWithLibVLCMediaList
:
p_mlist
]
retain
];
libvlc_media_list_release
(
p_mlist
);
}
state
=
LibVLCStateToMediaState
(
libvlc_media_descriptor_get_state
(
p_md
,
NULL
));
/* Force VLCMetaInformationTitle, that will trigger preparsing
* And all the other meta will be added through the libvlc event system */
[
self
fetchMetaInformationFromLibVLCWithType
:
VLCMetaInformationTitle
];
...
...
@@ -474,4 +507,11 @@ static void HandleMediaDurationChanged(const libvlc_event_t *event, void *self)
length
=
value
?
[
value
retain
]
:
nil
;
[
self
didChangeValueForKey
:
@"length"
];
}
-
(
void
)
setState
:(
NSNumber
*
)
newStateAsNumber
{
[
self
willChangeValueForKey
:
@"state"
];
state
=
[
newStateAsNumber
intValue
];
[
self
didChangeValueForKey
:
@"state"
];
}
@end
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