Play audio from file to speaker with Media Foundation

I'm attempting to play the audio track from an mp4 file to my speaker. I know Media Foundation is able to decode the audio stream as I can play it with the TopoEdit tool.
In the sample code below I'm not using a media session or topology. I'm attempting to manually connect the media source to the sink writer. The reason I want to do this is that I ultimately intend to be getting the source samples from the network rather than
from a file.
The error I get on the pSinkWriter->WriteSample line when running the sample below is MF_E_INVALIDREQUEST (0xC00D36B2). So I suspect there's something I haven't wired up correctly.
#include <stdio.h>
#include <tchar.h>
#include <mfapi.h>
#include <mfplay.h>
#include <mfreadwrite.h>
#pragma comment(lib, "mf.lib")
#pragma comment(lib, "mfplat.lib")
#pragma comment(lib, "mfplay.lib")
#pragma comment(lib, "mfreadwrite.lib")
#pragma comment(lib, "mfuuid.lib")
#define CHECK_HR(hr, msg) if (hr != S_OK) { printf(msg); printf("Error: %.2X.\n", hr); goto done; }
int _tmain(int argc, _TCHAR* argv[])
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
MFStartup(MF_VERSION);
IMFSourceResolver *pSourceResolver = NULL;
IUnknown* uSource = NULL;
IMFMediaSource *mediaFileSource = NULL;
IMFSourceReader *pSourceReader = NULL;
IMFMediaType *pAudioOutType = NULL;
IMFMediaType *pFileAudioMediaType = NULL;
MF_OBJECT_TYPE ObjectType = MF_OBJECT_INVALID;
IMFMediaSink *pAudioSink = NULL;
IMFStreamSink *pStreamSink = NULL;
IMFMediaTypeHandler *pMediaTypeHandler = NULL;
IMFMediaType *pMediaType = NULL;
IMFMediaType *pSinkMediaType = NULL;
IMFSinkWriter *pSinkWriter = NULL;
// Set up the reader for the file.
CHECK_HR(MFCreateSourceResolver(&pSourceResolver), "MFCreateSourceResolver failed.\n");
CHECK_HR(pSourceResolver->CreateObjectFromURL(
L"big_buck_bunny.mp4", // URL of the source.
MF_RESOLUTION_MEDIASOURCE, // Create a source object.
NULL, // Optional property store.
&ObjectType, // Receives the created object type.
&uSource // Receives a pointer to the media source.
), "Failed to create media source resolver for file.\n");
CHECK_HR(uSource->QueryInterface(IID_PPV_ARGS(&mediaFileSource)), "Failed to create media file source.\n");
CHECK_HR(MFCreateSourceReaderFromMediaSource(mediaFileSource, NULL, &pSourceReader), "Error creating media source reader.\n");
CHECK_HR(pSourceReader->GetCurrentMediaType((DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, &pFileAudioMediaType), "Error retrieving current media type from first audio stream.\n");
// printf("File Media Type:\n");
// Dump pFileAudioMediaType.
// Set the audio output type on the source reader.
CHECK_HR(MFCreateMediaType(&pAudioOutType), "Failed to create audio output media type.\n");
CHECK_HR(pAudioOutType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio), "Failed to set audio output media major type.\n");
CHECK_HR(pAudioOutType->SetGUID(MF_MT_SUBTYPE, MFAudioFormat_Float), "Failed to set audio output audio sub type (Float).\n");
CHECK_HR(pSourceReader->SetCurrentMediaType((DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, NULL, pAudioOutType), "Error setting reader audio output type.\n");
// printf("Source Reader Output Type:");
// Dump pAudioOutType.
CHECK_HR(MFCreateAudioRenderer(NULL, &pAudioSink), "Failed to create audio sink.\n");
CHECK_HR(pAudioSink->GetStreamSinkByIndex(0, &pStreamSink), "Failed to get audio renderer stream by index.\n");
CHECK_HR(pStreamSink->GetMediaTypeHandler(&pMediaTypeHandler), "Failed to get media type handler.\n");
// My speaker has 3 audio types of which I got the furthesr with the third one.
CHECK_HR(pMediaTypeHandler->GetMediaTypeByIndex(2, &pSinkMediaType), "Failed to get sink media type.\n");
CHECK_HR(pMediaTypeHandler->SetCurrentMediaType(pSinkMediaType), "Failed to set current media type.\n");
// printf("Sink Media Type:\n");
// Dump pSinkMediaType.
CHECK_HR(MFCreateSinkWriterFromMediaSink(pAudioSink, NULL, &pSinkWriter), "Failed to create sink writer from audio sink.\n");
printf("Read audio samples from file and write to speaker.\n");
IMFSample *audioSample = NULL;
DWORD streamIndex, flags;
LONGLONG llAudioTimeStamp;
for (int index = 0; index < 10; index++)
//while (true)
// Initial read results in a null pSample??
CHECK_HR(pSourceReader->ReadSample(
MF_SOURCE_READER_FIRST_AUDIO_STREAM,
0, // Flags.
&streamIndex, // Receives the actual stream index.
&flags, // Receives status flags.
&llAudioTimeStamp, // Receives the time stamp.
&audioSample // Receives the sample or NULL.
), "Error reading audio sample.");
if (flags & MF_SOURCE_READERF_ENDOFSTREAM)
printf("End of stream.\n");
break;
if (flags & MF_SOURCE_READERF_STREAMTICK)
printf("Stream tick.\n");
pSinkWriter->SendStreamTick(0, llAudioTimeStamp);
if (!audioSample)
printf("Null audio sample.\n");
else
CHECK_HR(audioSample->SetSampleTime(llAudioTimeStamp), "Error setting the audio sample time.\n");
CHECK_HR(pSinkWriter->WriteSample(0, audioSample), "The stream sink writer was not happy with the sample.\n");
done:
printf("finished.\n");
getchar();
return 0;
I've omitted the code that dumps the media types for brevity but their output is shown below. It could well be that I haven't got the
media types connected properly.
File Media Type:
Audio: MAJOR_TYPE=Audio, PREFER_WAVEFORMATEX=1, {BFBABE79-7434-4D1C-94F0-72A3B9E17188}=0, {7632F0E6-9538-4D61-ACDA-EA29C8C14456}=0, SUBTYPE={00001610-0000-0010-8000-00AA00389B71}, NUM_CHANNELS=2, SAMPLES_PER_SECOND=22050, BLOCK_ALIGNMENT=1, AVG_BYTES_PER_SECOND=8000,
BITS_PER_SAMPLE=16, USER_DATA=<BLOB>, {73D1072D-1870-4174-A063-29FF4FF6C11E}={05589F81-C356-11CE-BF01-00AA0055595A}, ALL_SAMPLES_INDEPENDENT=1, FIXED_SIZE_SAMPLES=1, SAMPLE_SIZE=1, MPEG4_SAMPLE_DESCRIPTION=<BLOB>, MPEG4_CURRENT_SAMPLE_ENTRY=0,
AVG_BITRATE=64000, 
Source Reader Output Type:
Audio: MAJOR_TYPE=Audio, SUBTYPE=Float, 
Sink Media Type:
Audio: MAJOR_TYPE=Audio, SUBTYPE=Float, NUM_CHANNELS=2, SAMPLES_PER_SECOND=48000, BLOCK_ALIGNMENT=8, AVG_BYTES_PER_SECOND=384000, BITS_PER_SAMPLE=32, ALL_SAMPLES_INDEPENDENT=1, CHANNEL_MASK=3, 
Any hints as to where I could look next would be appreciated.

Needed:
pSinkWriter->BeginWriting()

Similar Messages

  • Encore 2.0 doesn't play audio from .mpg file

    A long (1,5 hour) file transcoded from APPro 2.0 with media encoder.
    Encore 2.0 takes about 20 min to import that file as asset, and then - no audio playing in preview!
    I thought it was transcoding, or smth. and waited for an hour - still no audio! Not at the begining, nor at the end...
    Media player plays that file OK.
    Encoder 1.5 imports and plays that file OK in 30 sec!!!
    I wonder what is the problem now ???!!!
    I tried to make another (new!) project with ONLY this file on the ONLY "first play" timeline - the same result
    In some previous projects .mpg files played OK, what ' th difference?
    any idea?

    PAL or NTSC?

  • IPhone 4S keeps playing audio from a video file that is no longer on my phone.

    If I'm listening to music and try to change tracks or pause with the earbud buttons the music fades out and starts playing audio from a video file. It will only play about 3-4 seconds and then stop. This also will happen when double clicking the home button to try and change tracks. When I do that the track skipping buttons won't work and there's no title for the short bit of audio that plays. The only way to get music to start playing again is to go into music and press play again. The music I had been listening to is sitting there paused. The audio from the mystery video file still sometimes plays even when you're in music and the only way you would know is the little play icon at the top right part of the screen. I have removed every video off of my phone and it still does it. This is really frustrating.

    Sounds like a bad battery.  You'll need to bring the phone into Apple for evaluation.
    I'm sure you've been using your phone as designed and properly backing up your data, so you should have minimal, if any data loss should the phone need to be replaced.

  • How can I play music through safari specifically youtube on my Mac book pro over soundlink to my bose wireless speaker I can only play audio from itunes at present? HELP PLEASE!

    How can I play music through safari specifically youtube on my Mac book pro over soundlink to my bose wireless speaker I can only play audio from itunes at present? HELP PLEASE!

    Should be able to go into your sound preferences and choose your output device, you can also try downloading Airfoil and try that, it's a pretty cool app.

  • Satellite L50-A-19N can't play audio from multiple sources

    I can't play audio from multiple sources. This is very annoying when I have 2 youtube videos playing, if I start playing something on the media player, there is no sound on media player, it's the same when I have 2 media players open and 1 youtube video playing, youtube video doesn't have sound..
    It goes away when I plug out my headphones..
    I already have all the latest drivers, last DTS driver update was in 2014, sound update this year's february..
    25/02/14
    DTS Studio Sound
    DTS Inc.
    Windows 8.1 - 64 Bit
    1.01.2700
    I don't know if this makes sense, but I got newer DTS sound driver which I found, It's not my laptop model, but they all seem to be the same - v1.1.88.0
    I uninstalled DTS software and still had the same problem, so it's not affecting sound driver in any way..
    10/02/15
    Sound Driver
    Integrated Device Technology Inc.
    Windows 8.1 - 64 Bit
    6.10.6491.0
    IDT audio driver has newer release date, but the driver version is the same as the 2013 one..
    Why are toshiba releaseing old driver as 'NEW' ?
    2nd is my speakers advanced settings, nothing changed when I disabled "Allow applications to take exclusive control of this device"

    I see that the option called “give exclusive mode applications priority” has been checked.
    Usually different applications and programs can access the sound card simultaneously.
    For example: you can hear the sound in game, while you can run your own music via an external player.
    This is prevented with these options “give exclusive mode applications priority”.
    Maybe you should disable (uncheck) this option to prevent the different applications for using this exclusive mode stream.
    I did it for my DAC. I set the DAC for exclusive mode. Once my audio playback software starts to play music, no other software is able to share the DAC.
    However, I use Win 7 and Realtek sound driver… It’s another configuration.
    So it’s not known to me if your issue is related Win 8.1 system or maybe limitation of sound driver… it could be also possible that one of your sound applications don’t allow multiple sound streaming.

  • Is it possible to play audio from video in the background while using a different app?

    I would like to be ale to play audio from a video file in videos (or av player hd) in the background whie using a diffent app in my iPad 2. (ie watching a video while taking notes on the content or highlighting an e-textbook).
    Is this possible? Either through the original iPad functionality or by downloading a separate app?
    Thanks,
    mji

    Is it important that the music come from a video, or are you just looking to listen to music in the background, while doing something else.  If the later, you can certainly play music from the Music App, Pandora, or iHeart Radio, etc., and with the music playing, tap your home button to go to your home page and open anything else you want and the music will continue.
    I don't have any videos to try out right now, but you try the same thing out and if the music continues, it works.  If it doesn't, it doesn't.

  • Satellite L-50 can't play audio from multiple sources

    I can't play audio from multiple sources. This is very annoying when I have 2 youtube videos playing, if I start playing something on the media player, there is no sound on media player, it's the same when I have 2 media players open and 1 youtube video playing, youtube video doesn't have sound..
    I already have all the latest drivers, last DTS driver update was in 2014, sound update this year's february..
    25/02/14
    DTS Studio Sound
    DTS Inc.
    Windows 8.1 - 64 Bit
    1.01.2700
     I don't know if this makes sense, but I got newer DTS sound driver which I found, It's not my laptop model, but they all seem to be the same - v1.1.88.0 
    I uninstalled DTS software and still had the same problem, so it's not affecting sound driver in any way..
    10/02/15
    Sound Driver
    Integrated Device Technology Inc.
    Windows 8.1 - 64 Bit
    6.10.6491.0
    IDT audio driver has newer release date, but the driver version is the same as the 2013 one..
    Why are toshiba releaseing old driver as 'NEW' ?
    2nd is my speakers advanced settings, nothing changed when I disabled "Allow applications to take exclusive control of this device"
    Attachments:
    audio.png ‏6 KB
    test2.png ‏7 KB
    specs.png ‏16 KB

    Can you check the full model and part number from the laptop?
    - Peter

  • HT4072 Can I play audio from movies in the DVD player using iTunes or Airplay?

    I would like to play audio from movies in the MacBook DVD player using iTunes or Airplay? Is this possible?

    Is it important that the music come from a video, or are you just looking to listen to music in the background, while doing something else.  If the later, you can certainly play music from the Music App, Pandora, or iHeart Radio, etc., and with the music playing, tap your home button to go to your home page and open anything else you want and the music will continue.
    I don't have any videos to try out right now, but you try the same thing out and if the music continues, it works.  If it doesn't, it doesn't.

  • I have a docking station to charge and play audio from my ipod touch 3rd gen.  Just bought a new ipod touch 5 th gen.  Is there a converter/ adapter available so I can continue to use my dock?

    I have a docking station to charge and play audio from my ipod touch 3rd gen.  Is there an adapter available for the ipod touch 5th gen so that I can keep using the old dock?

    Lightning  Adopters
    One of these adopters/cables should work:
    http://store.apple.com/us/product/MD824ZM/A/lightning-to-30-pin-adapter-02-m?fno de=45
    http://store.apple.com/us/product/MD823ZM/A/lightning-to-30-pin-adapter?fnode=45

  • 5G Plays Audio From Movies But No Video

    I can play audio from all the movies downloaded to my Ipod, but it plays no video. I purchased some music videos from itunes, still the same problem. Any help would be great.
    Thanks
    Gateway   Windows XP  

    Are you watching on the iPod or TV? Is TV output on or off?
    2.0GHZ G5/533MHz G4 DeskTop/400MHz G4 PB   Mac OS X (10.4.3)  

  • In-ear headphones playing audio from one side only

    My apple in-ear headphones only play audio from one side.  I've tried replacing the cap and mesh; and also tested the headphones on different devices and still get the same problem.  Any advice?

    Probably time to have them replaced.
    B-rock

  • How do I play audio from my headphone jack and internal speakers?

    How do I play audio from my headphone jack and internal speakers at the same time ? I have a splitter for my audio jack so that when i connect up my second monitor I can have it so it also plays audio as well as anything else i have connected into the jack but how do i let the internal speakers emit sound at the same time?

    Hello,
    If you mean the internal speakers in your Mac, you can't play audio through them at the same time you have anything plugged into the headphone jack. When you plug something into the headphone jack, it disconnects the internal speakers.

  • Flash Player 10 is not playing audio from Youtube with Vista and IE

    Since installing FP10, I cannot get audio when playing YouTube video. I'm running Vista with SP2 and IE on an HP laptop. Flash 0 on my XP desktop plays audio fine, so I'm guessing its a setting on my laptop which needs changing back to what it was before the upgrade to FP10...any ideas please? I have uninstalled and the reinstalled FP10 as per other posts on this forum, but no success.

    I too am experiencing this
    [edit]
    My problem was that I was not getting flash audio at all, including local publishes out of the IDE.  The problem was that my Windows Audio service had stopped (for some reason).
    To check :
    (classic view) :: Start > Settings > Control Panel > Administrative Tools > Services >
    (non-classic) :: Computer (right click)  > Manage > Services and Applications > services >
    (one of the above, then) :: [scroll down to 'Windows Audio'] > r-click 'properties', general tab, set the start-up type to manual (in the dropdown), and click the start button on the next line.

  • Cannot play audio from macbook pro 2009 to tv using hdmi with adapter

    MacBook Pro 2009. I cannot get audio from my my macbook pro to tv using an hdmi adapter

    That is because the 2009 MBP does not support audio via the minidisplay port.  You will have to tap the audio output port for audio and use the RCA audio input connections on the TV.
    Ciao.

  • Play audio from internet -http connection-

    Hi friends,
    I have made an audio player using jmf as part of my project.It can play files from local machine as well as local network in my company. But i don't know how to play audio files like wav,mp3 from internet using http connection as described by tristanlee85. Can anyone explain me how to accomplish this.
    The code where i tried to
    access http connection is given below.
    But it is not working.I know Streaming is necessary. But how to do it in jmf. What imports are needed.Please guide me
    Manu
    import javax.media.*;
    import java.text.DecimalFormat;
    import java.awt.*;
    import java.awt.FileDialog;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    <APPLET CODE=PlayerApplet.class
    WIDTH=320 HEIGHT=300>
    </APPLET>
    class nwa extends WindowAdapter
         frameclass frame;
         Player player;
         public nwa(frameclass frame,Player player)
          this.player=player;
          this.frame=frame;
         public void windowClosing (WindowEvent e)
          //User selected close from System menu.
          //Call dispose to invoke windowClosed.
          frame.dispose ();
          public void windowClosed (WindowEvent e)
              if (player != null)
                   player.stop();
                player.close ();
                   player.deallocate();
          System.exit (0);
    class frameclass extends JFrame
    Player player;
         frameclass(Player player)
         nwa n=new nwa(this,player);
         this.addWindowListener(n);                    
    public class PlayerApplet extends JApplet
               implements ActionListener,ControllerListener,ItemListener, KeyListener
               Player player=null;
               frameclass frame=new frameclass(player);
                 Component vc, cc;
                 Container f;
                 JProgressBar volumeBar;
                 JButton fastRewind;
              JButton fastForward;
              JButton play;
              int sizeIncrease = 2;
              boolean invokedStop = false;
              /** Big */
              int progressFontSize=30;
                 boolean first = true, loop = false;
                 String currentDirectory;
                 public void init()
                          f=frame.getContentPane();
                         JMenu m = new JMenu ("File");
                         JMenuItem mi = new JMenuItem ("Open...");
                         mi.addActionListener (this);
                         m.add (mi);
                         m.addSeparator ();
                         mi = new JMenuItem ("URL");
                         mi.addActionListener (this);
                         m.add (mi);
                         m.addSeparator ();
                         JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem ("Loop", false);
                         cbmi.addItemListener (this);
                         m.add (cbmi);
                         m.addSeparator ();
                         mi = new JMenuItem ("Exit");
                         mi.addActionListener (this);
                         m.add (mi);
                         JMenuBar mb = new JMenuBar ();
                         mb.add (m);
                         frame.setJMenuBar (mb);
                         setSize (500, 500);
                           JPanel p = new JPanel(new GridLayout(1,0,5,5));
                        p.setBorder(new EmptyBorder(3,5,5,5) );
                        fastRewind = new JButton("<html><body><font size=+"+ sizeIncrease+ "><<");
                        fastRewind.setToolTipText("Fast Rewind");
                        fastRewind.addActionListener( new ActionListener(){
                             public void actionPerformed(ActionEvent ae) {
                                  if (player!=null) {
                                       invokedStop = false;
                                       skipBack();
                                  } else {
                                       JOptionPane.showMessageDialog(play,
                                       new JLabel("Open a sound file first!"));
                        fastRewind.addKeyListener(this);
                        p.add(fastRewind);
                        JButton stop = new JButton("<html><body><font size=+"+ sizeIncrease+ ">��");
                        stop.setToolTipText("Stop");
                        stop.addActionListener( new ActionListener(){
                                  public void actionPerformed(ActionEvent ae) {
                                       invokedStop = true;
                                       sp();
                        stop.addKeyListener(this);
                        p.add(stop);
                        play = new JButton("<html><body><font size=+"+ sizeIncrease+ ">>");
                        play.setToolTipText("Play");
                        play.addActionListener( new ActionListener()
                                  public void actionPerformed(ActionEvent ae) {
                                       if (player!=null) {
                                            invokedStop = false;
                                            player.setRate(1);
                                            st();
                                       } else {
                                            JOptionPane.showMessageDialog(play,
                                            new JLabel("Open a sound file first!"));
              play.addKeyListener(this);
              p.add(play);
              fastForward = new JButton("<html><body><font size=+"+ sizeIncrease+ ">>>");
              fastForward.setToolTipText("Fast Forward");
              fastForward.addActionListener( new ActionListener(){
                   public void actionPerformed(ActionEvent ae) {
                        if (player!=null) {
                             invokedStop = false;
                             skipForward();
                        } else {
                             JOptionPane.showMessageDialog(play,
                             new JLabel("Open a sound file first!"));
              fastForward.addKeyListener(this);
              p.add(fastForward);
              frame.getContentPane().add(p,BorderLayout.CENTER);
              frame.setVisible (true);
              frame.pack();
              frame.setResizable(false);
      public void stop(){
      sp();
      public void destroy(){
       player.stop();
        player.deallocate();
      public void actionPerformed (ActionEvent e)
              if (e.getActionCommand().equals("Exit"))
                             // Call dispose to invoke windowClosed.
                             player.stop();
                             player.close();
                             player.deallocate();
                             frame.dispose ();
                                  return;
    // Play file from local machine
              if (e.getActionCommand().equals("Open..."))
                             FileDialog fd = new FileDialog (frame, "Open File",
                                         FileDialog.LOAD);
                              fd.setDirectory (currentDirectory);
                              fd.show ();
                              // If user cancelled, exit.
                              if (fd.getFile() == null)
                             return;
                              currentDirectory = fd.getDirectory ();
                                   if (player != null){
                                       player.close ();
                                       player.deallocate();
                         try
                  player = Manager.createPlayer (new MediaLocator
                                               ("file:" +
                                               fd.getDirectory() +
                                               fd.getFile()));
                              catch (java.io.IOException e2)
                            System.out.println ("file not found :"+e2);
                            return;
                              catch (NoPlayerException e2)
                            System.out.println ("Could not find a player.");
                            return;
                    if (player == null)
                   System.out.println ("Trouble creating a player.");
                   return;
                    first = false;
                    frame.setTitle (fd.getFile ().toString());
                    player.addControllerListener (this);
                    player.prefetch ();
                   return;
    // Play file from internet
    if (e.getActionCommand().equals("URL"))
                              if (player != null){
                                       player.close ();
                                       player.deallocate();
                   try
                        URL url = new URL ("http://www.plastikhosting.net/uploads/tristanlee85/music/02-hellyeah-you_wouldnt_know.mp3");
                    MediaLocator mediaLocator = new MediaLocator (url);
                        player = Manager.createPlayer (mediaLocator);
                   catch (java.io.IOException e2)
                  System.out.println ("file not found :"+e2);
                  return;
                    catch (NoPlayerException e2)
                  System.out.println ("Could not find a player.");
                  return;
                    if (player == null)
                   System.out.println ("Trouble creating a player.");
                   return;
          first = false;
          player.addControllerListener (this);
          player.prefetch ();
              player.start ();
              return;
       public void controllerUpdate (ControllerEvent e)
          if (e instanceof ControllerClosedEvent)
              if (vc != null)
                  frame.getContentPane().remove (vc);
                  vc = null;
              if (cc != null)
                  frame.getContentPane().remove (cc);
                  cc = null;
              return;
          if (e instanceof EndOfMediaEvent)
              if (loop)
                  player.setMediaTime (new Time (0));
                  player.start ();
              return;
          if (e instanceof PrefetchCompleteEvent)
              player.start();
              return;
          if (e instanceof RealizeCompleteEvent)
            if (vc != null)
                  remove (vc);
                  vc = null;
              if (cc != null)
                  remove (cc);
                  cc = null;
              vc = player.getVisualComponent ();
              if (vc != null)
                  frame.getContentPane().add(vc,BorderLayout.NORTH);
              cc = player.getControlPanelComponent ();
              if (cc != null){
                       frame.getContentPane().add (cc, BorderLayout.SOUTH);
                     frame.setVisible(true);
                     frame.pack();
                      return;
    public void keyReleased(KeyEvent ke) {
    public void keyTyped(KeyEvent ke) {
    /*public void keyReleased(KeyEvent ke) {
    int keycode = ke.getKeyCode();
              if (keycode==KeyEvent.VK_LEFT) {
                   skipBack();
              } else if (keycode==KeyEvent.VK_RIGHT) {
                   skipForward();
         /*public void keyTyped(KeyEvent ke) {
         int keycode = ke.getKeyCode();
              if (keycode==KeyEvent.VK_LEFT) {
                   skipBack();
              } else if (keycode==KeyEvent.VK_RIGHT) {
                   skipForward();
         public void keyPressed(KeyEvent ke) {
              int keycode = ke.getKeyCode();
              if (keycode==KeyEvent.VK_LEFT) {
                   skipBack();
              } else if (keycode==KeyEvent.VK_RIGHT) {
                   skipForward();
              }else if (keycode==KeyEvent.VK_UP) {
                   st();
              }else if (keycode==KeyEvent.VK_DOWN) {
                   sp();
    public void skipForward() {
    Time settime;
    double secs=5;
    double playersecs = player.getMediaTime().getSeconds();
    double duration = player.getDuration().getSeconds();
              if((playersecs+secs) < duration){
                      settime = new javax.media.Time(playersecs + secs);
                      player.setMediaTime(settime);
              }else {
                        player.setMediaTime(new Time(duration));
    public void skipBack() {
              double secs1=5;
              double secs2=0;
              double playersecs1 = player.getMediaTime().getSeconds();
              Time settime1;
              if((playersecs1 - secs1) > secs2){
                      settime1 = new javax.media.Time(playersecs1 - secs1);
                      player.setMediaTime(settime1);
              }else {
                        player.setMediaTime(new Time(0));
         public void st() {
         player.start();
         public void sp() {
         player.stop();
       public void itemStateChanged (ItemEvent e)
          loop = !loop;
    }

    Thank u Thompson For your kind reply. I got the problem solved. It was the the problem of Untrusted Applet as u said.Now i Have signed my applet and this appletplayer plays audio only from the server from where this applet comes and from the localmachine also.Now it is playing fine from the server.
    But i have another problem , If i am asking that in the wrong forum plz forgive, I will ask it it in applet forum also.
    Problem is , I have implemented a joystick with this player. The idea is to combine this player with a text editor so that user can hear audio at the same time he can type in the editor what he hear and he can rewind and forward using joystick(It is actually a footswitch controller) with his leg. This driver i got from Source forgenet works fine in my localmachine and localnetwork also.But i have to install .DLL file in every client machine. This should be avoided.When a client having no jmf and joystick in his machine tries to run this applet through the browser the required Joystick driver and jmf must be installed in client computer also.
    By signing the applet and using ARCHIVE keyword i think jmf part will be ok but what about joystick driver.How i could install it in client machine.Playerapplet throws jjstck.dll not found exception
    plz guide me
    manu

Maybe you are looking for

  • Problem with the # in upload file of application server.

    Hi All, I have a to upload a unix file which have # after every field. i tried  " OPEN DATASET x_file FOR INPUT IN TEXT MODE ENCODING DEFAULT IGNORING CONVERSION ERRORS." but its  not working .would appreciate if you can  reply to this  on immediate

  • How to save iTunes library from failing internal drive?

    How does one go about doing this? My internal drive is making noise (and I suspect about to fail), so I'm trying to save my itunes library...I have already switched default drive to my external, but as I understand it some info is still saved on my i

  • How to hide a particular report in a Dasboard for some level of user

    Hi Gurus, This is our requirment. We have Level Based Hierarchy starting from L1 to L8.We want to display one particular report or page only for the Level Greater than or equal to L5. Any kind of help is appreciated. Regards

  • Writind Data to XML in XML Format

    Hi, This is my First post in Sun Forums. I m learning XML writing in Java. I have searched on the Net but unable to find the proper XML writing Method using any API. Please provide code for writing the XML in correct format with useful API.? i m givi

  • 2 monitors, gaming, youtube dailymotion, no video

    flash 10,2,152,32 windows 7 x64 , opera chrome When i Play starcraft 2, warcraft 3, HoN on 1 monitor and the other monitor have a youtube/dailymotion video the second i switch to gaming ... the video goes black... when i switch back, it resumes.... i