简体   繁体   English

Objective-C:将float转换为int64_t而不会造成精度损失

[英]Objective-C: Convert float to int64_t without precision loss

THE SCENARIO I am working on an application that uses RTPlayer to play prerecorded Video and Audio from our server. 场景我正在开发一个使用RTPlayer播放来自我们服务器的预录制视频和音频的应用程序。

THE SUSPECTS RTPlayer has 2 useful properties; 疑似 RTPlayer具有2个有用的属性。 .initialPlaybackTime and .currentPosition for calculating media time position in seconds. .initialPlaybackTime.currentPosition用于计算媒体时间位置(以秒为单位)。 .initialPlaybackTime sets where in the media the player should start playing from, and .currentPosition tells you where you left off to resume at the same position in the media. .initialPlaybackTime设置播放器应在媒体中开始播放的位置, .currentPosition告诉您从何处退出可以在媒体中的同一位置继续播放。

THE ISSUE The .initialPlaybackTime property is of int64_t type, and .currentPosition is of type float . 问题 .initialPlaybackTime属性为int64_t类型,而.currentPosition类型为float When I "plug" the .currentPosition value into .initialPlaybackTime there is always about 8-10 seconds ADDED to the player's position. 当我“外挂”的.currentPosition值到.initialPlaybackTime始终存在约8-10秒玩家的位置。

QUESTION How can I convert the .currentPosition float value to a int64_t and keep the same value? 问题如何将.currentPosition float值转换为int64_t并保持相同的值?

The "8-10 seconds being added to the player's position" may have something to do with the underlying HTTP Live Streaming (HLS) technology . “将8-10秒添加到玩家的位置中”可能与基础HTTP Live Streaming(HLS)技术有关

If the media you are playing is streamed it is likely that it conforms to this technology and, if so, will be split into several smaller chunks of media (my experience is this is usually about 15 seconds in length for video) at a variety of bitrates. 如果您正在播放的媒体是流媒体,则很可能符合该技术,并且,如果这样,它将被分割成几个较小的媒体块(我的经验是,视频的长度通常约为15秒)。比特率。

In that case, unless the initialPlaybackTime is set to a value that coincides with the start time of one of those media segments, it is possible the player is just using the nearest media segment and jumping to the beginning of that segment (a common practice) or to the next segment if it is near the end of the current segment to reduce loading a full segment's worth of media data without playing it. 在那种情况下,除非将initialPlaybackTime设置为与这些媒体片段之一的开始时间一致的值,否则播放器可能只是在使用最近的媒体片段并跳到该片段的开头(通常做法)如果它接近当前片段的末尾,则返回到下一个片段,以减少在不播放的情况下加载完整片段的媒体数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM