I can't use “Fast forward” and drag in the player under the Streaming mode! Who can help me? Is it a bug?

Feb 9, 2011 at 12:04 PM

The details is:
The silverlight media framework request a url in streaming mode, this url is not the real media url,I use #C  to response the request to hide the media url.
And I set the IIS no cache, so the media can't download to the internet temp folder.

The following code is response the binary streaming:

 

//response the streaming, the path is the physical path in the video server.
protected void ResponseFile(string path)
        {
            System.IO.Stream iStream = null;
            byte[] buffer = new Byte[102400];
            int length; long dataToRead;
            string filename = System.IO.Path.GetFileName(path);
            try
            {
                iStream = new System.IO.FileStream(path, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
                dataToRead = iStream.Length;
                context.Response.ContentType = "application/octet-stream";
                context.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8));
               while (dataToRead > 0)
                {
                    if (context.Response.IsClientConnected)
                    {
                        length = iStream.Read(buffer, 0, 102400);
                        context.Response.OutputStream.Write(buffer, 0, length);
                        context.Response.Flush();
                        buffer = new Byte[102400];
                        dataToRead = dataToRead - length;
                    }
                    else
                    {
                        dataToRead = -1;
                    }
                }
                iStream.Close();
            }
            catch (Exception ex)
            {
                context.Response.Write(ex.ToString());
            }
            finally
            {
                if (iStream != null)
                {
                    iStream.Close();
                }
            }
            GC.Collect();
        }


But I can't use “Fast forward” and drag  in the player under the Streaming mode! Who can help me? Is it a bug?

Coordinator
Feb 9, 2011 at 4:28 PM

JerryYin, the ability to seek or not comes from the underlying Silverlight MediaElement and is not supported in certain scenarios (most notably for progressive streaming). I suspect that this is what you are encountering. Here's a link to the docs on MediaElement.CanSeek (the property that SMF observes). http://msdn.microsoft.com/en-us/library/system.windows.controls.mediaelement.canseek(v=vs.95).aspx

One quick thought: you might be able to get around this by loading the file url directly and see if it works. If it does, use a tool like fiddler to see what headers it is sending down to the client and try to mimic that in your server side script. It might be just be that the MediaElement needs a file length or something like that.

Hope that helps,

Tim Greenfield

Feb 11, 2011 at 10:33 AM

The streaming works well, I think it is the bug of mediaelement, I think I can't drag because it base on the cache file in IE template folder. The player need add a function to support caculate the progress when drag. And in the server point, can receive the percent param from client, and return the request binary