Click here to Skip to main content
11,804,919 members (67,106 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: Javascript CSS HTML
Hi everyone

I have this's an audio player list but I have a little problem ... it opens the file in new windows how to make it in the same window??????

CSS File:
.active a{color:#5DB0E6;text-decoration:none;}
li a{color:#eeeedd;background:#333;padding:5px;display:block;}
li a:hover{text-decoration:none;}

HTML File:
<audio id="audio" preload="auto" tabindex="0" controls="" type="audio/mpeg">
    <source type="audio/mp3" src="">
    Sorry, your browser does not support HTML5 audio.
<ul id="playlist">
    <li class="active"><a href="">Ravel Bolero</a></li>
    <li><a href="">Moonlight Sonata - Beethoven</a></li>
    <li><a href="">Canon in D Pachabel</a></li>
    <li><a href="">patrikbkarl chamber symph</a></li>

JavaScript File:
var audio;
var playlist;
var tracks;
var current;
function init(){
    current = 0;
    audio = $('audio');
    playlist = $('#playlist');
    tracks = playlist.find('li a');
    len = tracks.length - 1;
    audio[0].volume = .10;
        link = $(this);
        current = link.parent().index();
        run(link, audio[0]);
        if(current == len){
            current = 0;
            link = playlist.find('a')[0];
            link = playlist.find('a')[current];    
function run(link, player){
        player.src = link.attr('href');
        par = link.parent();
Posted 3-Jan-13 7:16am
Sergey Alexandrovich Kryukov at 3-Jan-13 13:26pm
Why do you think audio element is related to SWF?
davemas at 3-Jan-13 16:14pm
because I saw many sites have a player as SWF file and that's why I said that
but I have this example and I need to play the file without open new window
Sergey Alexandrovich Kryukov at 3-Jan-13 16:20pm
No, no, SWF files are played in different ways, for example, using the HTML element "object". This is a completely different approach; please don't mix them up.
davemas at 3-Jan-13 16:27pm
I'm not using SWF in this example I don't want to use it but my project is:

I have my music and I made offline website only for me .... and I have every song as a link and I want to make a player in the same window or another way:
I have a SWF player but I don't know how to make every link play a song in this player
Sergey Alexandrovich Kryukov at 3-Jan-13 16:35pm
OK, your question was not about SWF. You asked about something about "without SWF"... And then I answered...
"I don't know" is not a question...
davemas at 3-Jan-13 16:38pm
hehehehe I'm sorry my friend ..... ok now do you understand my idea??
if you can help me to make it ... please tell me

or if you can help me to play file in swf player !!!
Sergey Alexandrovich Kryukov at 3-Jan-13 16:51pm
It was "without SWF", and not, it turns out, it means "with SWF". Not sure, never did it, but...
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You may just need to add a target attribute to your anchor tags.
Target Attribute[^]
davemas at 3-Jan-13 16:23pm
I put this in the link but still open new window
Marcus Kramer at 3-Jan-13 16:25pm
target="audio" isn't a valid option.
The only valid options are
1) _blank Opens the linked document in a new window or tab
2) _self Opens the linked document in the same frame as it was clicked (this is default)
3) _parent Opens the linked document in the parent frame
4) _top Opens the linked document in the full body of the window
5) framename Opens the linked document in a named frame
davemas at 3-Jan-13 16:34pm
and how it will be??
Marcus Kramer at 3-Jan-13 17:00pm
Just read the options. They are pretty much self-explanatory.
In this case use the target="_self" option to open the link into the current window.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Please see my comment to the question: I cannot see how your question is related to SWF. You are trying to work with HTML5 audio element. Please see:[^],[^],[^].

This element is rather associated with Ogg Vorbis audio. The problem of acceptable or supported audio format is somewhat controversial these days. For further detail, please see:[^],[^].

For comparison, please see also my recent CodeProject Q&A post of audio formats: HTML5 and Mime, Streaming a video?[^].

Also, see the post reference above and pay attention for my recommendations to use ffMpeg or libavcodec utilities for media conversion. There are widely universal. It's very likely that they will help you to re-master your audio record to present them properly in your Web applications.

Rate this: bad
Please Sign up or sign in to vote.

Solution 3

OK, now it's weird. After the discussion in comments on something related to "without SWF File" it turns out to be rather "how to play SWF file in ASP.NET application". And how was I supposed to understand it.

OK, here is one short but descriptive CodeProject article on the topic:
How To Play SWF File In Asp.Net[^].

As I mentioned before, this is completely different technique. Look at the code sample: it's based on the HTML element <object>.

If you need, you will find a lot more:[^],[^].


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 3,205
1 Maciej Los 1,950
2 KrunalRohit 1,907
3 CPallini 1,855
4 Richard MacCutchan 1,187

Advertise | Privacy | Mobile
Web04 | 2.8.151002.1 | Last Updated 3 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100