A kind of video screen spinning solution and deviceTechnical field
The invention belongs to communication technical field, more particularly to a kind of video screen spinning solution and device.
Background technology
With flourishing for mobile Internet industry, increasing user replaces computer with mobile phone, wherein very big by oneGroups of people like seeing video with mobile phone, seen a film.But it is due to the limitation of mobile terminal, video can not be seen as computerSee, so by serial of methods, allowing user to have more preferable experience, just become the problem of developer.
Although the app of some present main flows has the function of played in full screen, but is all based on the vertical setting of types direction-locking of systemFunction, and sometimes user only want to watch the app when can be by screen transverse screen played in full screen, when mobile phone falls back on backstageWhen, other application is not influenceed, this is unable to handle, because this function is system level, thus have impact on itHe is app.There are following two defects in it:
1st, only set, screen transverse screen could be played, it is impossible to accurately know the current screen court of mobile phone by systemTo automatic Rotation screen;
2nd, in said system application, if exiting current video playback, the setting that screen transverse screen is played also exists, ifInto other app, it is not necessary to which screen transverse screen is played, it is necessary to which change system is set again, and progress vertical setting of types direction-locking causes userOperational inconvenience.
The content of the invention
In order to solve the above mentioned problem of prior art presence, the invention provides a kind of video screen spinning solution and dressPut, there was only the technical problem that ability rotating mobile screen is set by system to solve mobile terminal in the prior art.
The technical solution adopted in the present invention is:A kind of video screen spinning solution is provided, including:Current video is obtained to broadcastScreen three-dimensional data when putting;Screen three-dimensional data when being played according to the current video, calculates and obtains current screen direction;According to the current screen towards Rotation screen.
Preferably, the screen three-dimensional data during acquisition current video broadcasting is:Obtained using 3-axis acceleration sensorAcceleration of the screen on three-dimensional when taking the current video to play.
Preferably, the screen three-dimensional data obtained when current video is played, to call the mobile terminal systemScreen three-dimensional data.
Preferably, screen three-dimensional data when being played according to the current video, calculates and obtains current screen direction,Including:Give tacit consent to the current screen and be oriented portrait layout upward, three-dimensional data is respectively x, y, z;When z absolute value is less than critical valueWhen, start to calculate, and make the following judgment:If y absolute value is more than x absolute value, it is perpendicular in z directions to judge current screen, if now y values are more than 0, represent that current screen is directed downward, y values are less than 0, represent current screen direction upward;IfY absolute value is less than x absolute value, judges that current screen, towards being horizontal, if now x values are more than 0, represents current in zScreen orientation is less than 0 towards a left side, x values, represents current screen direction towards the right side.
Preferably, it is described to be towards Rotation screen according to the current screen:Call the screen of the mobile terminal systemControl interface, according to the current screen towards Rotation screen.
The present invention also provides a kind of video screen rotating device, applied to mobile terminal, including:On-screen data obtains singleMember, for obtaining screen three-dimensional data when current video is played;Screen is towards computing unit, for according to the current videoScreen three-dimensional data during broadcasting, calculates and obtains current screen direction;Screen rotation unit, for according to the current screen courtTo Rotation screen.
Preferably, the on-screen data acquiring unit is:When obtaining current video broadcasting using 3-axis acceleration sensorAcceleration of the screen on three-dimensional.
Preferably, the 3-axis acceleration sensor is gyroscope.
Preferably, the screen is towards computing unit, including:Initialization module, for setting the current screen directionAcquiescence is oriented portrait layout upward, and three-dimensional data is respectively x, y, z;Screen is towards computing unit, for facing when z absolute value is less thanDuring dividing value, start to calculate, and make the following judgment:If y absolute value is more than x absolute value, judge current screen in z directionsIt is endways, if now y values are more than 0, represent that current screen is directed downward, y values are less than 0, represent current screen direction upward;If y absolute value is less than x absolute value, judge that current screen, towards being horizontal, if now x values are more than 0, is represented in zCurrent screen direction is less than 0 towards a left side, x values, represents current screen direction towards the right side.
Preferably, the screen rotation unit, including:Calling module, the screen for connecting the mobile terminal systemControl interface;Rotary module, for by calling module, Rotation screen to be carried out according to current screen direction.
Therefore, using technical solution of the present invention, screen three-dimensional data during due to being played by obtaining current videoCurrent screen direction is obtained to calculate, the current screen direction of mobile phone can be accurately known;Rotated according to current screen directionScreen, it is not necessary to set by system, can equally obtain the effect of transverse screen broadcasting, and when exiting video playback, also notNeed to change system setting again, the technique effect of automatic Rotation screen can be reached.Therefore, screen when current video is played is obtainedCurtain three-dimensional data;Screen three-dimensional data when being played according to current video, calculates and obtains current screen direction;According to current screenTowards Rotation screen, the demand for experience of user is more adapted to, more hommization meets practical application.
Brief description of the drawings
Fig. 1 shows the flow chart of video screen spinning solution according to an embodiment of the invention;
Fig. 2 shows the structure chart of video screen rotating device according to an embodiment of the invention.
Embodiment
The present invention provides a kind of method and apparatus, and hand could be rotated to solve of the prior art only set by systemThe technical problem of machine screen.
Technical scheme in the embodiment of the present application is solves above-mentioned technical problem, and general thought is as follows:Not by beingIn the case of level operations of uniting, mobile phone direction, and automatic rotating mobile screen are calculated according to gyroscope.
In order to be better understood from above-mentioned technical proposal, below by accompanying drawing and specific embodiment to technical solution of the present inventionIt is described in detail, it should be understood that the specific features in the embodiment of the present invention and embodiment are to the detailed of technical solution of the present inventionThin explanation, rather than the restriction to technical solution of the present invention, in the case where not conflicting, the embodiment of the present invention and embodimentIn technical characteristic can be mutually combined.
Embodiment 1
As shown in figure 1, the present embodiment provides a kind of method video screen spinning solution, applied to mobile phone, including following stepSuddenly:
Screen three-dimensional data when S1, acquisition current video broadcasting;
S2, screen three-dimensional data when being played according to the current video, calculate and obtain current screen direction;
S3, according to the current screen towards Rotation screen.
Being only wanted in view of user can be by screen transverse screen played in full screen when app videos are watched, therefore the present embodimentScreen three-dimensional data is only just obtained in video playback;Acquisition current screen direction is calculated according to screen three-dimensional data, can be withAccurately know the current screen direction of mobile phone;According to current screen towards Rotation screen, it is not necessary to set by system, equallyThe effect of transverse screen broadcasting can be obtained, and when exiting video playback, it is not required that system setting is changed again, can be reached certainlyThe technique effect of dynamic Rotation screen.
As a kind of preferred scheme of above-described embodiment, step S1 can be obtained using 3-axis acceleration sensor works as forward sightAcceleration of the screen on three-dimensional when frequency is played.3-axis acceleration sensor is such as gyroscope.
As another preferred scheme of above-described embodiment, step S1 can be the dimension of screen three of calling mobile phone systemAccording to.
Found in further investigation of the present inventor in the research present invention, some that can be carried by calling mobile phone systemMethod persistently obtains the data of gyroscope.For example, iPhone system carries gyroscope, three dimensions of mobile phone can be knownAccording to, that is to say, that we can be according to the x in its coordinate system, y, tri- values of z, to judge the direction of equipment.
The main function of gyroscope, is to be based on conservation of angular momentum principle, along some specific reference axis measurement rotation speedRate.In use, the rotor of gyroscope points to a fixed direction, when the motion of moving object all the time when telling rotationWhen predetermined direction is deviateed in direction, gyroscope can just be felt out.
That is, we can by force be drawn by a global variable by Video Controller to screen three-dimensional dataWith, it is possible to ensure that the data of gyroscope can be continuously obtained during app is run.So it is also an advantage that, allows videoController strongly reference he, when we exit video playback interface, Video Controller can be destroyed, then his institute's strongly referenceAll objects can all destroy, can so save many memory headrooms, allow app more lightweights, processing speed is faster.
Preferably, screen three-dimensional data when being played according to the current video, calculates and obtains current screen direction,Including:When entering new app video playbacks every time, give tacit consent to the current screen and be oriented portrait layout upward, three-dimensional data is respectivelyx、y、z;Three-dimensional data is persistently obtained, when z absolute value is less than critical value, starts to calculate, and make the following judgment:If yAbsolute value be more than x absolute value, judge that current screen towards being endways, if now y values are more than 0, represents currently to shield in zCurtain is directed downward, and y values are less than 0, represents current screen direction upward;If y absolute value is less than x absolute value, judge currentScreen, towards being horizontal, if now x values are more than 0, represent current screen direction towards a left side, x values are less than 0, represents current screen in zCurtain direction is towards the right side.
Specific algorithm is as follows:
A. the value of an enumeration type is defined:Value, carrys out recording equipment direction, the value acquiescence be portrait layout upward;
B. start to calculate (0.5 is critical value, represents equipment and starts rotation) when z absolute value is less than 0.5
C. judge, if y absolute value is more than x absolute value, then it is endways to prove equipment, now only needs to compareIf whether y values are more than 0. y values and are more than 0, device orientation is represented down, y values are less than 0, represent device orientation upward;
If d. y absolute value is less than x absolute value, then it is horizontal to prove equipment, now needs whether to compare x valuesIf being more than 0 more than 0. x values, device orientation is represented towards a left side, x values are less than 0, represent device orientation towards the right side.
Preferably, it is towards Rotation screen according to current screen:Call the screen control interface of the mobile terminal system, rootAccording to the current screen towards Rotation screen.Found by the further investigation of the present inventor, carry gyroscope for cell phone system, obtainKnow that cell phone apparatus after, can pass through [[UIDevicecurrentDevice] setValue:valueforKey:@"Orientation "] method carrys out Rotation screen.
It is emphasized that above method step is not necessarily performed according to number order, why it is intended merely to numberingThe convenience of statement, as long as the purpose of the present invention can be realized, changing in any step should all be protected in the claim of the present inventionIn the range of.
Embodiment 2
As shown in Fig. 2 the present embodiment provides a kind of video screen rotating device of the application above method, applied to mobile wholeEnd, including:On-screen data acquiring unit 10, for obtaining screen three-dimensional data when current video is played;Screen direction is calculatedUnit 20, screen three-dimensional data during for being played according to the current video calculates and obtains current screen direction;Screen rotationUnit 30, for according to the current screen towards Rotation screen.
Preferably, on-screen data acquiring unit 10 is:Obtained using 3-axis acceleration sensor when current video is playedAcceleration of the screen on three-dimensional.
Preferably, 3-axis acceleration sensor is gyroscope.
Preferably, screen is towards computing unit 20, including:Initialization module, for setting the current screen direction silentRecognize and be oriented portrait layout upward, three-dimensional data is respectively x, y, z;Screen is towards computing unit, for the absolute value as z less than criticalDuring value, start to calculate, and make the following judgment:If y absolute value is more than x absolute value, judge that current screen is in z directionsEndways, if now y values are more than 0, represent that current screen is directed downward, y values are less than 0, represent current screen direction upward;Such asFruit y absolute value is less than x absolute value, judges that current screen, towards being horizontal, if now x values are more than 0, represents to work as in zForth screen direction is less than 0 towards a left side, x values, represents current screen direction towards the right side.
Preferably, screen rotation unit 30, including:Calling module, the screen control for connecting the mobile terminal systemInterface processed;Rotary module, for by calling module, Rotation screen to be carried out according to current screen direction.
Its concrete operating principle specifically can be, but not limited to referring to the corresponding description in embodiment 1.
As seen from the above-described embodiment, the beneficial effect comprise that:During due to being played by obtaining current videoScreen three-dimensional data obtains current screen direction to calculate, and can accurately know the current screen direction of mobile phone;According to currentScreen is towards Rotation screen, it is not necessary to set by system, can equally obtain the effect of transverse screen broadcasting, and is exiting videoDuring broadcasting, it is not required that change system setting again, the technique effect of automatic Rotation screen can be reached.Therefore, obtain and work as forward sightScreen three-dimensional data when frequency is played;Screen three-dimensional data when being played according to current video, calculates and obtains current screen direction;According to current screen towards Rotation screen, the demand for experience of user is more adapted to, more hommization meets practical application.
, but those skilled in the art once know basic creation although preferred embodiments of the present invention have been describedProperty concept, then can make other change and modification to these embodiments.So, appended claims are intended to be construed to include excellentSelect embodiment and fall into having altered and changing for the scope of the invention.
Obviously, those skilled in the art can carry out the essence of various changes and modification without departing from the present invention to the present inventionGod and scope.So, if these modifications and variations of the present invention belong to the scope of the claims in the present invention and its equivalent technologiesWithin, then the present invention is also intended to comprising including these changes and modification.