同步操作将从 OpenHarmony/docs 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
Audio and video playback is a process in which audio and video files or audio and video stream data is decoded and played by using an output device, and a playback task is managed.
The audio and video playback APIs are described as follows. For details about the APIs, see the API reference document.
Table 1 Audio and Video Playback APIs
When the input source is an audio or video stream, the playback progress cannot be controlled and the file duration cannot be obtained.
Implement the PlayerCallback callback function for event processing.
class TestPlayerCallback : public PlayerCallback{
void OnPlayBackComplete() override
{
// The implementation code is used to process the event that the file playback is complete.
}
void OnError(int32_t errorType, int32_t errorCode) override
{
// Implement the code processing error event.
}
void OnInfo(int type, int extra) override
{
//Implement the code to process common events.
}
void OnRewindToComplete() override
{
//Implement the event that the code processing progress control is complete.
}
};
Create a player instance, set the playback source, and start playback.
Player *player = Player::CreatePlayer();
std::shared_ptr<PlayerCallback> callback = std::make_shared<TestPlayerCallback>();
player->SetPlayerCallback(callback);// Set player callback.
std::string uri(filePath);// filePath is the local file path.
Source source(uri);//Save the URI to the source instance.
player->SetSource(source);//Set the source to the player.
player->SetVideoSurface(surface);//Set the playback window.
player->Prepare(); // Prepare for the playback.
player->Play(); //Starts playback.
Perform playback control based on the scenario.
player->SetVolume(lvolume, rvolume);//Set the left and right sound channels.
player->EnableSingleLooping(true);// Set cyclic playback.
player->Pause(); //Pause.
player->Play(); //Continue the playback.
Release resources after the playback task is complete.
player->Stop(); //Stop the playback.
player->Release(); // Release resources.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。