关于audio标签使用动态生成的mp3无法拖拽进度条的问题

html5 audio video不需要插件即可播放音频和视频,currentTime可以用来设置播放的起始时间,使得可以不从文件开头开始播放。如果 html5 audio video设置currentTime失效,无法设置开始播放的时间点,audio/video不能拖动进度条调整播放进度,很有可能是使用了php asp jsp等服务器后端语言动态输出待播放的媒体文件内容,如果audio/video播放的媒体资源文件不是静态文件,不经过处理直接通过服务器语言动态输出流媒体内容,设置currentTime不会生效。

为什么直接使用静态的.mp3 .mp4 .flac等媒体文件时支持使用 audio | video .currentTime = NUMBERIC; (NUMBERIC是一个数字,可以是整数,也可以是浮点数)来设置播放起始位置呢,而动态输出流媒体文件内容时不行呢?

这其中的核心技术就是服务器端对断点续传的支持,断点续传允许客户端从服务器提取某个文件指定字节范围内的一部分内容,当下载中断以后再次下载时可以只请求下载原先没有下载的部分,避免重复传输现有内容。当客户端(浏览器)检测到服务器支持断点续传以后才会发送相应的区间内容请求给服务器,服务器接到请求以后再返回相应范围内的文件内容,这样才能实现流媒体文件的定点播放。而直接使用静态文件做播放资源时,服务器软件通常会自动处理断点续传请求。

实现动态流媒体文件支持通过HTML5 audio/video.currentTime设置播放起始时间点,可以使用以下两种方法。

方法一:

使用服务器模块X-SendFile输出流媒体文件内容来解决currentTime失效的问题,以Apache服务器为例。

首先下载mod_xsendfile,将模块文件复制到Apache的modules目录,在Apache配置文件中添加
LoadModule xsendfile_module modules/mod_xsendfile.so
XSendFile On
XSendFilePath D:/server
复制代码其中XSendFilePath意思是将指定的文件夹路径添加到白名单中,指定文件夹中的文件可以被Apache直接发送给客户端,除了设置的文件夹本身以外,该文件夹包含的各级子目录也在允许范围内。配置完服务器以后重启Apache服务器以后X-SendFile模块有效。

安装了X-SendFile模块以后,PHP输出媒体文件变得非常简单。其中的Content-Type是要输出文件的MIME类型,可以不必写死而通过服务器语言获取。可以参见方法二有实例代码。

方法二:

使用服务器语言模拟断点续传支持让HTML5 audio/video.currentTime生效,以PHP为例。

如果没有服务器配置权限,可以在动态语言中发送Accept-Ranges: bytes和Content-Range: bytes S-E/FILESIZE两个响应头,告诉客户端它请求的服务器资源支持断点续传,服务器端接收到客户端发送的请求以后,从请求头拿到需要发送的内容区间,然后从文件中读取指定起止位置的数据发送到客户端即可解决HTML5 audio/video使用后端语言动态输出媒体文件内容造成的currentTime失效以及无法手动拖动进度条的问题。其中S和E分别是当次请求的起始位置索引和结束位置索引,FILESIZE为代表文件尺寸的总字节数,源码如下:

PHP使用签名URL对阿里云对象存储进行临时授权

PHP使用签名URL对阿里云对象存储进行临时授权,代码如下:

阿里帮助中心:
首页>对象存储 OSS>SDK示例>PHP>PHP授权访问
https://help.aliyun.com/document_detail/32106.html

2022年09月英语四级第1套听力原文及题目

2022年09月英语四级第1套听力原文及题目

Section A
Direction: In this section, you will hear three news reports. At the end of each news report, you will hear two or three questions. Both the news report and the questions will be spoken only once. After you hear a question, you must choose the best answer from the four choices marked A), B), C) and D). Then mark the corresponding letter on Answer Sheet 1 with a single line through the centre.

News Report 1
White meat, such as chicken, may raise blood cholesterol levels as much as red meat does. This finding surprised researchers, who admitted they didn’t expect that eating white meat would lead to higher blood cholesterol levels. In the study, researchers looked at 113 healthy people. The participants ate three different diets. These were a red meat diet which is primarily beef, a white meat diet which is mostly chicken and turkey, and a vegetarian protein diet. Each diet period was four weeks. Between the diet periods, participants had a break, during which they ate their regular foods. In addition, participants had blood tests at the start and finish of each new diet. The results showed that white and red meat diets had the same effects on blood cholesterol levels. Further, both diets increased blood cholesterol levels compared with the diet built on vegetarian protein sources. The team acknowledged that it is possible that white meat is better for our health than red meat despite their findings. This is because other effects of red meat consumption could contribute to heart disease independent of cholesterol. Their main recommendations are that people eat less of both kinds of meat and more vegetarian protein.
Questions 1 and 2 are based on the news report you have just heard.
Question 1: What do we learn from the news report about the study?
Question 2: What did the researchers acknowledge?

1.
A) It examines the effect of cholesterol on people’s health.
B) Its participants all had high blood cholesterol levels.
C) It questions the benefits of a vegetarian protein diet.
D) Its finding came as a surprise to the researchers.

2.
A) They do not know all the effects of eating meat.
B) Red meat itself does not cause heart diseases.
C) White meat may be healthier than red meat.
D) Vegetarian protein may be easier to absorb.

News Report 2
At around half past nine this morning, a trailer attached to a lorry turned over at the crossing of High Street in Milton. Hundreds of frozen turkeys were spilled all over the road. It is reported that nobody was hurt in the incident, but police said it may affect traffic and Christmas dinners. With just one week to go before Christmas, there are worries that local supermarket supplies of this holiday favorite may be affected. A police spokeswoman said that officers were currently in attendance at the scene. She stated that the driver of the lorry had been arrested on suspicion of dangerous driving. The crossing on High Street is a well-known accident blackspot. This year alone, there have been seven traffic accidents at this location. Thankfully, none of these accidents have resulted in serious injury.
Questions 3 and 4 are based on the news report you have just heard.
Question 3: What does the news report say about the accident at the crossing of High Street in Milton?
Question 4: What do we learn about the crossing on High Street?

3.
A) It may have been due to the lorry driver’s drunk driving.
B) It may affect the local supply of turkeys for Christmas.
C) It interrupted traffic for several hours running.
D) It was caused by a lorry running into a trailer.

4.
A) It has been the scene of several fatal accidents recently.
B) It is the spot that causes the local police a lot of worry.
C) It has witnessed several traffic accidents this year.
D) It is a location frequented by local traffic police.

News Report 3
India launched its helicopter taxi service on Monday, promising to ferry customers the 40 miles between Bangalore’s Electronic City tech hub and the International Airport terminal in 15 minutes. Customers can book their helicopter ride through a mobile app. The service, which claims to be the first of its kind in India, offers only one route, but Bangalore airport will add more once it gets approval. Helicopter taxi is not an affordable option for many travelers. A car ride for the same journey costs less than half as much. But Bangalore airport says it is a competitive alternative to a car ride for tech executives in a hurry. “A large number of high-class travelers, including CEOs, have to spend more than three hours by road to get there — and that is a loss of time,” a Bangalore airport spokesperson said. “This is not a low cost option, but it is an option,” she added. The helicopters ferried around eight customers to the airport on their first day. The company that owns and operates the service is called Thumby Aviation. It previously specialized in private charter flights for government officials.
Questions 5 to 7 are based on the news report you have just heard.
Question 5: What is Bangalore airport trying to do about the helicopter taxi service?
Question 6: What do we learn from the news report about the helicopter taxi ride?
Question 7: Who are the targeted customers of the helicopter taxi service?

5.
A) Get approval to add more routes.
B) Attract more international tourists.
C) Advertise it through a mobile app.
D) Make it affordable to common folk.

6.
A) It costs more than twice as much as a car ride.
B) It is gaining popularity among ordinary Indians.
C) It symbolizes India’s advancement in high-tech.
D) It can get anywhere in the city within 15 minutes.

7.
A) International tourists.
B) High-class travelers.
C) Prominent superstars.
D) Customers in a hurry.

Section B
Direction: In this section, you will hear two long conversations. At the end of each conversation, you will hear four questions. Both the conversation and the questions will be spoken only once. After you hear a question, you must choose the best answer from the four choices marked A), B), C) and D). Then mark the corresponding letter on Answer Sheet 1 with a single line through the centre.

Conversation 1
W: Hi, I wish to buy some cheese for a barbecue this weekend.
M: What kind would you like?
W: Sorry, I don’t know much about cheese. What type do you think would be suitable for a barbecue?
M: That’s easy! For a barbecue, you could have any cheese you want. I imagine there will be different foods and people will just help themselves and eat at their own pace, right?
W: Yes, exactly. It will be very casual. We will just be a small group of friends gathering together at Washington Park. There will be around 20 of us, including children.
M: Great! So you could have different types of cheese. How much would you like to spend?
W: Not very much. Let’s say $30.
M: I would suggest having at least one soft cheese and one hard cheese. That will offer you a good variety to suit different people’s tastes.
W: That sounds good. What’s the difference between a soft cheese and a hard cheese?
M: Well, it depends. But generally speaking, soft cheeses are creamy and go well with sweet things like honey and jam. I would suggest something like this Spanish goat cheese. It’s only $15, a very good price. You can spread it on bread with a knife, and then add a tiny bit of honey on top. It’s delicious. Children love it.
W: Okay, great. What about a hard cheese?
M: Yes, for hard cheese, I would recommend this Italian one here. It has a very strong smell and a dry flavor. You can cut it into thin slices and eat it on its own. It’s $16.
W: Okay, I’ll take both. Thank you for your help.
Questions 8 to 11 are based on the conversation you have just heard.
Question 8: What does the woman plan to do for the weekend?
Question 9: What does the man suggest the woman do?
Question 10: What does the man say about Spanish Goat Cheese?
Question 11: What is the woman going to do at the end of the conversation?

8.
A) Treat her friends in a bar.
B) Take a trip to Washington.
C) Make some cheese.
D) Throw a party.

9.
A) Spend no more than 30 dollars.
B) Buy different kinds of cheese.
C) Help him prepare the barbecue.
D) Find out different people’s tastes.

10.
A) It is the best kind of hard cheese.
B) It is the most popular in Spain.
C) It is more delicious than honey.
D) It is a good choice for children.

11.
A) Buy what the man recommended.
B) Have a taste of both of the cheeses.
C) Choose one of the two types of cheese.
D) Ask the man to cut the cheese into slices.

Conversation 2
M: Our school is replacing printed textbooks with e-textbooks next semester. I can’t wait.
W: Really? What about the cost, not only buying all those tablets, but the software and electronic infrastructure that goes with it, not to mention retraining all the teachers and administration staff?
M: Sure, the initial expenditure will be high, but much lower afterwards. Besides that, tablet prices continue to drop and are becoming increasingly affordable. Anyway, tablets help students learn up to 80% faster.
W: Not necessarily. Tablets have too many distractions. Students may pay attention to apps, games and websites instead of their teachers. In fact, research suggests that people who read printed text comprehend more, remember more and learn 30% more than those who read digital text.
M: Yes. But tablets contain many technological features that are not found in printed textbooks. Think about it. Students are able to highlight and edit text, write notes and search for information much more quickly than they can with printed textbooks. And what about all those trees that are cut down to make printed books?
W: Actually, manufacturing tablets is environmentally destructive and dangerous to human health. The health impacts from making one electronic reader are 70 times greater than those from making a single printed book. A lot of minerals are extracted from the earth to make electronic readers. It does far more damage to the environment.
M: Yes. But the software for electronic readers can be updated instantly without the need for buying a whole lot of new books. That’s better for the environment.
W: But the core curriculum doesn’t change that much. Printed textbooks that are not brand new, still contain the basic relevant information of core subjects.
M: Well, I’m looking forward to the change.
W: I’ll stick with my printed books.
Questions 12 to 15 are based on the conversation you have just heard.
Question 12: What does the woman say about using E-textbooks?
Question 13: According to the man, how can the use of tablets benefit students?
Question 14: What does the woman say about students using tablets?
Question 15: What does the woman say about making electronic readers?

12.
A) New teachers and staff have to be recruited.
B) It might take some time for students to adapt.
C) It involves buying lots of tablets and software.
D) The software has to be constantly upgraded.

13.
A) It can greatly improve their learning efficiency.
B) It can help them to interact more with teachers.
C) It can save their trouble of carrying printed books.
D) It can develop their skills in using electronic devices.

14.
A) They may have trouble comprehending texts.
B) They may encounter technological problems.
C) They may pay less respect to teachers.
D) They may get distracted more easily.

15.
A) It generates a great deal of electronic garbage.
B) It does a lot of damage to the environment.
C) It emits huge amounts of harmful radiation.
D) It accelerates the exhaustion of rare minerals.

Section C
Direction: In this section, you will hear three passages. At the end of each passage, you will hear three or four questions. Both the passage and the questions will be spoken only once. After you hear a question, you must choose the best answer from the four choices marked A), B), C) and D). Then mark the corresponding letter on Answer Sheet 1 with a single line through the centre.

Passage 1
In social psychology, the term “person perception” refers to the mental processes that we use to form impressions of other people. It includes not just how we form these impressions, but the conclusions we make about other people based on our impressions. Consider how often you make this kind of judgment every day. When you meet with a new coworker, you immediately begin to develop an initial impression of this person. When you visit the grocery store, you might draw conclusions about the cashier who checks you out. Obviously, person perception is a very subjective process that can be affected by a number of variables, including the characteristics of the person you are observing, the context of the situation, your own personal traits, and your past experiences. One of the techniques we use in person perception is social categorization. In this process, we mentally categorize people into different groups based on common characteristics. Problems with this technique include the fact that it can lead to errors and prejudice. Imagine that you are getting on a bus. There are only two seats available. One is next to a small, elderly woman; the other is next to a muscular, fierce-looking man. You sit next to the elderly woman, who unfortunately turns out to be quite skilled at picking pockets. Because of social categorization, you immediately judge the woman as harmless, and the man as threatening, leading to the loss of your wallet.
Questions 16 to 18 are based on the passage you have just heard.
Question 16: What does the passage say we tend to do every day?
Question 17: What do we learn about person perception from this passage?
Question 18: What is the problem with using social categorization in person perception?

16.
A) Communicate with our coworkers.
B) Encounter people in different places.
C) Judge people based on our first impressions.
D) Engage in a variety of psychological activities.

17.
A) It is an objective evaluation of a person’s character.
B) It is a mental process influenced by many factors.
C) It contributes to the formation of personal traits.
D) It varies greatly among different social groups.

18.
A) It can lead to incorrect judgments.
B) It can cause mistrust among people.
C) It can result in instant losses.
D) It can give rise to gender bias.

Passage 2
Despite smartphones and social media, young people today are as socially competent as those from the previous generation. At least this is what a new study suggests. For the study, researchers compared teacher and parent evaluations of American children who started kindergarten in 1998, with those who began school in 2010. The former group entered kindergarten when mobile phones were luxuries. The latter group started school when mobile devices were widespread. Results showed both groups of children were rated similarly on important social skills. These included their ability to form and maintain friendships and get along with people who are different. They were also rated similarly on self-control, such as the ability to regulate their temper. In virtually every comparison made, ratings of social skills either remain constant or improved for the children born later. There was one exception: Social skills were slightly lower for children who accessed online games and social networking sites many times a day. Adults are worried when technological change starts to undermine traditional relationships, particularly the parent-child relationship. The introduction of telephones, automobiles and radio all led to moral panic among adults of the time, because the technology allowed children to enjoy more freedom. Fears over screen-based technology represent the most recent panic in response to technological change. But overall, the study found little evidence that time spent on screens was hurting social skills for most children.
Questions 19 to 21 are based on the passage you have just heard.
Question 19: What does the news study suggest about young people today and those from the previous generation?
Question 20: What did the study find about children who accessed social networking sites many times a day?
Question 21: What is adults’ worry about technological change?

19.
A) Both groups spend a lot of time on mobile devices.
B) Both groups attach importance to social connections.
C) They are equally competent in using new technology.
D) They are similar in terms of social skills.

20.
A) Their social skills were negatively affected.
B) Their school performance was slightly lower.
C) Their emotions were much harder to regulate.
D) Their relations with peers were badly strained.

21.
A) It may pose a threat to their children’s safety.
B) It may affect society’s traditional values.
C) It may hurt their relations with children.
D) It may change their children’s ethical values.

Passage 3
It’s easy to spend all day searching for inspiration. You can find incredible videos, articles and news stories about the success of others. The problem is that consuming the success and ideas of others is passive inspiration. Every time you read an article or listen to an interview, you’re practicing passive inspiration. You might learn something, but you don’t actually have to do anything. Hearing about other people’s success isn’t the same as creating your own. Instead, it is through the process of active inspiration the act of creating things, applying new ideas to our goals, and making mistakes, that we discover who we are and what is important to us. Furthermore, active inspiration is what results in long-term passion and enthusiasm. Watching someone else’s success might leave you feeling excited for a few minutes. However, taking action and applying a new idea to your life will inspire you more than anything someone else can say. Learning and listening can help you think about things in a different way. But creating, producing, and experimenting is what drives you forward. Passive inspiration can give you ideas, but active inspiration will give you power. Too often we spend our lives consuming the world around us instead of creating it. And what matters is the power your actions have to inspire you. The best inspiration comes from the application of ideas, not the consumption of them.
Questions 22 to 25 are based on the passage you have just heard.
Question 22: What does the speaker say about inspiration from consuming others’ ideas and success stories?
Question 23: What do we learn from the passage about active inspiration?
Question 24: What does the passage say passive inspiration can do?
Question 25: Where does the best inspiration come from according to the passage?

22.
A) It is motivating.
B) It is passive.
C) It is incredible.
D) It is impracticable.

23.
A) It results in short-term excitement.
B) It helps us avoid making mistakes.
C) It breeds long-term passion and enthusiasm.
D) It is bound to help us achieve greater success.

24.
A) Drive us forward.
B) Bring us power.
C) Spur us to action.
D) Give us ideas.

25.
A) Listening to success stories.
B) Applying ideas to one’s life.
C) Following the advice of experts.
D) Consuming the world around us.

关注微信公众号”立金云英语听力”,助您提高英语听力水平
公众号立金云英语听力

PHP代码在线测试运行工具

本例包含2个文件:提供PHP代码编写的前端页面index.html、接受PHP代码解析处理运行的do.php文件。

do.php提供了2种方法来处理PHP代码,一种方法是将处理过的PHP代码通过file_put_contents函数写入到另一个php文件,我们这里命名为了code.php,然后通过header函数跳转到code.php,code.php再将执行结果反馈给index.html。

第二种方法是通过eval函数执行PHP代码,然后将执行结果反馈给index.html。

文件代码如下:

index.html

do.php