@@ -87,14 +87,6 @@ int64_t PlusPlayer::Create(const std::string &uri,
8787 create_message_ = create_message;
8888 LOG_INFO (" [PlusPlayer] Uri: %s" , uri.c_str ());
8989
90- if (create_message.streaming_property () != nullptr &&
91- !create_message.streaming_property ()->empty ()) {
92- for (const auto &[key, value] : *create_message.streaming_property ()) {
93- SetStreamingProperty (std::get<std::string>(key),
94- std::get<std::string>(value));
95- }
96- }
97-
9890 if (!SetAppId ()) {
9991 LOG_ERROR (" [PlusPlayer] Fail to set app id" );
10092 return -1 ;
@@ -119,22 +111,7 @@ int64_t PlusPlayer::Create(const std::string &uri,
119111
120112 SetDisplayRoi (0 , 0 , 1 , 1 );
121113
122- bool is_prebuffer_mode = flutter_common::GetValue (
123- create_message.player_options (), " prebufferMode" , false );
124- if (is_prebuffer_mode) {
125- plusplayer_set_prebuffer_mode (player_, true );
126- is_prebuffer_mode_ = true ;
127- }
128-
129- int64_t start_position = flutter_common::GetValue (
130- create_message.player_options (), " startPosition" , (int64_t )0 );
131- if (start_position > 0 ) {
132- LOG_INFO (" [PlusPlayer] Start position: %lld" , start_position);
133- if (plusplayer_seek (player_, start_position) !=
134- PLUSPLAYER_ERROR_TYPE_NONE) {
135- LOG_INFO (" [PlusPlayer] Fail to seek, it's a non-seekable content" );
136- }
137- }
114+ PreSet (create_message);
138115
139116 if (plusplayer_prepare_async (player_) != PLUSPLAYER_ERROR_TYPE_NONE) {
140117 LOG_ERROR (" [PlusPlayer] Player fail to prepare." );
@@ -148,6 +125,53 @@ void PlusPlayer::Dispose() {
148125 ClearUpEventChannel ();
149126}
150127
128+ void PlusPlayer::PreSet (const CreateMessage &create_message) {
129+ if (create_message.streaming_property () != nullptr &&
130+ !create_message.streaming_property ()->empty ()) {
131+ for (const auto &[key, value] : *create_message.streaming_property ()) {
132+ SetStreamingProperty (std::get<std::string>(key),
133+ std::get<std::string>(value));
134+ }
135+
136+ std::string user_agent = flutter_common::GetValue (
137+ create_message.streaming_property (), " USER_AGENT" , std::string ());
138+ if (!user_agent.empty ()) {
139+ int ret = plusplayer_set_user_agent (player_, user_agent.c_str ());
140+ if (ret != PLUSPLAYER_ERROR_TYPE_NONE) {
141+ LOG_ERROR (" [PlusPlayer] plusplayer_set_user_agent failed: %s." ,
142+ user_agent.c_str ());
143+ }
144+ }
145+
146+ std::string cookie = flutter_common::GetValue (
147+ create_message.streaming_property (), " COOKIE" , std::string ());
148+ if (!cookie.empty ()) {
149+ int ret = plusplayer_set_cookie (player_, cookie.c_str ());
150+ if (ret != PLUSPLAYER_ERROR_TYPE_NONE) {
151+ LOG_ERROR (" [PlusPlayer] plusplayer_set_cookie failed: %s." ,
152+ cookie.c_str ());
153+ }
154+ }
155+
156+ bool is_prebuffer_mode = flutter_common::GetValue (
157+ create_message.player_options (), " prebufferMode" , false );
158+ if (is_prebuffer_mode) {
159+ plusplayer_set_prebuffer_mode (player_, true );
160+ is_prebuffer_mode_ = true ;
161+ }
162+
163+ int64_t start_position = flutter_common::GetValue (
164+ create_message.player_options (), " startPosition" , (int64_t )0 );
165+ if (start_position > 0 ) {
166+ LOG_INFO (" [PlusPlayer] Start position: %lld" , start_position);
167+ if (plusplayer_seek (player_, start_position) !=
168+ PLUSPLAYER_ERROR_TYPE_NONE) {
169+ LOG_INFO (" [PlusPlayer] Fail to seek, it's a non-seekable content" );
170+ }
171+ }
172+ }
173+ }
174+
151175void PlusPlayer::SetDisplayRoi (int32_t x, int32_t y, int32_t width,
152176 int32_t height) {
153177 plusplayer_geometry_s roi;
0 commit comments