MediaPlayer.setLooping(true);

2022-07-20  本文已影响0人  gale_小米

Android MediaPlayer 播放特定视频setLooping(true) 无效不能循环播放

2022-07-20 13:22:18.080 2246-1353/? D/awplayer: <BaseCompPostAndWait:61>: video render receive cmd: eos
2022-07-20 13:22:18.253 2246-1352/? D/awplayer: <XPlayerThread:2154>: process message XPLAYER_COMMAND_START.
2022-07-20 13:22:18.254 2246-1352/? D/awplayer: <PlayerStop:860>: ****** PlayerStop
2022-07-20 13:22:18.254 2246-1352/? D/awplayer: <BaseCompPostAndWait:61>: video render receive cmd: stop
2022-07-20 13:22:18.254 2246-1352/? D/awplayer: <BaseCompPostAndWait:61>: video decoder receive cmd: stop
2022-07-20 13:22:18.266 2246-1352/? D/awplayer: <PlayerStop:892>: ****** PlayerStop end
2022-07-20 13:22:18.266 2246-1352/? D/awplayer: <BaseCompPostAndWait:61>: video render receive cmd: quit
2022-07-20 13:22:18.267 1291-1365/ E/BufferQueueProducer: [SurfaceTexture-0-1291-0] connect: already connected (cur=3 req=3)
2022-07-20 13:22:18.270 2246-1352/? D/awplayer: <BaseCompPostAndWait:61>: video decoder receive cmd: quit
W/MediaPlayerNative: info/warning (801, 0)

跟了一下源码

process message XPLAYER_COMMAND_START.
mMediaInfo->bSeekable

##android\frameworks\av\media\libcedarx\xplayer\xplayer.c
static void* XPlayerThread(void* arg)
{
        ......
else if(msg.messageId == XPLAYER_COMMAND_START)
        {
            logd("process message XPLAYER_COMMAND_START.");


            //* for complete status, we seek to mSeekTime(the last seek time).
            //logd("==== process message mPriData->mStatus == XPLAYER_STATUS_COMPLETE %s.",( (mPriData->mStatus == XPLAYER_STATUS_COMPLETE)?"true":"false" ));
            //logd("==== process message mPriData->mMediaInfo->bSeekable %d.",mPriData->mMediaInfo->bSeekable);
            if(mPriData->mStatus == XPLAYER_STATUS_COMPLETE)
            {
                AwMessage newMsg;
                  //定位到这里 这个mMediaInfo bSeekable 为false状态
                mPriData->mMediaInfo->bSeekable =1;//那么这里直接赋值为1(走到这里视频时可以正常播放的)
                if(mPriData->mMediaInfo->bSeekable)
                {
                    if(mPriData->mSeeking)
                    {
                        DemuxCompCancelSeek(mPriData->mDemux);
                        mPriData->mSeeking = 0;
                    }

                    mPriData->mSeeking  = 1;
                    mPriData->mSeekSync = 0;
                    mPriData->mSeekByInner = 1;
                    logd("seekTo %.2f secs", mPriData->mSeekTime / 1E3);

                    PlayerPause(mPriData->mPlayer);
                    DemuxCompSeekTo(mPriData->mDemux, mPriData->mSeekTime, mPriData->mSeekModeType);

                    //* player and demux will be started at the seek callback.
                    mPriData->mStatus = XPLAYER_STATUS_STARTED;
                    pthread_mutex_unlock(&mPriData->mMutexStatus);

                    if(pReplyValue != NULL)
                        *pReplyValue = (int)0;
                    if(pReplySem != NULL)
                        sem_post(pReplySem);
                    continue;
                }
                else
                {
                    //* post a stop message.
                    memset(&newMsg, 0, sizeof(AwMessage));
                    newMsg.messageId = XPLAYER_COMMAND_STOP;
                    AwMessageQueuePostMessage(mPriData->mMessageQueue, &newMsg);

                    //* post a prepare message.
                    memset(&newMsg, 0, sizeof(AwMessage));
                    newMsg.messageId = XPLAYER_COMMAND_PREPARE;
                    newMsg.params[0] = 0;
                    newMsg.params[1] = 0;
                    newMsg.params[2] = 1;   //* params[2] = mPrepareSync.
                    AwMessageQueuePostMessage(mPriData->mMessageQueue, &newMsg);

                    //* post a start message.
                    memset(&newMsg, 0, sizeof(AwMessage));
                    newMsg.messageId = XPLAYER_COMMAND_START;
                    AwMessageQueuePostMessage(mPriData->mMessageQueue, &newMsg);

                    //* should I reply 0 to the user at this moment?
                    //* or just set the semaphore and reply variable to the start message to
                    //* make it reply when start message done?
                    pthread_mutex_unlock(&mPriData->mMutexStatus);
                    if(pReplyValue != NULL)
                        *pReplyValue = (int)0;
                    if(pReplySem != NULL)
                        sem_post(pReplySem);
                    continue;
                }
            }

            pthread_mutex_unlock(&mPriData->mMutexStatus);


        ......
}
上一篇下一篇

猜你喜欢

热点阅读