How to control audio in embedded HTML5 pages in iOS

By initializing the audio controller and dictionary on the iOS side, and calling the audio controller on the iOS side on the HTML5 side, the limitations of the iOS system on the audio control of HTML5 pages are solved, and the precise control of audio and multiple audio simultaneous playback is achieved, improving the user experience.

CN114942744BActive Publication Date: 2025-04-294399 NETWORK
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210633848.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-06
Publication Date
2025-04-29
Estimated Expiration
2042-06-06

AI Technical Summary

Technical Problem

The iOS system has restrictions on the audio control in embedded HTML5 pages, which leads to problems such as inability to play audio, difficulty in adjusting volume, not supporting multiple audio simultaneous playback, and inability to continue playing after interruption by the outside world, affecting the user experience.

Method used

By initializing the audio controller, the loaded audio object dictionary and the playing audio object dictionary on the iOS side, the HTML5 side calls the iOS side audio controller to realize the loading, playback, pause, volume adjustment, loop playback and other controls on the audio objects in the HTML5 page.

Benefits of technology

It realizes precise control of HTML5 page audio, ensuring that the audio can be played on different devices, supports simultaneous playback of multiple audio and volume adjustment, timely pause and resume audio playback, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114942744B_ABST
    Figure CN114942744B_ABST
Patent Text Reader

Abstract

The present invention provides a method for controlling audio embedded in an HTML5 page by iOS, comprising: the iOS end initializes and generates an audio controller, a dictionary of loaded audio objects, and a dictionary of playing audio objects; the HTML5 end calls the audio controller of the iOS end to control the audio objects in the HTML5 page. The method has the following advantages: (1) By placing the audio object control on the iOS end, the playback of each audio object can be accurately controlled to ensure that each audio object is played according to the control of the program. (2) When the audio object is interrupted by a phone call or other application audio, it automatically pauses, and after returning to the application, the audio object can continue to be played. (3) Multiple audio objects can be played simultaneously or cross-played, and the volume can be adjusted at will to achieve special effects such as fading and fading of sound effects. The audio playback effect can be made consistent with the effect required by the design, thereby improving the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of iOS audio control, and in particular relates to a method for iOS to control audio embedded in an HTML5 page. Background Art

[0002] During the iOS development process, some H5 pages are often embedded to display richer and more vivid games, activities or information. On these H5 pages, some audio effects are also added to enrich the page's presentation and attract users.

[0003] Regarding the audio control method, if it is controlled by H5, there will be some shortcomings in the experience. This is because the iOS system itself has many restrictions on the playback of H5 audio. For example: due to system version reasons, some models do not currently support the features of H5 audio, resulting in the inability to play audio. The audio cannot be muted through program code, and the volume of the audio cannot be adjusted. It can only be adjusted uniformly through the physical buttons of the mobile phone. On the same page, multiple audios may not be played at the same time. The audio is not stopped in time and is still playing after closing the application and returning to the background. The audio cannot continue to play after being interrupted by an external phone call or the audio of other applications. This seriously affects the user experience and may cause users to abandon the application. Therefore, in iOS applications, how to control the audio of H5 is very important. Summary of the invention

[0004] In view of the defects of the prior art, the present invention provides a method for controlling the audio embedded in an HTML5 page by iOS, which can effectively solve the above problems.

[0005] The technical solution adopted by the present invention is as follows:

[0006] The present invention provides a method for controlling audio embedded in an HTML5 page using iOS, comprising the following steps:

[0007] Step 1: After the iOS client embeds the HTML5 page into the browser, it initializes and generates the audio controller, the loaded audio object dictionary, and the playing audio object dictionary;

[0008] in:

[0009] The loaded audio object dictionary is used to store the loaded audio objects;

[0010] The currently playing audio object dictionary is used to store the currently playing audio object;

[0011] The audio controller is used to control the audio object according to the loaded audio object dictionary and the playing audio object dictionary;

[0012] Step 2: The HTML5 end calls the audio controller on the iOS end to control the audio object in the HTML5 page.

[0013] Preferably, in step 2, the HTML5 end calls the audio controller of the iOS end to implement control of the audio objects in the HTML5 page, including: loading audio objects, playing audio objects, pausing audio objects, adjusting the audio volume of audio objects, controlling whether audio objects are played in a loop, removing individual audio objects, removing all audio objects, muting audio objects, and unmuting audio objects.

[0014] Preferably, the method for loading an audio object is:

[0015] Step A1, the HTML5 end sends a request to load an audio object to the audio controller of the iOS end; wherein the request carries the ID of the audio object to be loaded; the audio object to be loaded is represented as: audio object VF;

[0016] Step A2, after receiving the loading request, the audio controller uses the ID of the audio object VF as the query keyword to query the loaded audio object dictionary, and determines whether the audio object VF exists in the loaded audio object dictionary. If not, execute step A3; if yes, directly execute step A5;

[0017] Step A3, the audio controller determines whether the audio object VF exists in the local resource package. If not, the audio object VF is downloaded to the local resource package through the network, and then step A4 is executed; if it exists, step A4 is directly executed;

[0018] Step A4, the audio controller creates an audio player object VP that uniquely corresponds to the audio object VF, and binds the audio player object VP to the audio object VF;

[0019] Then, the audio controller loads the audio object VF bound to the audio player object VP into the loaded audio object dictionary, and uses the ID of the audio object VF as an identifier, thereby completing the loading process of the audio object VF;

[0020] Step A5: the audio controller returns a notification message to the HTML5 end indicating that the audio object VF has been loaded successfully and can be played.

[0021] Preferably, the method for playing the audio object is:

[0022] Step B1, after the HTML5 end receives the notification message returned by the audio controller that the audio object VF is loaded successfully, the HTML5 end sends a request to the audio controller to play the audio object VF;

[0023] Step B2, the audio controller retrieves the audio object VF bound to the audio player object VP from the loaded audio object dictionary;

[0024] The audio controller sends a play instruction to the audio player object VP; the audio player object VP starts playing the audio object VF on the one hand; on the other hand, the audio object VF bound to the audio player object VP that has started to be played is added to the dictionary of audio objects being played.

[0025] Preferably, pausing the playing of an audio object, adjusting the audio volume of an audio object, and controlling whether an audio object is played in a loop are specifically as follows:

[0026] Step C1, the HTML5 end sends a control instruction for the audio object VF being played to the audio controller; wherein the control instruction includes: pausing the audio object, adjusting the audio volume of the audio object and / or controlling whether the audio object is played in a loop;

[0027] Step C2, after receiving the control instruction, the audio controller takes out the audio object VF and its bound audio player object VP from the playing audio object dictionary;

[0028] The audio controller controls the audio player object VP, including: pausing the audio player object VP, setting the volume of the audio player object VP and / or setting whether the audio player object VP plays in a loop, thereby controlling the audio object VF accordingly.

[0029] Preferably, the method of muting the audio object being played and unmuting the audio object is:

[0030] Step D1, the HTML5 end sends a control instruction to mute all audio objects being played to the audio controller;

[0031] Step D2, the audio controller traverses the currently playing audio object dictionary, and sets the volume of the audio player object bound to each audio object in the currently playing audio object dictionary to 0, so as to achieve a mute effect;

[0032] Step D3, the HTML5 end sends a control instruction to cancel the mute to the audio controller;

[0033] Step D4, the audio controller traverses the currently playing audio object dictionary, and restores the volume of the audio player object bound to each audio object in the currently playing audio object dictionary to the original value, thereby achieving a cancel mute effect.

[0034] Preferably, the method of removing individual audio objects is:

[0035] Step E1, the HTML5 end sends an instruction to remove a certain audio object being played to the audio controller;

[0036] Step E2: the audio controller queries the currently playing audio object dictionary, and removes the corresponding audio object and its bound audio player object from the currently playing audio object dictionary.

[0037] Preferably, the method for removing all audio objects is:

[0038] Step F1, the HTML5 end sends an instruction to remove all audio objects to the audio controller;

[0039] Step F2, the audio controller traverses the currently playing audio object dictionary, removes all audio objects in the currently playing audio object dictionary and the audio player objects bound thereto, thereby clearing the currently playing audio object dictionary;

[0040] The audio controller traverses the loaded audio object dictionary, clears the loaded audio object dictionary, and reclaims resources occupied by all loaded audio objects.

[0041] Preferably, it also includes:

[0042] During the audio object playback process, when an incoming call is monitored, each audio object in the currently playing audio object dictionary is first traversed, and the audio player object bound to each audio object is paused; when the incoming call ends, each audio object in the currently playing audio object dictionary is traversed again, and the audio player object bound to each audio object is resumed;

[0043] or

[0044] When the HTML5 page enters the background, each audio object in the audio object dictionary being played is traversed, and the audio player object bound to each audio object is paused; when the HTML5 page resumes entering the foreground, each audio object in the audio object dictionary being played is traversed, and the audio player object bound to each audio object is resumed.

[0045] The method for controlling audio embedded in an HTML5 page in iOS provided by the present invention has the following advantages:

[0046] (1) By placing the control of the audio object on the iOS side, the playback of each audio object can be precisely controlled to ensure that each audio object can be played according to the control of the program. There will be no situation where some mobile phone models can play while others cannot.

[0047] (2) When the audio object is interrupted by a phone call or other application's audio, it automatically pauses and can resume playing after returning to the application.

[0048] (3) Multiple audio objects can be played simultaneously or cross-played, the volume can be adjusted at will, and special effects such as fading in and out of sound can be achieved.

[0049] Through the technical solution of the present invention, the audio playback effect is finally achieved to be consistent with the effect required to be presented by the design, thereby improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] Figure 1 A flowchart of a method for controlling audio embedded in an HTML5 page using iOS provided by the present invention;

[0051] Figure 2 An architectural diagram of a method for controlling audio embedded in an HTML5 page using iOS provided by the present invention;

[0052] Figure 3 A logic diagram for implementing the method for controlling audio embedded in an HTML5 page using iOS provided by the present invention. DETAILED DESCRIPTION

[0053] In order to make the technical problems, technical solutions and beneficial effects solved by the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0054] The present invention provides a method for controlling audio embedded in an HTML5 page on iOS. The present invention relates to the technical field of audio control on the iOS side, and specifically to a method for controlling operations such as loading, playing, stopping, and removing audio embedded in an HTML5 page on an iOS application, as well as multi-track control and volume control.

[0055] refer to Figure 1 , Figure 2 and Figure 3 The present invention provides a method for controlling audio embedded in an HTML5 page using iOS, comprising the following steps:

[0056] Step 1: After the iOS client embeds the HTML5 page into the browser, it initializes and generates the audio controller, the loaded audio object dictionary, and the playing audio object dictionary;

[0057] in:

[0058] The loaded audio object dictionary is used to store the loaded audio objects;

[0059] The currently playing audio object dictionary is used to store the currently playing audio object;

[0060] The audio controller is used to control the audio object according to the loaded audio object dictionary and the playing audio object dictionary;

[0061] Step 2: The HTML5 end calls the audio controller on the iOS end to control the audio object in the HTML5 page.

[0062] The HTML5 side calls the audio controller on the iOS side to control the audio objects in the HTML5 page, including: loading audio objects, playing audio objects, pausing audio objects, adjusting the audio volume of audio objects, controlling whether audio objects play in a loop, removing individual audio objects, removing all audio objects, muting audio objects, and unmuting audio objects.

[0063] The following is a detailed description of the various control processes:

[0064] (I) Loading audio objects

[0065] The method to load the audio object is:

[0066] Step A1, the HTML5 end sends a request to load an audio object to the audio controller of the iOS end; wherein the request carries the ID of the audio object to be loaded; the audio object to be loaded is represented as: audio object VF;

[0067] Step A2, after receiving the loading request, the audio controller uses the ID of the audio object VF as the query keyword to query the loaded audio object dictionary, and determines whether the audio object VF exists in the loaded audio object dictionary. If not, execute step A3; if yes, directly execute step A5;

[0068] Step A3, the audio controller determines whether the audio object VF exists in the local resource package. If not, the audio object VF is downloaded to the local resource package through the network, and then step A4 is executed; if it exists, step A4 is directly executed;

[0069] Step A4, the audio controller creates an audio player object VP that uniquely corresponds to the audio object VF, and binds the audio player object VP to the audio object VF;

[0070] Then, the audio controller loads the audio object VF bound to the audio player object VP into the loaded audio object dictionary, and uses the ID of the audio object VF as an identifier, thereby completing the loading process of the audio object VF;

[0071] Step A5: the audio controller returns a notification message to the HTML5 end indicating that the audio object VF has been loaded successfully and can be played.

[0072] (2) Playing audio objects

[0073] The method to play the audio object is:

[0074] Step B1, after the HTML5 end receives the notification message returned by the audio controller that the audio object VF is loaded successfully, the HTML5 end sends a request to the audio controller to play the audio object VF;

[0075] Step B2, the audio controller retrieves the audio object VF bound to the audio player object VP from the loaded audio object dictionary;

[0076] The audio controller sends a play instruction to the audio player object VP; the audio player object VP starts playing the audio object VF on the one hand; on the other hand, the audio object VF bound to the audio player object VP that has started to be played is added to the dictionary of audio objects being played.

[0077] (III) Pause the playback of an audio object, adjust the audio volume of an audio object, and control whether the audio object is played in a loop

[0078] Pause the audio object, adjust the audio volume of the audio object, and control whether the audio object is played in a loop. Specifically:

[0079] Step C1, the HTML5 end sends a control instruction for the audio object VF being played to the audio controller; wherein the control instruction includes: pausing the audio object, adjusting the audio volume of the audio object and / or controlling whether the audio object is played in a loop;

[0080] Step C2, after receiving the control instruction, the audio controller takes out the audio object VF and its bound audio player object VP from the playing audio object dictionary;

[0081] The audio controller controls the audio player object VP, including: pausing the audio player object VP, setting the volume of the audio player object VP and / or setting whether the audio player object VP plays in a loop, thereby controlling the audio object VF accordingly.

[0082] (IV) Mute and unmute the audio object being played

[0083] The methods to mute and unmute the currently playing audio object are:

[0084] Step D1, the HTML5 end sends a control instruction to mute all audio objects being played to the audio controller;

[0085] Step D2, the audio controller traverses the currently playing audio object dictionary, and sets the volume of the audio player object bound to each audio object in the currently playing audio object dictionary to 0, so as to achieve a mute effect;

[0086] Step D3, the HTML5 end sends a control instruction to cancel the mute to the audio controller;

[0087] Step D4, the audio controller traverses the currently playing audio object dictionary, and restores the volume of the audio player object bound to each audio object in the currently playing audio object dictionary to the original value, thereby achieving a cancel mute effect.

[0088] (V) Removing individual audio objects

[0089] To remove individual audio objects:

[0090] Step E1, the HTML5 end sends an instruction to remove a certain audio object being played to the audio controller;

[0091] Step E2: the audio controller queries the currently playing audio object dictionary, and removes the corresponding audio object and its bound audio player object from the currently playing audio object dictionary.

[0092] (VI) Remove all audio objects

[0093] The method to remove all audio objects is:

[0094] Step F1, the HTML5 end sends an instruction to remove all audio objects to the audio controller;

[0095] Step F2, the audio controller traverses the currently playing audio object dictionary, removes all audio objects in the currently playing audio object dictionary and the audio player objects bound thereto, thereby clearing the currently playing audio object dictionary;

[0096] The audio controller traverses the loaded audio object dictionary, clears the loaded audio object dictionary, and reclaims resources occupied by all loaded audio objects.

[0097] Also includes:

[0098] During the audio object playback process, when an incoming call is monitored, each audio object in the currently playing audio object dictionary is first traversed, and the audio player object bound to each audio object is paused; when the incoming call ends, each audio object in the currently playing audio object dictionary is traversed again, and the audio player object bound to each audio object is resumed;

[0099] or

[0100] When the HTML5 page enters the background, each audio object in the audio object dictionary being played is traversed, and the audio player object bound to each audio object is paused; when the HTML5 page resumes entering the foreground, each audio object in the audio object dictionary being played is traversed, and the audio player object bound to each audio object is resumed.

[0101] An embodiment is described below:

[0102] Step 1. After the iOS end embeds the HTML5 page into the WKWebview browser, it initializes an audio controller singleton. The audio controller singleton provides the following methods for the HTML5 end to call to control the audio, including: loading audio objects, playing audio objects, pausing audio objects, adjusting the audio volume of audio objects, controlling whether audio objects are played in a loop, removing individual audio objects, removing all audio objects, muting audio objects, and unmuting audio objects.

[0103] The audio controller singleton also provides a dictionary bufferMDic for storing loaded audio objects and a dictionary playerMDic for storing the currently playing audio object.

[0104] Step 2: iOS and HTML5 can interact through native system methods. HTML5 can call window.webkit.messageHandlers.func.postMeSsage(params) through JavaScript to call the audio object control method provided by iOS, thereby controlling the playback of the audio object. iOS can call back HTML5 methods by calling -(void)evaluateJavaScript:(NSString*)javaScriptStringcompletionHandler:(void(^)(id,NSError*))completionHandler to inform HTML5 of the audio object control situation.

[0105] Specifically include:

[0106] 1. Method of loading audio objects

[0107] (void)loadAudioUrl:(NSString*)key url:(NSString*)url isLocal:(BOOL)local callback:(void(^)(BOOL))callback, this method is mainly used to load audio objects. After successful loading, it notifies HTML5 that the audio has been loaded successfully and can be played. If the loading fails, it also notifies HTML5 that the loading failed and continues the subsequent operation.

[0108] in:

[0109] key represents the unique identifier of the audio object, url represents the local address or network address of the audio object, and local is used to determine whether the audio object exists in the local resource package. If it exists, the audio player object is initialized directly through the local address; if it does not exist, the audio object is first downloaded to the local resource package through the network address, and then the audio player object is initialized.

[0110] After loading successfully, bind the audio player object to the audio object, then add the audio object to bufferMDic and use key as an identifier. If you load an audio object with the same identifier later, you can directly take it out of bufferMDic and use it without initializing a new audio player object.

[0111] 2. Play audio objects

[0112] (void)playAudioUrl:(NSString*)channel key:(NSString*)key isLoop:(BOOL)loopvolume:(float)volume. This method is mainly used to play audio objects. Channel indicates which audio track the audio object is placed on, key indicates the unique identifier of the audio object, loop indicates whether the audio object is played in a loop, and volume indicates the volume of the audio object. The audio object is taken out from the bufferMDic audio cache according to the given key, and the bound audio player object is set to loop playback, volume and other information to start playing the audio. Multiple audios can be played simultaneously through different channels, and audios from different tracks do not affect each other. Add the audio object to be played to playerMDic and use channel as an identifier. The audio player object being played can be controlled by channel later.

[0113] 3. Pause the playback of audio objects

[0114] (void)stopAudioUrl:(NSString*)channel. This method is mainly used to pause the playback of an audio object. Through the channel, you can retrieve the audio object being played from playerMDic, pause the bound audio player, and thus pause the playback of the audio object.

[0115] 4. How to adjust the volume of audio objects

[0116] (void)setAudioUrl:(NSString*)channel volume:(float)volume. This method is mainly used to adjust the volume of the audio object. Through the channel, you can get the audio object being played from playerMDic and adjust the volume of the bound audio player to adjust the volume of the audio object. This can achieve the effect of multiple background music gradually fading in and out, etc.

[0117] 5. How to remove individual audio objects

[0118] (void)removeAudioUrl:(NSString*)channel. This method is mainly used to remove the audio player object. It removes the audio player object being played from playerMDic through the channel to release memory and prevent memory crash caused by too many audio objects occupying memory.

[0119] 6. Remove all audio objects

[0120] (void)removeAll, this method is mainly used to remove all the audio objects in the cache. It traverses all the audio objects being played in playerMDic, stops playing, removes them, and clears the dictionary. Then it removes all the audio objects in bufferMDic and clears the dictionary. It is called after the HTML5 page is exited to recycle the resources occupied by all audio objects.

[0121] 7. Methods to mute audio objects

[0122] (void)onMuteAudio: This method is mainly used to mute the audio object being played. It traverses all the audio objects being played in playerMDic and changes the volume of all bound audio player objects to zero to achieve the mute effect.

[0123] 8. How to unmute audio

[0124] (void)offMuteAudio: This method is mainly used to unmute the audio object being played. It traverses all the audio objects being played in playerMDic and changes the volume of all bound audio player objects to the original value to achieve the effect of unmuting.

[0125] Step 3: Processing of audio in some special cases.

[0126] In iOS applications, NSNotification is mainly used to schedule message notifications. Some system operations will be sent to the subscribed programs through NSNotificationCenter. Through these message notifications, the audio playback in these special cases can be processed to prevent unexpected situations in audio playback.

[0127] 1. The situation of audio playback being interrupted by a phone call

[0128] By listening to AVAudioSessionInterruptionNotification, which is called when the audio is interrupted by a phone call, after the interruption begins, all the audio objects being played by playerMDic are traversed, and the bound audio player is paused to pause the playback of the audio object. After the phone interruption ends, it is traversed again to make these audio player objects continue to play, so that the audio object can continue to play and the audio will not be stopped due to external interruptions.

[0129] 2. Enter the background audio playback situation

[0130] By listening to UIApplicationDidEnterBackgroundNotification, which is called when HTML5 enters the background, after HTML5 enters the background, it traverses all the audio objects being played by playerMDic and pauses the bound audio player to pause the audio playback.

[0131] 3. Enter the foreground audio playback situation

[0132] By listening to UIApplicationWillEnterForegroundNotification, which is called when HTML5 enters the foreground, after HTML5 is clicked and activated, all the audio objects being played in playerMDic are traversed, and the bound audio player is played, so that these audios continue to play.

[0133] The method for controlling audio embedded in an HTML5 page by an iOS application provided by the present invention has the following advantages:

[0134] (1) By placing the control of the audio object on the iOS side, the playback of each audio object can be precisely controlled to ensure that each audio object can be played according to the control of the program. There will be no situation where some mobile phone models can play while others cannot.

[0135] (2) When the audio object is interrupted by a phone call or other application's audio, it automatically pauses and can resume playing after returning to the application.

[0136] (3) Multiple audio objects can be played simultaneously or cross-played, the volume can be adjusted at will, and special effects such as fading in and out of sound can be achieved.

[0137] Through the technical solution of the present invention, the audio playback effect is finally achieved to be consistent with the effect required to be presented by the design, thereby improving the user experience.

[0138] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be considered as the scope of protection of the present invention.

Claims

1. A method for controlling audio embedded in an HTML5 page in iOS, characterized in that: The following steps are involved: Step 1: After the iOS client embeds the HTML5 page into the browser, it initializes and generates the iOS client's audio controller, loaded audio object dictionary, and playing audio object dictionary; in: The loaded audio object dictionary is used to store the loaded audio objects; The currently playing audio object dictionary is used to store the currently playing audio object; The audio controller of the iOS terminal is used to control the audio object according to the loaded audio object dictionary and the playing audio object dictionary; Step 2, the HTML5 end calls the audio controller of the iOS end to control the audio object in the HTML5 page, including: loading the audio object, playing the audio object, pausing the audio object, adjusting the audio volume of the audio object, controlling whether the audio object is played in a loop, removing individual audio objects, removing all audio objects, muting the audio object, and unmuting the audio object; The method for loading the audio object is: Step A1, the HTML5 end sends a request to load an audio object to the audio controller of the iOS end; wherein the request carries the ID of the audio object to be loaded; the audio object to be loaded is represented as: audio object VF; Step A2, after receiving the loading request, the audio controller of the iOS end uses the ID of the audio object VF as the query keyword to query the loaded audio object dictionary, and determines whether the audio object VF exists in the loaded audio object dictionary. If not, execute step A3; if yes, directly execute step A5; Step A3, the audio controller of the iOS terminal determines whether the audio object VF exists in the local resource package. If not, the audio object VF is downloaded to the local resource package through the network, and then step A4 is executed; if it exists, step A4 is directly executed; Step A4, the audio controller on the iOS end creates an audio player object VP that uniquely corresponds to the audio object VF, and binds the audio player object VP to the audio object VF; Then, the audio controller of the iOS end loads the audio object VF bound to the audio player object VP into the loaded audio object dictionary, and uses the ID of the audio object VF as an identifier, thereby completing the loading process of the audio object VF; Step A5: the audio controller on the iOS side returns a notification message to the HTML5 side indicating that the audio object VF has been loaded successfully and can be played.

2. The method for controlling audio in an embedded HTML5 page in iOS according to claim 1, characterized in that: The method to play the audio object is: Step B1, after the HTML5 end receives the notification message returned by the audio controller of the iOS end that the audio object VF is loaded successfully, the HTML5 end sends a request to play the audio object VF to the audio controller of the iOS end; Step B2, the audio controller of the iOS terminal retrieves the audio object VF bound to the audio player object VP from the loaded audio object dictionary; The audio controller on the iOS side sends a play instruction to the audio player object VP; the audio player object VP starts playing the audio object VF on the one hand; on the other hand, the audio object VF bound to the audio player object VP that has started to be played is added to the dictionary of audio objects being played.

3. The method for controlling audio in an embedded HTML5 page in iOS according to claim 2, characterized in that: Pause the audio object, adjust the audio volume of the audio object, and control whether the audio object is played in a loop. Specifically: Step C1, the HTML5 end sends a control instruction for the audio object VF being played to the audio controller of the iOS end; wherein the control instruction includes: pausing the audio object, adjusting the audio volume of the audio object and / or controlling whether the audio object is played in a loop; Step C2, after receiving the control instruction, the audio controller of the iOS terminal retrieves the audio object VF and the audio player object VP bound thereto from the dictionary of the audio object being played; The audio controller on the iOS side controls the audio player object VP, including: pausing the audio player object VP, setting the volume of the audio player object VP and / or setting whether the audio player object VP plays in a loop, thereby controlling the audio object VF accordingly.

4. The method for controlling audio in an embedded HTML5 page in iOS according to claim 1, characterized in that: The methods to mute and unmute the currently playing audio object are: Step D1, the HTML5 end sends a control instruction to mute all the audio objects being played to the audio controller of the iOS end; Step D2, the audio controller of the iOS end traverses the currently playing audio object dictionary, and sets the volume of the audio player object bound to each audio object in the currently playing audio object dictionary to 0, so as to achieve a mute effect; Step D3, the HTML5 end sends a control instruction to cancel the mute to the audio controller of the iOS end; Step D4, the audio controller on the iOS end traverses the currently playing audio object dictionary, and restores the volume of the audio player object bound to each audio object in the currently playing audio object dictionary to the original value, thereby achieving a cancel mute effect.

5. The method for controlling audio in an embedded HTML5 page in iOS according to claim 1, characterized in that: To remove individual audio objects: Step E1, the HTML5 end sends an instruction to remove a certain audio object being played to the audio controller of the iOS end; Step E2: the audio controller on the iOS terminal queries the currently playing audio object dictionary, and removes the corresponding audio object and its bound audio player object from the currently playing audio object dictionary.

6. The method for controlling audio in an embedded HTML5 page in iOS according to claim 1, characterized in that: The method to remove all audio objects is: Step F1, the HTML5 end sends an instruction to remove all audio objects to the audio controller of the iOS end; Step F2, the audio controller of the iOS end traverses the currently playing audio object dictionary, removes all audio objects in the currently playing audio object dictionary and the audio player objects bound thereto, thereby achieving the effect of clearing the currently playing audio object dictionary; The audio controller on the iOS end traverses the loaded audio object dictionary, clears the loaded audio object dictionary, and reclaims resources occupied by all loaded audio objects.

7. The method for controlling audio in an embedded HTML5 page in iOS according to claim 1, characterized in that: Also includes: During the audio object playback process, when an incoming call is monitored, each audio object in the playing audio object dictionary is first traversed, and the audio player object bound to each audio object is paused; When the incoming call ends, traverse each audio object in the playing audio object dictionary and restore the audio player object bound to each audio object; or When the HTML5 page enters the background, each audio object in the audio object dictionary being played is traversed, and the audio player object bound to each audio object is paused; when the HTML5 page resumes entering the foreground, each audio object in the audio object dictionary being played is traversed, and the audio player object bound to each audio object is resumed.

Citation Information

Patent Citations

  • Micro video generation system and method based on '' Internet + '' mode

    CN105262959A