Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_25606643
ijkplayer
提交
6bcf00f4
I
ijkplayer
项目概览
qq_25606643
/
ijkplayer
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
ijkplayer
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6bcf00f4
编写于
10月 09, 2013
作者:
B
bbcallen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ios: notify playback state change
上级
2bf698dc
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
77 addition
and
27 deletion
+77
-27
ijkmedia/ijkplayer/ff_ffmsg.h
ijkmedia/ijkplayer/ff_ffmsg.h
+1
-0
ijkmedia/ijkplayer/ijkplayer.c
ijkmedia/ijkplayer/ijkplayer.c
+22
-11
ijkmedia/ijkplayer/ijkplayer.h
ijkmedia/ijkplayer/ijkplayer.h
+1
-0
ios/IJKMediaPlayer/IJKMediaPlayer/IJKFFMoviePlayerController.m
...JKMediaPlayer/IJKMediaPlayer/IJKFFMoviePlayerController.m
+40
-5
ios/IJKMediaPlayer/IJKMediaPlayer/IJKMPMoviePlayerController.m
...JKMediaPlayer/IJKMediaPlayer/IJKMPMoviePlayerController.m
+13
-11
未找到文件。
ijkmedia/ijkplayer/ff_ffmsg.h
浏览文件 @
6bcf00f4
...
...
@@ -36,6 +36,7 @@
#define FFP_MSG_BUFFERING_BYTES_UPDATE 503
/* arg1 = cached data in bytes, arg2 = high water mark */
#define FFP_MSG_BUFFERING_TIME_UPDATE 504
/* arg1 = cached duration in milliseconds, arg2 = high water mark */
#define FFP_MSG_SEEK_COMPLETE 600
#define FFP_MSG_PLAYBACK_STATE_CHANGED 700
#define FFP_REQ_START 20001
#define FFP_REQ_PAUSE 20002
...
...
ijkmedia/ijkplayer/ijkplayer.c
浏览文件 @
6bcf00f4
...
...
@@ -71,6 +71,12 @@ void ijkmp_global_uninit()
ffp_global_uninit
();
}
void
ijkmp_change_state_l
(
IjkMediaPlayer
*
mp
,
int
new_state
)
{
mp
->
mp_state
=
new_state
;
ffp_notify_msg1
(
mp
->
ffplayer
,
FFP_MSG_PLAYBACK_STATE_CHANGED
);
}
IjkMediaPlayer
*
ijkmp_create
(
int
(
*
msg_loop
)(
void
*
))
{
IjkMediaPlayer
*
mp
=
(
IjkMediaPlayer
*
)
av_mallocz
(
sizeof
(
IjkMediaPlayer
));
...
...
@@ -163,7 +169,7 @@ void ijkmp_reset_l(IjkMediaPlayer *mp)
ffp_reset_internal
(
mp
->
ffplayer
);
av_freep
(
&
mp
->
data_source
);
mp
->
mp_state
=
MP_STATE_IDLE
;
ijkmp_change_state_l
(
mp
,
MP_STATE_IDLE
)
;
}
void
ijkmp_reset
(
IjkMediaPlayer
*
mp
)
...
...
@@ -226,7 +232,7 @@ static int ijkmp_set_data_source_l(IjkMediaPlayer *mp, const char *url)
if
(
!
mp
->
data_source
)
return
EIJK_OUT_OF_MEMORY
;
mp
->
mp_state
=
MP_STATE_INITIALIZED
;
ijkmp_change_state_l
(
mp
,
MP_STATE_INITIALIZED
)
;
return
0
;
}
...
...
@@ -259,7 +265,7 @@ static int ijkmp_prepare_async_l(IjkMediaPlayer *mp)
assert
(
mp
->
data_source
);
mp
->
mp_state
=
MP_STATE_ASYNC_PREPARING
;
ijkmp_change_state_l
(
mp
,
MP_STATE_ASYNC_PREPARING
)
;
msg_queue_start
(
&
mp
->
ffplayer
->
msg_queue
);
ijkmp_inc_ref
(
mp
);
...
...
@@ -268,7 +274,7 @@ static int ijkmp_prepare_async_l(IjkMediaPlayer *mp)
int
retval
=
ffp_prepare_async_l
(
mp
->
ffplayer
,
mp
->
data_source
);
if
(
retval
<
0
)
{
mp
->
mp_state
=
MP_STATE_ERROR
;
ijkmp_change_state_l
(
mp
,
MP_STATE_ERROR
)
;
return
retval
;
}
...
...
@@ -388,7 +394,7 @@ static int ijkmp_stop_l(IjkMediaPlayer *mp)
return
retval
;
}
mp
->
mp_state
=
MP_STATE_STOPPED
;
ijkmp_change_state_l
(
mp
,
MP_STATE_STOPPED
)
;
return
0
;
}
...
...
@@ -457,6 +463,11 @@ int ijkmp_seek_to(IjkMediaPlayer *mp, long msec)
return
retval
;
}
int
ijkmp_get_state
(
IjkMediaPlayer
*
mp
)
{
return
mp
->
mp_state
;
}
static
long
ijkmp_get_current_position_l
(
IjkMediaPlayer
*
mp
)
{
return
ffp_get_current_position_l
(
mp
->
ffplayer
);
...
...
@@ -512,7 +523,7 @@ int ijkmp_get_msg(IjkMediaPlayer *mp, AVMessage *msg, int block)
MPTRACE
(
"ijkmp_get_msg: FFP_MSG_PREPARED
\n
"
);
pthread_mutex_lock
(
&
mp
->
mutex
);
if
(
mp
->
mp_state
==
MP_STATE_ASYNC_PREPARING
)
{
mp
->
mp_state
=
MP_STATE_PREPARED
;
ijkmp_change_state_l
(
mp
,
MP_STATE_PREPARED
)
;
}
else
{
// FIXME: 1: onError() ?
ALOGE
(
"FFP_MSG_PREPARED: expecting mp_state==MP_STATE_ASYNC_PREPARING
\n
"
);
...
...
@@ -525,7 +536,7 @@ int ijkmp_get_msg(IjkMediaPlayer *mp, AVMessage *msg, int block)
pthread_mutex_lock
(
&
mp
->
mutex
);
mp
->
restart_from_beginning
=
1
;
mp
->
mp_state
=
MP_STATE_COMPLETED
;
ijkmp_change_state_l
(
mp
,
MP_STATE_COMPLETED
)
;
pthread_mutex_unlock
(
&
mp
->
mutex
);
break
;
...
...
@@ -549,19 +560,19 @@ int ijkmp_get_msg(IjkMediaPlayer *mp, AVMessage *msg, int block)
ALOGD
(
"ijkmp_get_msg: FFP_REQ_START: restart from beginning
\n
"
);
retval
=
ffp_start_from_l
(
mp
->
ffplayer
,
0
);
if
(
retval
==
0
)
mp
->
mp_state
=
MP_STATE_STARTED
;
ijkmp_change_state_l
(
mp
,
MP_STATE_STARTED
)
;
}
else
{
ALOGD
(
"ijkmp_get_msg: FFP_REQ_START: restart from seek pos
\n
"
);
retval
=
ffp_start_l
(
mp
->
ffplayer
);
if
(
retval
==
0
)
mp
->
mp_state
=
MP_STATE_STARTED
;
ijkmp_change_state_l
(
mp
,
MP_STATE_STARTED
)
;
}
mp
->
restart_from_beginning
=
0
;
}
else
{
ALOGD
(
"ijkmp_get_msg: FFP_REQ_START: start on fly
\n
"
);
retval
=
ffp_start_l
(
mp
->
ffplayer
);
if
(
retval
==
0
)
mp
->
mp_state
=
MP_STATE_STARTED
;
ijkmp_change_state_l
(
mp
,
MP_STATE_STARTED
)
;
}
}
pthread_mutex_unlock
(
&
mp
->
mutex
);
...
...
@@ -574,7 +585,7 @@ int ijkmp_get_msg(IjkMediaPlayer *mp, AVMessage *msg, int block)
if
(
0
==
ikjmp_chkst_pause_l
(
mp
->
mp_state
))
{
int
retval
=
ffp_pause_l
(
mp
->
ffplayer
);
if
(
retval
==
0
)
mp
->
mp_state
=
MP_STATE_PAUSED
;
ijkmp_change_state_l
(
mp
,
MP_STATE_STARTED
)
;
}
pthread_mutex_unlock
(
&
mp
->
mutex
);
break
;
...
...
ijkmedia/ijkplayer/ijkplayer.h
浏览文件 @
6bcf00f4
...
...
@@ -167,6 +167,7 @@ int ijkmp_start(IjkMediaPlayer *mp);
int
ijkmp_pause
(
IjkMediaPlayer
*
mp
);
int
ijkmp_stop
(
IjkMediaPlayer
*
mp
);
int
ijkmp_seek_to
(
IjkMediaPlayer
*
mp
,
long
msec
);
int
ijkmp_get_state
(
IjkMediaPlayer
*
mp
);
bool
ijkmp_is_playing
(
IjkMediaPlayer
*
mp
);
long
ijkmp_get_current_position
(
IjkMediaPlayer
*
mp
);
long
ijkmp_get_duration
(
IjkMediaPlayer
*
mp
);
...
...
ios/IJKMediaPlayer/IJKMediaPlayer/IJKFFMoviePlayerController.m
浏览文件 @
6bcf00f4
...
...
@@ -41,7 +41,7 @@
@synthesize
playableDuration
;
@synthesize
isPreparedToPlay
;
@synthesize
playbackState
=
_playbackState
;
@synthesize
playbackState
;
@synthesize
loadState
=
_loadState
;
@synthesize
naturalSize
=
_naturalSize
;
...
...
@@ -124,6 +124,40 @@
return
ijkmp_is_playing
(
_mediaPlayer
);
}
-
(
MPMoviePlaybackState
)
playbackState
{
if
(
!
_mediaPlayer
)
return
NO
;
MPMoviePlaybackState
mp_state
=
MPMoviePlaybackStateStopped
;
int
state
=
ijkmp_get_state
(
_mediaPlayer
);
switch
(
state
)
{
case
MP_STATE_STOPPED
:
case
MP_STATE_COMPLETED
:
case
MP_STATE_ERROR
:
case
MP_STATE_END
:
mp_state
=
MPMoviePlaybackStateStopped
;
break
;
case
MP_STATE_IDLE
:
case
MP_STATE_INITIALIZED
:
case
MP_STATE_ASYNC_PREPARING
:
case
MP_STATE_PREPARED
:
case
MP_STATE_PAUSED
:
mp_state
=
MPMoviePlaybackStatePaused
;
break
;
case
MP_STATE_STARTED
:
mp_state
=
MPMoviePlaybackStatePlaying
;
break
;
}
// MPMoviePlaybackStatePlaying,
// MPMoviePlaybackStatePaused,
// MPMoviePlaybackStateStopped,
// MPMoviePlaybackStateInterrupted,
// MPMoviePlaybackStateSeekingForward,
// MPMoviePlaybackStateSeekingBackward
return
ijkmp_is_playing
(
_mediaPlayer
);
}
-
(
void
)
setCurrentPlaybackTime
:(
NSTimeInterval
)
aCurrentPlaybackTime
{
if
(
!
_mediaPlayer
)
...
...
@@ -168,8 +202,6 @@
case
FFP_MSG_ERROR
:
{
NSLog
(
@"FFP_MSG_ERROR: %d"
,
avmsg
->
arg1
);
_playbackState
=
MPMoviePlaybackStateStopped
;
[[
NSNotificationCenter
defaultCenter
]
postNotificationName:
IJKMoviePlayerPlaybackDidFinishNotification
object
:
self
];
...
...
@@ -191,8 +223,6 @@
break
;
case
FFP_MSG_COMPLETED
:
{
_playbackState
=
MPMoviePlaybackStateStopped
;
[[
NSNotificationCenter
defaultCenter
]
postNotificationName:
IJKMoviePlayerPlaybackDidFinishNotification
object
:
self
];
...
...
@@ -246,6 +276,11 @@
case
FFP_MSG_BUFFERING_TIME_UPDATE
:
// NSLog(@"FFP_MSG_BUFFERING_TIME_UPDATE: %d", avmsg->arg1);
break
;
case
FFP_MSG_PLAYBACK_STATE_CHANGED
:
[[
NSNotificationCenter
defaultCenter
]
postNotificationName:
IJKMoviePlayerPlaybackStateDidChangeNotification
object:
self
];
break
;
case
FFP_MSG_SEEK_COMPLETE
:
// NSLog(@"FFP_MSG_SEEK_COMPLETE:");
break
;
...
...
ios/IJKMediaPlayer/IJKMediaPlayer/IJKMPMoviePlayerController.m
浏览文件 @
6bcf00f4
...
...
@@ -51,13 +51,15 @@
self
.
scalingMode
=
MPMovieScalingModeAspectFit
;
self
.
shouldAutoplay
=
YES
;
self
.
useApplicationAudioSession
=
NO
;
[
self
IJK_installMovieNotificationObservers
];
}
return
self
;
}
-
(
void
)
dealloc
{
[
self
removeMovieNotificationObservers
];
[
self
IJK_
removeMovieNotificationObservers
];
}
-
(
BOOL
)
isPlaying
...
...
@@ -73,30 +75,30 @@
#pragma mark Movie Notification Handlers
/* Register observers for the various movie object notifications. */
-
(
void
)
installMovieNotificationObservers
-
(
void
)
IJK_
installMovieNotificationObservers
{
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector:
@selector
(
dispatchMPMediaPlaybackIsPreparedToPlayDidChangeNotification
:)
selector:
@selector
(
IJK_
dispatchMPMediaPlaybackIsPreparedToPlayDidChangeNotification
:)
name:
MPMediaPlaybackIsPreparedToPlayDidChangeNotification
object:
self
];
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector:
@selector
(
dispatchMPMoviePlayerLoadStateDidChangeNotification
:)
selector:
@selector
(
IJK_
dispatchMPMoviePlayerLoadStateDidChangeNotification
:)
name:
MPMoviePlayerLoadStateDidChangeNotification
object:
self
];
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector:
@selector
(
dispatchMPMoviePlayerPlaybackDidFinishNotification
:)
selector:
@selector
(
IJK_
dispatchMPMoviePlayerPlaybackDidFinishNotification
:)
name:
MPMoviePlayerPlaybackDidFinishNotification
object:
self
];
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector:
@selector
(
dispatchMPMoviePlayerPlaybackStateDidChangeNotification
:)
selector:
@selector
(
IJK_
dispatchMPMoviePlayerPlaybackStateDidChangeNotification
:)
name:
MPMoviePlayerPlaybackStateDidChangeNotification
object:
self
];
}
-
(
void
)
removeMovieNotificationObservers
-
(
void
)
IJK_
removeMovieNotificationObservers
{
[[
NSNotificationCenter
defaultCenter
]
removeObserver
:
self
name
:
MPMediaPlaybackIsPreparedToPlayDidChangeNotification
object
:
self
];
...
...
@@ -105,22 +107,22 @@
[[
NSNotificationCenter
defaultCenter
]
removeObserver
:
self
name
:
MPMoviePlayerPlaybackStateDidChangeNotification
object
:
self
];
}
-
(
void
)
dispatchMPMediaPlaybackIsPreparedToPlayDidChangeNotification
:(
NSNotification
*
)
notification
-
(
void
)
IJK_
dispatchMPMediaPlaybackIsPreparedToPlayDidChangeNotification
:(
NSNotification
*
)
notification
{
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
IJKMediaPlaybackIsPreparedToPlayDidChangeNotification
object
:
notification
.
object
userInfo
:
notification
.
userInfo
];
}
-
(
void
)
dispatchMPMoviePlayerLoadStateDidChangeNotification
:(
NSNotification
*
)
notification
-
(
void
)
IJK_
dispatchMPMoviePlayerLoadStateDidChangeNotification
:(
NSNotification
*
)
notification
{
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
IJKMoviePlayerLoadStateDidChangeNotification
object
:
notification
.
object
userInfo
:
notification
.
userInfo
];
}
-
(
void
)
dispatchMPMoviePlayerPlaybackDidFinishNotification
:(
NSNotification
*
)
notification
-
(
void
)
IJK_
dispatchMPMoviePlayerPlaybackDidFinishNotification
:(
NSNotification
*
)
notification
{
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
IJKMoviePlayerPlaybackDidFinishNotification
object
:
notification
.
object
userInfo
:
notification
.
userInfo
];
}
-
(
void
)
dispatchMPMoviePlayerPlaybackStateDidChangeNotification
:(
NSNotification
*
)
notification
-
(
void
)
IJK_
dispatchMPMoviePlayerPlaybackStateDidChangeNotification
:(
NSNotification
*
)
notification
{
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
IJKMoviePlayerPlaybackStateDidChangeNotification
object
:
notification
.
object
userInfo
:
notification
.
userInfo
];
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录