简体   繁体   中英

Assertion Error occurred while running HTML5 audio creating program in Hackerrank

<!DOCTYPE html>
<html>
<head>
  <link rel="icon" href="favicon.png" type="image/png">
  <title>Destiny</title>
  <link href="mystyle.css" rel="stylesheet" type="text/css">
</head>
<body>
 // write your code
 <p>regular player</p>
<audio controls>    
   <source src="audio.mp3" type="audio/mpeg">
   <source src="audio.wav" type="audio/wav">
   <source src="audio.ogg" type="audio/ogg">

</audio>   

</body>
</html>

while running this Program in hackerrank the below error occurred

self = <test_webpage.TestWebpage object at 0x7f078f22f0f0>

        def test_indexpage(self):
    
            site = self._index.find_all('audio')
    
            count = 0
    
            for audio in site:
    
                count +=1
    
    >       assert count==3
    
    E       assert 1 == 3
    
    test/test_webpage.py:19: AssertionError

I couldn't find out the error and also I have written the correct syntax for creating audioPlayer using HTML5

Please anyone familiar with HTML5 Multimedia please give me the solution

I was facing the same issue. Try this code. It worked for me.

<body>
 // write your code
<audio controls>    
   <source src="audio.mp3" type="audio/mpeg">
</audio>   
<audio preload='none'>    
   <source src="audio.mp3" type="audio/mpeg">
</audio>  
<audio loop>    
   <source src="audio.mp3" type="audio/mpeg">
</audio>    
</body>

Its correct solution for HTML5 audio question

 <body> <audio controls> <source src="audio.mp3" type="audio/mp3"> </audio> <audio controls preload="none"> <source src="audio.mp3" type="audio/mp3"> </audio> <audio controls loop> <source src="audio.mp3" type="audio/mp3"> </audio> </body>

I can only help on this.

assert count==3

E assert 1 == 3 i can make this assert 2 ==3.

Use

<audio controls>    
   <source src="audio.mp3" type="audio/mpeg">
   <source src="audio.wav" type="audio/wav">
   <source src="audio.ogg" type="audio/ogg">
 Your browser does not support <audio > tag.
</audio>

May be from this you will get some idea. I couldn't go further.

In hakerrank we need to start the server to run html program If we start the test without starting the server it will show assertion error like this U can start the server by opening terminal and type npm start

Before running the test case this Run the program normally and let the server connect.

<p>regular player</p>
<audio controls>
   <source src="SampleAudio.mp3" type="audio/mpeg">
   <source src="SampleAudio.wav" type="audio/wav">
   <source src="SampleAudio.ogg" type="audio/ogg">
</audio>

In your source tag, please specify the name and location of audio file properly. As in case of hackerrank, please look through sidebar in IDE it will be just below your index.html file. I guess, it would be SampleAudio.mp3. Well in that case, the tag becomes -

source src="SampleAudio.mp3" type="audio/mpeg"

and one thing, instead of using it 3 times use it once.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM