Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Videoview:在Android中从本地服务器播放mp3/视频_Android_Sockets_Video Streaming_Inputstream_Android Videoview - Fatal编程技术网

Videoview:在Android中从本地服务器播放mp3/视频

Videoview:在Android中从本地服务器播放mp3/视频,android,sockets,video-streaming,inputstream,android-videoview,Android,Sockets,Video Streaming,Inputstream,Android Videoview,我用DatagramSocket和DatagramPacket整天都在努力通过本地服务器读取音频文件(mp3)。以下是代码和错误日志: 客户端 OutputStream out = client.getOutputStream(); ... // after receiving the datapacket => I'm trying to write it to a Http socket // which is not working udpS

我用DatagramSocket和DatagramPacket整天都在努力通过本地服务器读取音频文件(mp3)。以下是代码和错误日志:

客户端

    OutputStream out = client.getOutputStream();
    ... 
    // after receiving the datapacket => I'm trying to write it to a Http socket
    // which is not working
    udpSocket.receive(dataPacket);
    http_outputStream.write(dataPacket.getData(),dataPacket.getOffset(),
                              dataPacket.getLength());
我对处理音频/视频文件的功能有些怀疑,因为在尝试 从服务器向客户端发送一些文本,一切正常。 我正在使用:

服务器端

   File audio = new File(Environment.getExternalStorageDirectory()+File.separator, "bob.mp3");
   FileInputStream is = new FileInputStream(audio);
   is.read(buf);
   DatagramSocket socket = new DatagramSocket();
   DatagramPacket out = new DatagramPacket(buf, buf.length, hostAddress, UDP_PORT);
   socket.send(out);
日志:

我感谢你的帮助

编辑: 我忘了提到,类似“服务器”的代码每次将“mp3数据”发送到客户端的同一端口时都使用不同的端口。这样行吗

   4-10 17:26:25.943 I/amplayer( 2307): [parse_sysparam_str]j=0 vc1: start:17 end:39
   04-10 17:26:25.943 I/amplayer( 2307): [vc1 profile] progress:1; interlace:0; wmv1:0; wmv2:0; wmv3:1
   04-10 17:26:25.943 I/amplayer( 2307): [parse_sysparam_str]j=1 h264: start:40 end:46
   04-10 17:26:25.943 I/amplayer( 2307): [parse_sysparam_str]j=2 real: start:55 end:66
   04-10 17:26:25.943 I/amplayer( 2307): [parse_sysparam_str]j=3 mpeg12: start:0 end:8
   04-10 17:26:25.943 I/amplayer( 2307): [parse_sysparam_str]j=4 mpeg4: start:9 end:16
   04-10 17:26:25.943 I/amplayer( 2307): [parse_sysparam_str]j=5 mjpeg: start:47 end:54
   04-10 17:26:25.943 I/amplayer( 2307): pid[8]::Init State: mute_on=0 black=1        t_pos:1074475459s read_max_cnt=0
   04-10 17:26:25.943 I/amplayer( 2307): file::::[shttp://127.0.0.1:1666/],len=23
   04-10 17:26:26.003 I/ActivityManager( 3241): Displayed com.example.server/.MainActivity:        +858ms
   04-10 17:26:26.043 I/VideoView( 4440): Layout changed,left=202 top=100 right=642        bottom=417
   04-10 17:26:26.043 I/VideoView( 4440): Layout changed,oldLeft=202 oldTop=100        oldRight=642 oldBottom=417
   04-10 17:26:26.043 I/VideoView( 4440):        .left=202.top=100.right=642.bottom=417.oldLeft=202.oldTop=100.oldRight=642.oldBottom=417.Rotati       on=0
   04-10 17:26:26.043 I/amplayer( 2307): **[update_state]pid:8        status=BEGIN_INIT(last:UNKNOW_STATE) err=0x0 curtime=0 (ms:0) fulltime=0 lsttime=0
   04-10 17:26:26.043 I/amplayer( 2307): **[update_state]abuflevel=0.000 vbublevel=0.000        abufrp=0 vbufrp=0 read_end=0
   04-10 17:26:26.043 V/AmlogicPlayer( 2307): update_process pid=8, current=0,status=       [BEGIN_INIT]
   04-10 17:26:26.043 V/AmlogicPlayer( 2307): Playing percent =0,mPlayTime:0,mStreamTime:0
   04-10 17:26:26.043 V/AmSuperPlayer( 2307): [notify::405]
   04-10 17:26:26.043 V/AmSuperPlayer( 2307): [Notify::412]
   04-10 17:26:26.043 V/AmSuperPlayer( 2307): cookie=0x46970,msg=3,ext1=0,ext2=0
   04-10 17:26:26.043 I/amffmpeg( 2307): [tcp @ 0x44a40] TCP connect to 127.0.0.1 port 1666 
   04-10 17:26:26.043 I/amffmpeg( 2307): HTTP[GET / HTTP/1.1
   04-10 17:26:26.043 I/amffmpeg( 2307): User-Agent: AppleCoreMedia/1.0.0.8C148 (iPad; U;        CPU OS 4_2_1 like Mac OS X; zh_cn)
   04-10 17:26:26.043 I/amffmpeg( 2307): Accept: */*
   04-10 17:26:26.043 I/amffmpeg( 2307): Range: bytes=0-
   04-10 17:26:26.043 I/amffmpeg( 2307): Connection: close
   04-10 17:26:26.043 I/amffmpeg( 2307): Host: 127.0.0.1:1666
   04-10 17:26:26.043 I/amffmpeg( 2307): 
   04-10 17:26:26.043 I/amffmpeg( 2307): ]
   04-10 17:26:26.043 I/amffmpeg( 2307): [shttp @ 0x4c1b0] process_line:HTTP/1.1 200 OK 
   04-10 17:26:26.043 I/amffmpeg( 2307): [shttp @ 0x4c1b0] process_line:Content-Type:               audio/mp3 
   04-10 17:26:26.043 I/amffmpeg( 2307): [shttp @ 0x4c1b0] process_line:Connection: keep-       alive 
   04-10 17:26:26.043 I/amffmpeg( 2307): [shttp @ 0x4c1b0] process_line: 
   04-10 17:26:26.043 I/amffmpeg( 2307): getloopbuf size=4000000
   04-10 17:26:26.043 I/amffmpeg( 2307): ffio_fdopen (h->is_slowmedia=1,flags=1
   04-10 17:26:26.043 I/amffmpeg( 2307): lpbuffer block size=32768
   04-10 17:26:26.043 I/amffmpeg( 2307): url_lpopen used lp buf size=67108864
   04-10 17:26:26.043 I/amffmpeg( 2307): url_lpseek:offset=0        whence=65536,buffer=47968020,rp=47968020,wp=47968020,end=4b968020,pos=0
   04-10 17:26:26.043 I/amffmpeg( 2307): ffio_fdopen Register lpbuf
   04-10 17:26:26.043 I/amffmpeg( 2307): auto_switch_protol_t:list::
   04-10 17:26:26.053 V/MediaPlayerService( 2307): [103] setParameter(2000)
   04-10 17:26:26.053 V/AmSuperPlayer( 2307): [setParameter::352]
   04-10 17:26:26.213 I/amffmpeg( 2307): m3u_format_get_line line 4=ID3?
   04-10 17:26:26.213 I/amffmpeg( 2307): auto_switch_protol_t:nsc::
   04-10 17:26:26.213 I/amffmpeg( 2307): is_ncs_file check lineID3? ret=4
   04-10 17:26:26.213 I/amffmpeg( 2307): is_ncs_file check line ret=0
   04-10 17:26:26.213 I/amffmpeg( 2307): is_ncs_file=0
   04-10 17:26:32.483 I/ActivityManager( 3241): No longer want com.android.keychain (pid        4406): hidden #16
   04-10 17:26:32.483 I/ActivityManager( 3241): No longer want com.anttek.clockwiget (pid        3064): hidden #17
   04-10 17:26:32.493 W/ActivityManager( 3241): Scheduling restart of crashed service        com.anttek.clockwiget/.service.LocationService in 5000ms
   04-10 17:26:32.513 I/amplayer( 2307): [ffmpeg_open_file]        file=shttp://127.0.0.1:1666/,header=
   04-10 17:26:32.513 I/amplayer( 2307): ffmpeg error: Couldn't open input file!        ret==bebbb1b7
   04-10 17:26:32.513 I/amplayer( 2307): [player_dec_init]ffmpeg_open_file        failed(shttp://127.0.0.1:1666/)*****ret=fcffffff!
   04-10 17:26:32.513 I/amplayer( 2307): 
   04-10 17:26:32.513 I/amplayer( 2307): pid[8]player_thread release0 begin...(sta:0x30001)
   04-10 17:26:32.513 I/amplayer( 2307): [get_pts_video]No codec handler
   04-10 17:26:32.513 I/amplayer( 2307): **[update_state]pid:8               status=ERROR(last:BEGIN_INIT) err=0x3000001 curtime=0 (ms:0) fulltime=0 lsttime=0
   04-10 17:26:32.513 I/amplayer( 2307): **[update_state]abuflevel=0.000 vbublevel=0.000        abufrp=0 vbufrp=0 read_end=0
   04-10 17:26:32.513 V/AmlogicPlayer( 2307): update_process pid=8, current=0,status=[ERROR]
   04-10 17:26:32.513 V/AmSuperPlayer( 2307): [notify::405]
   04-10 17:26:32.513 V/AmSuperPlayer( 2307): [Notify::412]
   04-10 17:26:32.513 V/AmSuperPlayer( 2307): cookie=0x46970,msg=64,ext1=1,ext2=fcffffff
   04-10 17:26:32.523 V/AmSuperPlayer( 2307): [CreatePlayer::703]
   04-10 17:26:32.523 I/AmSuperPlayer( 2307): media.amplayer.enable is enabled
   04-10 17:26:32.523 I/AmSuperPlayer( 2307): media.stagefright.enable-player is disabled
   04-10 17:26:32.523 V/AmSuperPlayer( 2307): [CreatePlayer::714]
   04-10 17:26:32.523 V/AmSuperPlayer( 2307): Need to creat new player=3
   04-10 17:26:32.523 V/AmlogicPlayer( 2307): stop
          04-10 17:26:32.523 D/HTTP !!!( 4440): ERROR !!!
   04-10 17:26:32.523 I/amplayer( 2307): [player_stop:enter]pid=8
   04-10 17:26:32.523 I/amplayer( 2307): [player_stop]player_status=30001
   04-10 17:26:32.523 I/amplayer( 2307): [player_stop]pid=8 thread is already stopped
   04-10 17:26:32.523 D/#hello# ( 4440): nothing => just ending !!!!!
   04-10 17:26:32.523 V/AmlogicPlayer( 2307): AmlogicPlayer destructor
   04-10 17:26:32.523 V/AmlogicPlayer( 2307): release
   04-10 17:26:32.523 V/AmlogicPlayer( 2307): [release::1499]
   04-10 17:26:32.523 I/amplayer( 2307): [player_stop:enter]pid=8
   04-10 17:26:32.523 I/amplayer( 2307): [player_stop]player_status=30001
   04-10 17:26:32.523 I/amplayer( 2307): [player_stop]pid=8 thread is already stopped
   04-10 17:26:32.523 I/amplayer( 2307): [player_exit:enter]pid=8
   04-10 17:26:32.523 I/amplayer( 2307): [player_exit]player_state=0x30001
   04-10 17:26:32.523 I/amplayer( 2307): [player_stop:enter]pid=8
   04-10 17:26:32.523 I/amplayer( 2307): [player_stop]player_status=30001
   04-10 17:26:32.523 I/amplayer( 2307): [player_stop]pid=8 thread is already stopped
   04-10 17:26:32.523 I/amplayer( 2307): [player_thread_wait_exit:80]pid=[8] thead_id=427752
   04-10 17:26:32.523 V/AmlogicPlayer( 2307): Player status:ERROR, error occur
   04-10 17:26:32.523 V/AmSuperPlayer( 2307): [notify::405]
   04-10 17:26:32.523 V/AmSuperPlayer( 2307): [Notify::412]
   04-10 17:26:32.523 V/AmSuperPlayer( 2307): cookie=0x46970,msg=64,ext1=1,ext2=ffffffff
   04-10 17:26:32.523 I/amplayer( 2307): **[update_state]pid:8 status=EXIT(last:ERROR)        err=0x0 curtime=0 (ms:0) fulltime=0 lsttime=0
   04-10 17:26:32.523 I/amplayer( 2307): **[update_state]abuflevel=0.000 vbublevel=0.000 abufrp=0 vbufrp=0 read_end=0
   04-10 17:26:32.523 V/AmlogicPlayer( 2307): update_process pid=8, current=0,status=[EXIT]
   04-10 17:26:32.523 V/AmlogicPlayer( 2307): Player status:EXIT, playback exit
   04-10 17:26:32.523 I/amplayer( 2307): 
   04-10 17:26:32.523 I/amplayer( 2307): pid[8]::stop play, exit player thead!(sta:0x30004)
   04-10 17:26:32.523 I/amplayer( 2307): [player_thread_wait_exit:86]thead_id=427752 returning
   04-10 17:26:32.523 I/amplayer( 2307): [player_exit]player thread already exit: 0
   04-10 17:26:32.523 I/amplayer( 2307): [player_release_pid:72]release pid=8
   04-10 17:26:32.523 I/amplayer( 2307): [player_exit:exit]pid=8
   04-10 17:26:32.523 I/amplayer( 2307): [get_display_mode]mode=panel
   04-10 17:26:32.523 I/amplayer( 2307): 
   04-10 17:26:32.523 I/amplayer( 2307):  strlen=7
   04-10 17:26:32.523 I/amplayer( 2307): [get_display_mode]display_mode=panel
   04-10 17:26:32.523 I/amplayer( 2307): 
   04-10 17:26:32.523 I/amplayer( 2307): 
   04-10 17:26:32.523 I/amplayer( 2307): [display_mode_convert]disp_mode=panel
   04-10 17:26:32.523 I/amplayer( 2307): 
   04-10 17:26:32.523 I/amplayer( 2307): 
   04-10 17:26:32.523 I/amplayer( 2307): [display_mode_convert]disp_mode=panel
   04-10 17:26:32.523 I/amplayer( 2307): 
   04-10 17:26:32.523 I/amplayer( 2307): -->ffff
   04-10 17:26:32.523 I/amplayer( 2307): [enable_freescale]
   04-10 17:26:32.523 V/AmlogicPlayer( 2307): VideoViewClose=0
   04-10 17:26:32.523 V/AmlogicPlayer( 2307): [release::1509]
   04-10 17:26:32.523 V/AmlogicPlayer( 2307): History mgt old[shttp://127.0.0.1:1666/,0,0]
   04-10 17:26:32.523 V/AmlogicPlayer( 2307): History mgt    [shttp://127.0.0.1:1666/,1,0]
   04-10 17:26:32.523 V/AmSuperPlayer( 2307): createPlayer
   04-10 17:26:32.523 V/AmSuperPlayer( 2307):  create StagefrightPlayer
   04-10 17:26:32.523 V/AmSuperPlayer( 2307): [CreatePlayer::679]
   04-10 17:26:32.523 I/AwesomePlayer( 2307): setDataSource_l('http://127.0.0.1:1666/')
   04-10 17:26:32.523 V/AmSuperPlayer( 2307): [CreatePlayer::714]
   04-10 17:26:32.523 V/AmSuperPlayer( 2307): [CreatePlayer::730]
   04-10 17:26:32.523 V/AmSuperPlayer( 2307): Start new player now=3
   04-10 17:26:32.523 V/AmSuperPlayer( 2307): [initThread::763]
   04-10 17:26:32.523 V/ChromiumHTTPDataSource( 2307): connect on behalf of uid 0
   04-10 17:26:32.523 I/ChromiumHTTPDataSource( 2307): connect to http://127.0.0.1:1666/ @0