[summary of the invention]
Technical matters to be solved by this invention is to provide a kind of can calculate the file that is not played at random with fast speeds, makes each corresponding file of file ID tabulation all can be played once the method that realizes shuffle in multimedia player.
The present invention solves the problems of the technologies described above by the following technical programs: a kind of method that realizes shuffle in multimedia player, wherein said multimedia player comprises controller, random number generator, the file ID tabulation, database, and player, its middle controller control random number generator, the file ID tabulation, database, and player, realize the function of total system, random number generator generates the random number in the specified scope, the file ID list records is not play the ID with the file of having broadcast, database is deposited the information of All Files, can find the information of this document by the ID of file, the player resolution file, the described method of shuffle that realizes in multimedia player comprises the steps:
Step 1: at first controller carries out initialization to file ID tabulation, promptly the corresponding All Files of file ID tabulation is carried out serial number, and according to number order each file is established an ID, establishes the file ID corresponding N file of tabulating;
Step 2: controller controls playing device specifically comprises the steps: N file shuffle one time
Step 21: the random number A that at first generates 1~N scope by random number generator;
Step 22: the ID that from the file ID tabulation, takes out A file;
Step 23: the ID exchange of N file in the ID of A file in the file ID tabulation and the file ID tabulation;
Step 24: the information of removing to search in the database this A file with the ID of A file, and with this A file of player plays;
Step 25: finish the broadcast of this A file;
Step 26: generate a random number less than the file number scope that is not played by random number generator;
Step 27: utilize the random number that generates in the step 26 from the file ID tabulation, to take out the ID of this random number respective file;
Step 28: exchange counting the ID that was not exchanged in ID in the step 27 and the file ID tabulation from behind successively;
Step 29: go to search in the database information of this ID respective file with the ID in the step 27, and with this ID respective file of player plays;
Step 30: the broadcast of file in the end step 29, return step 26, when the file number that is not played is 0, after promptly All Files all is played and finishes, finish to play.
The present invention realizes that in multimedia player the advantage of the method for shuffle is: 1, each file only can be played once; 2, utilize less internal memory that the order of having play is stored, thereby have the function of the broadcast of retreating, can carry out the inverted order playing function by the order of having play; 3, operational method is simple, and travelling speed is very fast.
[embodiment]
The present invention realizes that in multimedia player the multimedia player of the method for shuffle comprises controller, random number generator, file ID tabulation, database, and player.
Its middle controller is used to control random number generator, file ID tabulation, database, and player, realizes the function of total system.Random number generator is used to generate the random number in the specified scope.The file ID tabulation is used to write down the ID of the file of not playing and having broadcast.Database is used for depositing the information of All Files, can find the information of this document by the ID of file.Player is used for resolution file.
The present invention realizes that in multimedia player the method for shuffle comprises the steps:
Step 1: at first controller carries out initialization to file ID tabulation, promptly the corresponding All Files of file ID tabulation is carried out serial number, and according to number order each file is established an ID, establishes the file ID corresponding N file of tabulating;
Step 2: controller controls playing device specifically comprises the steps: N file shuffle one time
Step 21: the random number A that at first generates 1~N scope by random number generator;
Step 22: the ID that from the file ID tabulation, takes out A file;
Step 23: the ID exchange of N file in the ID of A file in the file ID tabulation and the file ID tabulation;
Step 24: the information of removing to search in the database this A file with the ID of A file, and with this A file of player plays;
Step 25: finish the broadcast of this A file;
Step 26: generate a random number less than the file number scope that is not played by random number generator;
Step 27: utilize the random number that generates in the step 26 from the file ID tabulation, to take out the ID of this random number respective file;
Step 28: exchange counting the ID that was not exchanged from behind in ID in the step 27 and the file ID tabulation;
Step 29: go to search in the database information of this ID respective file with the ID in the step 27, and with this ID respective file of player plays;
Step 30: the broadcast of file in the end step 29, return step 26, when the file number that is not played is 0, promptly up to All Files all be played finish after, finish to play.
Be example so that 5 files are carried out shuffle below, specify the present invention realizes shuffle in multimedia player method.
One, initialization is carried out in tabulation to the file file ID, and the ID of the numbering of file and file is provided with shown in following table one after the initialization.
Table one file ID list initialization structure
Tabulation |
1? |
2? |
3? |
……? |
N? |
File ID |
ID1? |
ID2? |
ID3? |
……? |
ID?N? |
Two, to N file shuffle one time.
If during N=5, step is as follows:
1, generates the random number B of 1-5 scope, suppose B=3;
2, from tabulation, take out B file ID, at this moment file ID=ID3;
3, the B of tabulation file ID and N file ID exchange of tabulation.That at this moment tabulates thes contents are as follows shown in the table two:
The later file ID list structure of table two ID exchange for the first time
Tabulation |
1? |
2? |
3? |
4? |
5? |
File ID |
ID1? |
ID2? |
ID5? |
ID4? |
ID3? |
4, remove the database lookup fileinfo with ID3, and use player plays.
Finish first file and begin to play second file:
1, generates the random number C of 1-4 scope, suppose C=2;
2, from tabulation, take out C file ID, at this moment file ID=ID2;
3, the C of tabulation file ID and N-1 file ID exchange of tabulation.That at this moment tabulates thes contents are as follows shown in the table three:
The later file ID list structure of table three ID exchange for the second time
Tabulation |
1? |
2? |
3? |
4? |
5? |
File ID |
ID1? |
ID4? |
ID5? |
ID2? |
ID3? |
4, remove the database lookup fileinfo with ID2, and use player plays.
Finish second file and begin to play the 3rd file:
1, generates the random number D of 1-3 scope, suppose D=2;
2, from tabulation, take out D file ID, at this moment file ID=ID4.
3, the D of tabulation file ID and N-1 file ID exchange of tabulation.That at this moment tabulates thes contents are as follows shown in the table four:
The later file ID list structure of table four ID exchange for the third time
Tabulation |
1? |
2? |
3? |
4? |
5? |
File ID |
ID1? |
ID5? |
ID4? |
ID2? |
ID3? |
4, remove the database lookup fileinfo with ID4, and use player plays.
Finish the 3rd file and begin to play the 4th file:
1, generates the random number E of 1-2 scope, suppose E=1;
2, from tabulation, take out E file ID, at this moment file ID=ID1.
3, the E of tabulation file ID and N-1 file ID exchange of tabulation.That at this moment tabulates thes contents are as follows shown in the table five:
The 4th later file ID list structure of ID exchange of table five
Tabulation |
1? |
2? |
3? |
4? |
5? |
File ID |
ID5? |
ID1? |
ID4? |
ID2? |
ID3? |
4, remove the database lookup fileinfo with ID1, and use player plays.
Finish the 4th file and begin to play the 5th file:
1, generates the random number F of 1-1 scope, suppose F=1;
2, from tabulation, take out F file ID, at this moment file ID=ID5.
3, the F of tabulation file ID and N-1 file ID exchange of tabulation.That at this moment tabulates thes contents are as follows shown in the table six:
The 5th later file ID list structure of ID exchange of table six
Tabulation |
1? |
2? |
3? |
4? |
5? |
File ID |
ID5? |
ID1? |
ID4? |
ID2? |
ID3? |
4, remove the database lookup fileinfo with ID5, and use player plays.
Three, finish to play.