I'm is someone able to point me in the right direction for playing multiple streams/AAC media either with a MediaElement or MediaPlayer. I have 3 streams that get returned from a server and this gets updated every 10 seconds so I add the new streams to the collection.
Problem is when I change the source of the MediaElement in the Media_Ended event and call Play() again it has a slight gap in the audio. What I'm wondering is if I should be creating a playlist, and if so how is this done?
I've also tried this sample: http://phonesm.codeplex.com/
but same thing when changing the source - there is a slight delay in playing the next stream/AAC link. Here's my source:
<mmppf:MediaPlayer x:Name="MediaPlayerPlayer"
Source=".AACLinkHere"
MediaEnded="MediaEndedChangeSource"
MediaEndedBehavior="Reset"
IsLive="True">
and the code behind:
private void MediaEndedChangeSource(object sender, Microsoft.PlayerFramework.MediaPlayerActionEventArgs e)
{
try
{
MediaPlayerPlayer.SetSource(new FileStream());
MediaPlayerPlayer.Source = new Uri(".NextAACLinkHere", UriKind.RelativeOrAbsolute);
Debug.WriteLine("*********************************************************test...adfadfadf");
}
catch (Exception exception)
{
Debug.WriteLine(exception.Message);
}
}
if anyone has any ideas that would be appreciated. Sample code would be even better! Cheers.
Related
I have been working in AS3 to stream 1080P video on YouTube and video gets start uploading and almost 4-5 minutes of the video has been uploaded successfully and afterwards YouTube shows that stream has been ended, but FFMPEG will never hits on "Exit" or any other method even after waiting for next 10 minutes.
Below is the method I am using.
public var _nativeProcessStartupInfo:NativeProcessStartupInfo;
public var _processArgs:Vector.<String>;
public var _process:NativeProcess;
protected function StartVideo_clickHandler(event:MouseEvent):void
{
_nativeProcessStartupInfo.executable = File.applicationStorageDirectory.resolvePath("ffmpeg.exe Path");
_processArgs.push('-re');
_processArgs.push('-i');
_processArgs.push(VideoPath);
_processArgs.push('-vcodec');
_processArgs.push('copy');
_processArgs.push('-acodec');
_processArgs.push('copy');
_processArgs.push('-maxrate');
_processArgs.push('4500k');
_processArgs.push('-bufsize');
_processArgs.push('9000k');
_processArgs.push('-pix_fmt');
_processArgs.push('yuv422p');
_processArgs.push('-preset');
_processArgs.push('fast');
_processArgs.push('-ac');
_processArgs.push('2');
_processArgs.push('-r');
_processArgs.push('30');
_processArgs.push('-g');
_processArgs.push('60');
_processArgs.push('-ar');
_processArgs.push('44100');
_processArgs.push('-f');
_processArgs.push('flv');
_processArgs.push(streamurl+'/'+streamname);
_nativeProcessStartupInfo.arguments = _processArgs;
_process = new NativeProcess();
_process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);
_process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, progress);
_process.addEventListener(NativeProcessExitEvent.EXIT, onExit);
_process.addEventListener(IOErrorEvent.STANDARD_OUTPUT_IO_ERROR, onIOErrorNativeProcess);
_process.addEventListener(IOErrorEvent.STANDARD_ERROR_IO_ERROR, onIOErrorNativeProcess);
_process.start(_nativeProcessStartupInfo);
}
public function onIOErrorNativeProcess(event:IOErrorEvent):void
{
trace(event.toString());
}
public function onOutputData(event:ProgressEvent):void
{
trace("Got: ", _process.standardOutput.readUTFBytes(_process.standardOutput.bytesAvailable));
}
public function progress(e:ProgressEvent):void
{
trace(e);
}
public function onExit(e:NativeProcessExitEvent):void
{
trace(e);
}
I have tried with 720P video too by changing bit rate from 4500k to 2500k which is as per YouTube and it is working fine but with 1080P something not went as per expectation.
Here are the video details:
Resolution : 1920*1080
Data Rate : 3220kbps
FrameRate : 20
Thanks in advance
There is two problem with the following code.
In the "progress" function I am not reading actual log of the FFMPEG, have to update progress event like below.
public function progress(e:ProgressEvent):void
{
trace("Progress: ", _process.standardOutput.readUTFBytes(_process.standardOutput.bytesAvailable));
}
For now I have just traced the log and code is working properly in Debug mode after creating build issue has been happening and after that I have logged all the data in file and then even after creating build everything is working fine.
I don't know the exact reason behind it, but this solution help me for now.
Thanks
I'm developing my own game with eclipse and I tried to export it and test it on an other computer. On my own computer the exported game worked fine but not on the other one. I started the jar from the commandline, so I can see the error and it is the error, mentioned in the headline, "Pixel format not accelerated" in this function (in line "Display.create(...)"):
public static void createDisplay() {
System.out.println("test1");
ContextAttribs attribs = new ContextAttribs(3, 2).withForwardCompatible(true).withProfileCore(true);
try {
System.out.println("test2");
Display.setDisplayMode(new DisplayMode(WIDTH,HEIGHT));
Display.create(new PixelFormat().withDepthBits(24), attribs);
Display.setTitle("Our First Display!");
System.out.println("test3");
GL11.glEnable(GL13.GL_MULTISAMPLE);
} catch (LWJGLException e) {
e.printStackTrace();
}
GL11.glViewport(0,0, WIDTH, HEIGHT);
lastFrameTime = getCurrentTime();
}
Now my question is, how I can get rid of this exception, so I can play the game on the other computer as well...
Thanks for you help :)
I am expermenting with video recording on Windows Phone 8. I want to handle the situation when user is putting my app to background, while it is recording a video. I would like to save the already recorded video before quitting.
I am handling this situation using the code from this example:
https://msdn.microsoft.com/en-us/library/windows/apps/mt243896.aspx
private async Task StopRecordingAsync()
{
try
{
Debug.WriteLine("Stopping recording...");
_isRecording = false;
await _mediaCapture.StopRecordAsync();
Debug.WriteLine("Stopped recording!");
}
catch (Exception ex)
{
Debug.WriteLine("Exception when stopping video recording: {0}", ex.ToString());
}
}
I am calling this method from the:
protected async override void OnNavigatingFrom(NavigatingCancelEventArgs e)
But the video is not being saved. In the debug console I get only the first message: "Stopping recording...", but there is no "Stopped recording!" message logged. It seems like the resources are being destroyed before I can handle them.
When your app is moved to the background you only have a short amount of time to run code.
Instead of having saving be triggered when you navigate from the page, instead look at the Application.Suspending event which allows you to use a deferral to try and run your code for a bit longer so you can finish tidying up before your app loses it's resource allocation.
Something like:
async protected void OnSuspending(object sender, SuspendingEventArgs args)
{
SuspendingDeferral deferral = args.SuspendingOperation.GetDeferral();
await StopRecordingAsync();
deferral.Complete();
}
Windows phone 8.1 new to world. Basic function is back button click. Is that function not working properly is this windows phone 8.1. Is that behavior or i'm made mistake.
Below code using in Homepage but this code calling from all other class too while clicking back. I need to access below method only on Home page .
Please check below code and refer me good solution.
Please look my code:
public HomePage()
{
this.InitializeComponent();
Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
}
void HardwareButtons_BackPressed(object sender, BackPressedEventArgs e)
{
}
Thanks
It is working properly. The BackPressed event is working app-wide. Two options that come to my mind:
write eventhandler that would recognize the Page in which you currently invoke it - simple example can look like this:
private void HardwareButtons_BackPressed(object sender, Windows.Phone.UI.Input.BackPressedEventArgs e)
{
Frame frame = Window.Current.Content as Frame;
if (frame == null) return;
if (frame.Content is HomePage)
{
e.Handled = true;
Debug.WriteLine("I'm in HomePage");
}
else if (frame.CanGoBack)
{
frame.GoBack();
e.Handled = true;
}
}
second option - subscribe to Windows.Phone.UI.Input.HardwareButtons.BackPressed when you enter the Page and unsubscribe when you leave the Page. Note that in this way there are some pitfalls - you have to handle properly OnNavigatedTo, OnNavigatedFrom, Suspending and Resuming (more about Lifecycle here). Note also that the subscription should be done before others - for example NavigationHelper.
Some remarks - the above code should work, but it also depends on other circumstances:
if there is something other subscribed to BackPressed before (in App.xaml.cs) - remember that usually events are fired in order they were subscribed
check if you are using NavigationHelper - it also subscribes to BackPressed
remember not to subscribe multiple times
remember to allow the User to leave your HomePage
I'm trying to use the Accelerometer in my application but an error comes up and I have been trying to get around it. I'm not the best programmer but I'm trying to get better. the error is "accelerometer_CurrentValueChanged doesn't exist". How do I use this properly, many sites use this line of code and I'm wondering why it isn't working for me. I have all the API and I have the references that I am meant to have but it just wont work. What is it even there for? any help would be much appreciated
If you have this in your output view, you need to check in your .cs, if you have this methode.If you don't have this, you need to choice to delete property in your xaml or put the correct methode in your .cs.
Like this =>
void accelerometer_CurrentValueChanged(object sender, SensorReadingEventArgs<AccelerometerReading> e)
{
//Do your job
}
But please use your favorite web browser for do a little search before post in stackoverflow.
Accelerometer accelerometer;
public AccelerometerTest(){
accelerometer = new Accelerometer();
if (accelerometer != null)
{
accelerometer.CurrentValueChanged += accelerometer_CurrentValueChanged;
accelerometer.TimeBetweenUpdates = TimeSpan.FromMilliseconds(1);
accelerometer.Start();
}
}
void accelerometer_CurrentValueChanged(object sender, SensorReadingEventArgs<AccelerometerReading> e)
{
//do your code
}