Player callback event processing method and device, computer device and storage medium

CN116136789BActive Publication Date: 2026-09-15TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111362647.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-17
Publication Date
2026-09-15
Estimated Expiration
2041-11-17

AI Technical Summary

Technical Problem

[0004]然而,传统方法中,业务方的处理过程同步进行,在所有业务方处理完成后,播放器才能够继续接下来的操作,而播放器对于业务方的处理过程无法控制,若业务方耗时较多,会影响播放器的处理流程,降低处理效率

Benefits of technology

[0031] The aforementioned player callback event handling method, apparatus, computer device, computer-readable storage medium, and computer program product, when detecting an event generated by the player, acquire the event identifier and event data of the event generated by the player; determine the associated business module based on the event identifier, and the business module has a corresponding pre-configured protocol function and callback function; call the protocol function corresponding to the business module to perform the corresponding event handling operation based on the event identifier and event data; within a preset time, call the callback function corresponding to the business module to send the execution result of the event handling operation back to the player. Accordingly, by calling the protocol function and callback function and controlling the execution time of the function through a preset time, the time for the business to handle player events can be controlled, improving the efficiency of callback event execution, thereby improving the player's processing efficiency, and also facilitating developers to control and manage the player's callback events.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116136789B_ABST
    Figure CN116136789B_ABST
Patent Text Reader

Abstract

The application relates to a player callback event processing method and device, computer equipment and a storage medium. The method comprises the following steps: when it is monitored that an event is generated by a player, the event identifier and event data of the event generated by the player are acquired; an associated business module is determined according to the event identifier, the business module having a corresponding pre-configured protocol function and callback function; the corresponding protocol function of the business module is called, and corresponding event processing operations are executed based on the event identifier and the event data; and within a preset time, the corresponding callback function of the business module is called, and the execution result of the event processing operation is returned to the player. The method can improve the callback event execution efficiency, thereby improving the player processing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, computer device, and storage medium for handling player callback events. Background Technology

[0002] When the player generates an event, the relevant business modules will take corresponding actions. For example, after playback is paused, the advertising module will request to download the pre-roll ad, the audio processing module will stop occupying the sound output port, the data stream module will pause data loading, and the pop-up module will display the corresponding prompts.

[0003] In traditional technologies, such as Figure 1 As shown, after the player generates an event, it transmits the event by sending a notification (or broadcasting). Each business module (such as business A, business B, and business C) listens for the player event and then performs corresponding processing (such as processing A, processing B, and processing C).

[0004] However, in the traditional method, the processing of business components is carried out synchronously. The player can only continue the next operation after all business components have completed their processing. The player has no control over the processing of business components. If the business components take a long time, it will affect the player's processing flow and reduce processing efficiency. Summary of the Invention

[0005] Therefore, it is necessary to provide a player callback event handling method, apparatus, computer device, and storage medium that can improve the player's processing efficiency in response to the above-mentioned technical problems.

[0006] A method for handling player callback events, the method comprising:

[0007] When an event is detected generated by the player, the event identifier and event data of the event generated by the player are obtained;

[0008] The associated business module is determined based on the event identifier, and the business module has a corresponding pre-configured protocol function and callback function;

[0009] The corresponding protocol function of the business module is invoked to perform the corresponding event processing operation based on the event identifier and the event data;

[0010] Within a preset time period, the callback function corresponding to the business module is invoked to send the execution result of the event handling operation back to the player.

[0011] A player callback event handling device, the device comprising:

[0012] The acquisition module is used to acquire the event identifier and event data of the event generated by the player when an event is detected.

[0013] The determination module is used to determine the associated business module based on the event identifier, wherein the business module has a corresponding pre-configured protocol function and callback function;

[0014] The first processing module is used to call the protocol function corresponding to the business module and perform corresponding event processing operations based on the event identifier and the event data.

[0015] The second processing module is used to call the callback function corresponding to the business module within a preset time to send the execution result of the event processing operation back to the player.

[0016] A computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program performing the following steps:

[0017] When an event is detected generated by the player, the event identifier and event data of the event generated by the player are obtained;

[0018] The associated business module is determined based on the event identifier, and the business module has a corresponding pre-configured protocol function and callback function;

[0019] The corresponding protocol function of the business module is invoked to perform the corresponding event processing operation based on the event identifier and the event data;

[0020] Within a preset time period, the callback function corresponding to the business module is invoked to send the execution result of the event handling operation back to the player.

[0021] A computer-readable storage medium having a computer program stored thereon, the computer program performing the following steps when executed by a processor:

[0022] When an event is detected generated by the player, the event identifier and event data of the event generated by the player are obtained;

[0023] The associated business module is determined based on the event identifier, and the business module has a corresponding pre-configured protocol function and callback function;

[0024] The corresponding protocol function of the business module is invoked to perform the corresponding event processing operation based on the event identifier and the event data;

[0025] Within a preset time period, the callback function corresponding to the business module is invoked to send the execution result of the event handling operation back to the player.

[0026] A computer program product includes a computer program that, when executed by a processor, performs the following steps:

[0027] When an event is detected generated by the player, the event identifier and event data of the event generated by the player are obtained;

[0028] The associated business module is determined based on the event identifier, and the business module has a corresponding pre-configured protocol function and callback function;

[0029] The corresponding protocol function of the business module is invoked to perform the corresponding event processing operation based on the event identifier and the event data;

[0030] Within a preset time period, the callback function corresponding to the business module is invoked to send the execution result of the event handling operation back to the player.

[0031] The aforementioned player callback event handling method, apparatus, computer device, computer-readable storage medium, and computer program product, when detecting an event generated by the player, acquire the event identifier and event data of the event generated by the player; determine the associated business module based on the event identifier, and the business module has a corresponding pre-configured protocol function and callback function; call the protocol function corresponding to the business module to perform the corresponding event handling operation based on the event identifier and event data; within a preset time, call the callback function corresponding to the business module to send the execution result of the event handling operation back to the player. Accordingly, by calling the protocol function and callback function and controlling the execution time of the function through a preset time, the time for the business to handle player events can be controlled, improving the efficiency of callback event execution, thereby improving the player's processing efficiency, and also facilitating developers to control and manage the player's callback events. Attached Figure Description

[0032] Figure 1 This is a schematic diagram illustrating the interaction between the player and the business module in traditional technology.

[0033] Figure 2 This is an application environment diagram of the player callback event handling method in one embodiment;

[0034] Figure 3 This is a flowchart illustrating the player callback event handling method in one embodiment;

[0035] Figure 4 This is a schematic diagram of the structural framework of the scheduler in one embodiment;

[0036] Figure 5 This is a schematic diagram of the display page of a multi-instance player in one embodiment;

[0037] Figure 6This is a flowchart illustrating the player callback event handling method in one embodiment;

[0038] Figure 7 This is a structural block diagram of a player callback event handling device in one embodiment;

[0039] Figure 8 This is an internal structural diagram of a computer device in one embodiment;

[0040] Figure 9 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0041] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0042] The player callback event handling method provided in this application can be applied to, for example... Figure 2 In the application environment shown, terminal 202 communicates with server 204 via a network. Users can access applications with media player functionality (such as video playback software) through terminal 202, and server 204 can be the server hosting that application. Terminal 202 includes, but is not limited to, mobile phones, computers, smart voice interaction devices, smart home appliances, and in-vehicle terminals. Server 204 can be a standalone server or a server cluster consisting of multiple servers.

[0043] In one embodiment, such as Figure 3 As shown, a method for handling player callback events is provided. This embodiment illustrates the application of this method to a terminal. It is understood that this method can also be applied to a server, and to a system including both a terminal and a server, and implemented through the interaction between the terminal and the server. In this embodiment, the method includes the following steps S302 to S308.

[0044] S302: When an event is detected by the player, the event identifier and event data of the event generated by the player are obtained.

[0045] Events generated by the player can include, but are not limited to, starting playback, pausing, downloading, resuming playback, dragging the progress bar, adjusting playback speed, and sharing. Each player event has a unique corresponding event identifier, which is used to distinguish different player events. In one embodiment, a number can be used as the event identifier (event ID), and the correspondence between event identifiers and player events is shown in Table 1 below:

[0046] Table 1

[0047]

[0048]

[0049] Event data refers to data related to player events, generated by the player kernel. For example, a pause event generated by the player can include information such as the time the pause occurred, the player state, the playback environment, and the CPU usage percentage.

[0050] S304: The associated business module is determined based on the event identifier. The business module has corresponding pre-configured protocol functions and callback functions.

[0051] Associated business modules refer to the business modules that will handle the events generated by the player. One event can correspond to one or more associated business modules. For example, if the player generates a pause event, its associated business modules may include advertising modules, audio processing modules, data streaming modules, playback history modules, and pop-up modules.

[0052] The protocol functions corresponding to the business modules are functions used to perform corresponding event handling operations. These event handling operations refer to the actions taken by the business module after detecting an event generated by the player. For example, the advertising module's actions after detecting a pause event include requesting the download of pre-roll ads; the audio processing module's actions include stopping the use of the audio output port; the data stream module's actions include loading paused data; the playback history module's actions include storing playback timestamps; and the pop-up module's actions include displaying a corresponding prompt.

[0053] The callback function corresponding to a business module is a function used to send the execution result of the event handling operation performed by the protocol function corresponding to that business module back to the player. The execution result includes the data that needs to be sent back, which can be agreed upon by the business module and the player. For example, after listening for a pause event, the protocol function corresponding to the playback record module stores the playback time point, and the data that needs to be sent back to the player includes that playback time point.

[0054] S306 calls the corresponding protocol function of the business module to perform the corresponding event handling operation based on the event identifier and event data.

[0055] Event identifiers are used to characterize the player events that have been monitored. Event data includes data related to the player event. Event identifiers and event data can be passed as parameters to the corresponding protocol function of the business module, so that the protocol function can perform the corresponding event handling operation when it is called.

[0056] For example, the event generated by the player is a pause event. Its associated business modules may include an advertising module, an audio processing module, a data stream module, a playback record module, and a pop-up module. When the protocol function corresponding to the advertising module is called, the event handling operations executed include requesting the download of the pre-roll ad. When the protocol function corresponding to the audio processing module is called, the event handling operations executed include stopping the occupation of the sound output port. When the protocol function corresponding to the data stream module is called, the event handling operations executed include loading the pause data. When the protocol function corresponding to the playback record module is called, the event handling operations executed include storing the playback time point. When the protocol function corresponding to the pop-up module is called, the event handling operations executed include displaying the corresponding prompt.

[0057] S308, within a preset time, calls the callback function corresponding to the business module and sends the execution result of the event handling operation back to the player.

[0058] The preset time refers to the maximum duration agreed upon by the business module and the caller for executing event handling operations. The callback function is used to send the execution result of the protocol function's event handling operation back to the player. The execution result includes the data to be sent back, which is agreed upon by the business module and the player. Specifically, the callback function can use an anonymous function as an attribute of the protocol function, adhering to the agreed-upon protocol. After the protocol function completes execution, the anonymous function sends the data back to the player.

[0059] Specifically, if the event handling operation is completed within the preset time, the corresponding callback function of the business module can be called to send the result back to the player. If the event handling operation is not completed, the corresponding callback function of the business module can be called when the preset time is reached to send the result back to the player. If the callback function needs to modify the data corresponding to the event identifier, the data can be copied for later use.

[0060] In the aforementioned player callback event handling method, when an event is detected in the player, the event identifier and event data of the event are obtained. Based on the event identifier, the associated business module is determined. Each business module has a corresponding pre-configured protocol function and callback function. The protocol function corresponding to the business module is called, and the corresponding event handling operation is performed based on the event identifier and event data. Within a preset time, the callback function corresponding to the business module is called, and the execution result of the event handling operation is sent back to the player. Therefore, by calling the protocol function and callback function and controlling the execution time of the function via a preset time, the time for the business side to handle player events can be controlled, improving the efficiency of callback event execution and thus improving the player's processing efficiency. Simultaneously, it facilitates developers in controlling and managing the player's callback events.

[0061] In one embodiment, the step of determining the associated business module based on the event identifier may specifically include the following steps: obtaining the object address corresponding to the event identifier from a global dictionary; the global dictionary stores the object addresses, callback functions, and protocol functions registered by each business module; obtaining the business module corresponding to the object address as the business module associated with the event identifier.

[0062] The mapping between each event identifier and the address of each object registered in the global dictionary can be pre-configured. One event identifier can correspond to one or more object addresses. After obtaining the event identifier, the object address corresponding to the event identifier can be obtained according to the mapping, and then the object can be obtained according to the object address, thereby determining the business module that needs to take corresponding actions for the event.

[0063] Specifically, a dispatcher is created within the player. The dispatcher controls the execution flow of tasks, reducing CPU and memory load. For example... Figure 4 The diagram illustrates the structural framework of a dispatcher in one embodiment. The dispatcher includes a player control center and a protocol layer. The player control center is used to control the creation of the player and the distribution of events.

[0064] The `playerControl` maintains a global dictionary. When a player is created on a client-side page, each business module (also called an observer object) registers its corresponding object address (key), anonymous function, and protocol method with the scheduler's global dictionary. The key can be a fixed address during program execution, allowing direct access to the object. Furthermore, the key can be a weak reference object, meaning the object can only be accessed but not held, thus not affecting its lifecycle. Anonymous functions are used to send data back to the player after the observer object has completed its event handling operations; anonymous functions can also be used as protocol attributes.

[0065] The protocol layer includes protocol methods, event IDs, and data. The event IDs and data are passed as parameters to the protocol methods. Anonymous functions in the protocol methods are bound to the scheduler through runtime mechanisms. The protocol methods are used to perform corresponding event handling operations.

[0066] When the player generates an event, the scheduler obtains the event ID and its data from the playerControl, iterates through the keys in the global dictionary to obtain the key corresponding to the event ID, obtains the observer object through the key corresponding to the event ID, executes the corresponding event handling operation through the protocol method of the observer object, and sends the data back to the player through the anonymous function corresponding to the observer object after the event handling operation is completed. After the iteration operation and the anonymous function are completed, the scheduler clears the player's events and releases the observer object in the playerControl.

[0067] In one embodiment, when the player is a multi-instance player, the global dictionary is copied to each player created on the current page.

[0068] A singleton means that a class can only have one instance, and that instance has only one access point on the user's side. Multiple instances mean that a class can have multiple instances. The player in this solution can be either a singleton or a multiple instance player. If it's a singleton player, only one player will be created on the current page in the client; if it's a multiple instance player, multiple players will be created on the current page in the client.

[0069] When an event is detected from the player, the player type can be first identified as either a singleton player or a non-instance player (i.e., a multi-instance player). Specifically, the player type can be identified based on the number of videos currently displayed on the client's page. If only one video is displayed, the player is determined to be a singleton player; if more than one video is displayed, the player is determined to be a non-singleton player.

[0070] When the player is a multi-instance player, the global dictionary in the scheduler's playerControl can be increased by 2 bits to store the addresses of multiple instance players. This global dictionary can then be copied to each player created on the current page. Figure 4 As shown by the dashed arrow, when any of the multiple players created on the current page generates an event, the observer object can be obtained by traversing the global dictionary. The corresponding event handling operation can be executed through the protocol method of the observer object, and the data can be returned to the player after the event handling operation is completed through the anonymous function of the observer object. This improves the efficiency of callback event execution and thus improves the player's processing efficiency.

[0071] In one embodiment, if the player is a multi-instance player, when a start-up event is detected by any player on the current page, other players on the current page are restricted from starting up simultaneously, and the data streams of other players are preloaded.

[0072] For most applications, only one player should be playing a video at a time. Playing two videos simultaneously within the application would cause audio overlap, which is not user-friendly. In such scenarios, developers would typically set the player to a singleton pattern. However, for some large applications, the scenario of multiple player instances is related to video feeds, where multiple players can be displayed on the same screen, such as... Figure 5 As shown, using a multi-instance player allows for preloading of the data stream, thereby improving playback speed.

[0073] If the player is not a singleton player, a potential problem is that two video players may be open simultaneously within the application, resulting in two playback sounds. Therefore, a playback control layer can be added to the playerControl to limit the simultaneous playback of multiple instance players, allowing only player creation and data stream preloading, thus achieving fault tolerance.

[0074] In one embodiment, the step of calling the protocol function corresponding to the business module and performing corresponding event handling operations based on the event identifier and event data may specifically include: creating a spinlock and inputting a semaphore into the spinlock; and through the thread that acquires the spinlock, calling the protocol function corresponding to the business module and performing corresponding event handling operations based on the event identifier and event data.

[0075] Spin locks are a type of lock introduced to prevent concurrency in multiprocessor systems. They are widely used in kernel components such as interrupt handling (for single-processor systems, preventing concurrency in interrupt handling can be easily achieved by disabling interrupts, i.e., turning the interrupt flag on / off in the flag register, without needing a spin lock). Specifically, when a thread attempts to acquire a lock, if the lock is already held by another thread, the first thread cannot acquire it and will wait. After a certain interval, it will attempt to acquire the lock again. This mechanism of circular locking and waiting for the lock to be released is called a spin lock. Using spin locks can protect the playback state attributes, preventing event data from being modified by multiple threads while executing protocol functions, thus ensuring data security.

[0076] A semaphore is a synchronization object used to maintain a counter between 0 and a specified maximum value. When a thread completes a wait on the semaphore, the counter is decremented by one; when a thread completes a release, the counter is incremented by one. When the counter reaches 0, threads will no longer be able to wait successfully on the semaphore until it becomes a signaled object. A semaphore with a counter greater than 0 is in a signaled state; a counter equal to 0 is in a non-signaled state. Semaphores are caller-dependent and used to control the execution order of tasks within threads, ensuring that the next operation can proceed as quickly as possible.

[0077] In one embodiment, after calling the protocol function corresponding to the business module, the following steps are also included: starting a countdown from the start of the event handling operation, with the countdown duration being a preset time.

[0078] The preset time refers to the maximum duration agreed upon by the business module and the caller for executing event handling operations. If the execution time of event handling operations by the business module is too long, it will affect the performance of the player. Therefore, the business module can agree on a duration with the player as the maximum duration for executing event handling operations. Specifically, a timer can be created to start a countdown when the business module begins executing the event handling operation; the countdown length is the agreed duration. It should be noted that different business modules can hold the same or different agreed durations; this is not restricted.

[0079] In one embodiment, if the event handling operation is completed before the countdown ends, a new semaphore is sent to the spinlock. Completing the event handling operation before the countdown ends indicates that the business module has finished executing within the agreed time period. At this point, a new semaphore is sent to the spinlock, releasing the spinlock for the next operation.

[0080] In one embodiment, if the event handling operation is not completed before the countdown ends, a semaphore is automatically emitted from the spinlock to stop the call to the protocol function. If the event handling operation is still not completed before the countdown ends, it means that the business module has not completed execution within the agreed time. At this time, a semaphore is automatically emitted from the spinlock to stop the call to the protocol function corresponding to the business module, preventing excessive time consumption from affecting the player's processing efficiency.

[0081] In one embodiment, the method further includes: copying the event data, wherein the copied event data is applied to the protocol function corresponding to a subsequent business module that has a logical sequential relationship with the business module.

[0082] Subsequent business modules have a logical order relationship, which can be understood as the sequential use of data between them. Specifically, one business module might use certain data first, and a subsequent business module might use that data later. For example, when a player generates a stop playback event, observer A is the playback recording module, and observer B is the start playback module. Observer A uses the singleton player's stop playback data and needs to pass the stored or updated data of the video's playback time point to observer B so that the user can resume playback later. At this time, the event identifier and event data of the stop playback event are copied in the protocol method of observer A and then passed to the protocol method of observer B, so that when a playback event is detected later, playback can be resumed from the playback time point corresponding to the stop playback event.

[0083] In one embodiment, such as Figure 6 As shown, a method for handling player callback events is provided, including the following steps:

[0084] S601: When an event is detected by the player, the event identifier and event data of the event generated by the player are obtained.

[0085] S602: Obtain the object address corresponding to the event identifier from the global dictionary based on the event identifier, and obtain the business module corresponding to the object address based on the object address. As the business module associated with the event identifier, the business module has corresponding pre-configured protocol functions and callback functions.

[0086] S603 calls the corresponding protocol function of the business module, performs the corresponding event handling operation based on the event identifier and event data, controls the execution thread through spinlock and controls the execution order through semaphore during the execution process.

[0087] S604, starts a countdown from the beginning of the event handling operation, and the countdown time is a preset time.

[0088] S605: If the event handling operation is completed before the countdown ends, the corresponding callback function of the business module is called to send the execution result of the event handling operation back to the player.

[0089] S606: If the event handling operation is not completed before the countdown ends, stop calling the protocol function.

[0090] The specific descriptions of steps S601 to S606 above can be found in the preceding embodiments and will not be repeated here. In this embodiment, by calling protocol functions and anonymous functions and controlling the execution time of preset time control functions, the time for business parties to process player events can be controlled, thereby improving the efficiency of callback event execution and thus improving the player's processing efficiency. This also facilitates developers in controlling and managing the player's callback events. During the transmission of data generated by the player, spinlocks protect the data from tampering, ensuring data security. Combining this with semaphores helps control the method call and execution process, increasing processing flexibility and scalability.

[0091] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps.

[0092] In one embodiment, such as Figure 7 As shown, a player callback event handling device 700 is provided. This device can be a software module, a hardware module, or a combination of both as part of a computer device. Specifically, the device includes: an acquisition module 710, a determination module 720, a first processing module 730, and a second processing module 740, wherein:

[0093] The acquisition module 710 is used to acquire the event identifier and event data of the event generated by the player when an event is detected.

[0094] The determination module 720 is used to determine the associated business module based on the event identifier. The business module has corresponding pre-configured protocol functions and callback functions.

[0095] The first processing module 730 is used to call the protocol function corresponding to the business module and perform corresponding event processing operations based on the event identifier and event data.

[0096] The second processing module 740 is used to call the callback function corresponding to the business module within a preset time to send the execution result of the event processing operation back to the player.

[0097] In one embodiment, when the first processing module 730 determines the associated business module based on the event identifier, it is specifically used to: obtain the object address corresponding to the event identifier from the global dictionary based on the event identifier; the global dictionary stores the object addresses, callback functions, and protocol functions registered by each business module; obtain the business module corresponding to the object address based on the object address, and use it as the business module associated with the event identifier.

[0098] In one embodiment, when the second processing module 740 calls the protocol function corresponding to the business module to perform the corresponding event processing operation based on the event identifier and event data, it is specifically used to: create a spinlock and input a semaphore into the spinlock; and through the thread that acquires the spinlock, call the protocol function corresponding to the business module to perform the corresponding event processing operation based on the event identifier and event data.

[0099] In one embodiment, the second processing module 740 is further configured to: start a countdown from the beginning of the event processing operation, the countdown time being a preset time.

[0100] In one embodiment, the second processing module 740 is further configured to: send a new semaphore to the spinlock if the execution of the event processing operation is completed before the countdown ends.

[0101] In one embodiment, the second processing module 740 is further configured to: if the event processing operation is not completed before the countdown ends, automatically send a semaphore from the spinlock to stop the call to the protocol function.

[0102] In one embodiment, the first processing module 730 is further configured to: when the player is a multi-instance player, copy the global dictionary to each player created on the current page.

[0103] In one embodiment, the first processing module 730 is further configured to: if the player is a multi-instance player, when a start-up event is detected by any player on the current page, restrict other players on the current page from starting up simultaneously and preload the data streams of other players.

[0104] In one embodiment, the first processing module 730 is further configured to: copy the event data, and apply the copied event data to the protocol function corresponding to a subsequent business module that has a logical sequential relationship with the business module.

[0105] For specific limitations regarding the player callback event handling mechanism, please refer to the limitations on the player callback event handling method described above, which will not be repeated here. Each module in the aforementioned player callback event handling mechanism can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in the computer device in hardware form, or stored in the memory of the computer device in software form, so that the processor can call and execute the corresponding operations of each module.

[0106] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 8 As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with external terminals via a network connection. When the computer program is executed by the processor, it implements a player callback event handling method.

[0107] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 9 As shown, the computer device includes a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, carrier networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a player callback event handling method. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the computer device casing, or an external keyboard, touchpad, or mouse.

[0108] Those skilled in the art will understand that Figure 8 or Figure 9The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0109] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.

[0110] In one embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0111] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, causing the computer device to perform the steps in the above-described method embodiments.

[0112] It should be understood that the terms "first," "second," etc., used in the above embodiments are for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Furthermore, in the description of this application, unless otherwise stated, "a plurality of" means at least two.

[0113] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.

[0114] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0115] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. A method for handling player callback events, characterized in that, The method includes: When an event is detected generated by the player, the event identifier and event data of the event generated by the player are obtained; The associated business module is determined based on the event identifier, and the business module has a corresponding pre-configured protocol function and callback function; The corresponding protocol function of the business module is invoked to perform the corresponding event processing operation based on the event identifier and the event data; A countdown begins when the event handling operation is started, and the countdown duration is a preset time. If the event handling operation is completed before the countdown ends, the callback function corresponding to the business module will be called when the event handling operation is completed, and the execution result of the event handling operation will be sent back to the player. If the event handling operation is not completed, the callback function corresponding to the business module will be called when the preset time is reached, and the execution result of the event handling operation will be sent back to the player.

2. The method according to claim 1, characterized in that, The step of determining the associated business module based on the event identifier includes: The object address corresponding to the event identifier is obtained from the global dictionary based on the event identifier; the global dictionary stores the object addresses, callback functions, and protocol functions registered by each business module; The business module corresponding to the object address is obtained based on the object address, and is used as the business module associated with the event identifier.

3. The method according to claim 1, characterized in that, The step of invoking the protocol function corresponding to the business module and performing corresponding event processing operations based on the event identifier and the event data includes: Create a spinlock and input a semaphore into the spinlock; By acquiring the spinlock, the thread calls the protocol function corresponding to the business module to perform the corresponding event processing operation based on the event identifier and the event data.

4. The method according to claim 3, characterized in that, It also includes either of the following two: If the event handling operation is completed before the countdown ends, a new semaphore is sent to the spinlock; If the event handling operation is not completed before the countdown ends, a semaphore is automatically emitted from the spinlock to stop the call to the protocol function.

5. The method according to claim 2, characterized in that, Also includes: When the player is a multi-instance player, it also includes at least one of the following two: Copy the global dictionary to each player created on the current page; When a playback event is detected from any player on the current page, other players on the current page are restricted from playing simultaneously, and the data streams of the other players are preloaded.

6. The method according to any one of claims 1 to 5, characterized in that, Also includes: The event data is copied, and the copied event data is applied to the protocol functions of subsequent business modules that have a logical sequence relationship with the business module.

7. A player callback event handling device, characterized in that, The device includes: The acquisition module is used to acquire the event identifier and event data of the event generated by the player when an event is detected. The determination module is used to determine the associated business module based on the event identifier, wherein the business module has a corresponding pre-configured protocol function and callback function; The first processing module is used to call the protocol function corresponding to the business module and perform corresponding event processing operations based on the event identifier and the event data. The second processing module is used to start a countdown from the beginning of the event processing operation, and the countdown time is a preset time. If the event processing operation is completed before the countdown ends, the callback function corresponding to the business module is called when the event processing operation is completed, and the execution result of the event processing operation is sent back to the player. If the event processing operation is not completed, the callback function corresponding to the business module is called when the preset time is reached, and the execution result of the event processing operation is sent back to the player.

8. The apparatus according to claim 7, characterized in that, The determining module is further configured to: obtain the object address corresponding to the event identifier from the global dictionary based on the event identifier; the global dictionary stores the object addresses, callback functions, and protocol functions registered by each business module; obtain the business module corresponding to the object address based on the object address, and use it as the business module associated with the event identifier.

9. The apparatus according to claim 7, characterized in that, The first processing module is further configured to: create a spinlock, input a semaphore into the spinlock; and, through the thread that acquires the spinlock, call the protocol function corresponding to the business module to perform corresponding event processing operations based on the event identifier and the event data.

10. The apparatus according to claim 9, characterized in that, The second processing module is further configured to: if the execution of the event processing operation is completed before the countdown ends, send a new semaphore to the spinlock; if the execution of the event processing operation is not completed before the countdown ends, automatically send a semaphore from the spinlock to stop the call to the protocol function.

11. The apparatus according to claim 8, characterized in that, When the player is a multi-instance player, the first processing module is further configured to perform at least one of the following two operations: copy the global dictionary to each player created on the current page; when a start-up event is detected by any player on the current page, restrict other players on the current page from starting up simultaneously and preload the data streams of the other players.

12. The apparatus according to any one of claims 7 to 11, characterized in that, The first processing module is further configured to: copy the event data, and apply the copied event data to the protocol function corresponding to a subsequent business module that has a logical order relationship with the business module.

13. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.

14. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

15. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Monitoring method and device for video player

    CN110944231A

  • Interface calling method and device for calling module, computer equipment and storage medium

    CN113296987A