@@ -202,8 +202,10 @@ public bool HasPreview
202202 {
203203 this . hasPreview = value ;
204204 this . GeneratePreviewCommand . RaiseCanExecuteChanged ( ) ;
205+ this . PlaySourceCommand . RaiseCanExecuteChanged ( ) ;
205206 this . RaisePropertyChanged ( ( ) => this . SeekBarEnabled ) ;
206207 this . RaisePropertyChanged ( ( ) => this . HasPreview ) ;
208+ this . RaisePropertyChanged ( ( ) => this . PlayAvailable ) ;
207209 }
208210 }
209211
@@ -264,6 +266,33 @@ public int PreviewCount
264266 }
265267 }
266268
269+ public bool PlayAvailable
270+ {
271+ get
272+ {
273+ if ( ! this . HasPreview || this . mainViewModel . SourcePath == null )
274+ {
275+ return false ;
276+ }
277+
278+ string sourcePath = this . mainViewModel . SourcePath ;
279+ var fileAttributes = File . GetAttributes ( sourcePath ) ;
280+ if ( ( fileAttributes & FileAttributes . Directory ) == FileAttributes . Directory )
281+ {
282+ // Path is a directory. Can only preview when it's a DVD and we have a supported player installed.
283+ bool isDvd = Utilities . IsDvdFolder ( this . mainViewModel . SourcePath ) ;
284+ bool playerInstalled = Players . Installed . Count > 0 ;
285+
286+ return isDvd && playerInstalled ;
287+ }
288+ else
289+ {
290+ // Path is a file
291+ return true ;
292+ }
293+ }
294+ }
295+
267296 public HandBrakeInstance ScanInstance
268297 {
269298 get
@@ -299,6 +328,38 @@ public RelayCommand GeneratePreviewCommand
299328 }
300329 }
301330
331+ private RelayCommand playSourceCommand ;
332+ public RelayCommand PlaySourceCommand
333+ {
334+ get
335+ {
336+ return this . playSourceCommand ?? ( this . playSourceCommand = new RelayCommand ( ( ) =>
337+ {
338+ string sourcePath = this . mainViewModel . SourcePath ;
339+ var fileAttributes = File . GetAttributes ( sourcePath ) ;
340+ if ( ( fileAttributes & FileAttributes . Directory ) == FileAttributes . Directory )
341+ {
342+ // Path is a directory
343+ IVideoPlayer player = Players . Installed . FirstOrDefault ( p => p . Id == Settings . Default . PreferredPlayer ) ;
344+ if ( player == null )
345+ {
346+ player = Players . Installed [ 0 ] ;
347+ }
348+
349+ player . PlayTitle ( sourcePath , this . mainViewModel . SelectedTitle . TitleNumber ) ;
350+ }
351+ else
352+ {
353+ // Path is a file
354+ FileService . Instance . LaunchFile ( sourcePath ) ;
355+ }
356+ } , ( ) =>
357+ {
358+ return this . PlayAvailable ;
359+ } ) ) ;
360+ }
361+ }
362+
302363 private RelayCommand cancelPreviewCommand ;
303364 public RelayCommand CancelPreviewCommand
304365 {
0 commit comments